public void setStates(OMElement locationConfiguration) throws RegistryException { Iterator confElements = locationConfiguration.getChildElements(); while (confElements.hasNext()) { OMElement confElement = (OMElement)confElements.next(); if (confElement.getQName().equals(new QName("state"))) { states.put(confElement.getAttributeValue(new QName("key")), confElement.getText()); } } }
OMFactory omFactory = OMAbstractFactory.getOMFactory(); OMElement omSecurityElement = omFactory.createOMElement(new QName( "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd", "Security", "wsse"), null); OMElement omusertoken = omFactory.createOMElement(new QName("http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd", "UsernameToken", "wsu"), null); OMElement omuserName = omFactory.createOMElement(new QName("", "Username", "wsse"), null); omuserName.setText("myusername"); OMElement omPassword = omFactory.createOMElement(new QName("", "Password", "wsse"), null); omPassword.addAttribute("Type","http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText",null ); omPassword.setText("mypassword"); omusertoken.addChild(omuserName); omusertoken.addChild(omPassword); omSecurityElement.addChild(omusertoken); stub._getServiceClient().addHeader(omSecurityElement);
@SuppressWarnings("unchecked") private static OMElement stripNamespace(OMElement element) { OMElement parent = OM.createOMElement(new QName("", element.getLocalName())); Iterator<OMElement> iter = (Iterator<OMElement>) element.getChildElements(); while (iter.hasNext()) { OMElement child = iter.next(); child = child.cloneOMElement(); parent.addChild(child); } return parent; }
public String getURL() { String urlValue = null; OMElement url = data.getFirstChildWithName(new QName( DRConstants.SERVICE_DATA.URL)); if (url != null) { urlValue = url.getText(); } return urlValue; }
_messageContext = new org.apache.axis2.context.MessageContext(); env = this.toEnvelope(Stub.getFactory(_operationClient.getOptions().getSoapVersionURI()), nfeDistDFeInteresse, this.optimizeContent(new javax.xml.namespace.QName("http://www.portalfiscal.inf.br/nfe/wsdl/NFeDistribuicaoDFe", "nfeDistDFeInteresse"))); _messageContext.setEnvelope(env); final org.apache.axiom.soap.SOAPEnvelope _returnEnv = _returnMessageContext.getEnvelope(); final java.lang.Object object = this.fromOM(_returnEnv.getBody().getFirstElement(), NFeDistDFeInteresseResponse.class, this.getEnvelopeNamespaces(_returnEnv)); return (NFeDistDFeInteresseResponse) object; } catch (final org.apache.axis2.AxisFault f) { final org.apache.axiom.om.OMElement faultElt = f.getDetail(); if (faultElt != null) { if (this.faultExceptionNameMap.containsKey(faultElt.getQName())) { final java.lang.String exceptionClassName = (java.lang.String) this.faultExceptionClassNameMap.get(faultElt.getQName()); final java.lang.Class exceptionClass = java.lang.Class.forName(exceptionClassName); final java.lang.Exception ex = (java.lang.Exception) exceptionClass.newInstance(); final java.lang.String messageClassName = (java.lang.String) this.faultMessageMap.get(faultElt.getQName()); final java.lang.Class messageClass = java.lang.Class.forName(messageClassName); final java.lang.Object messageObject = this.fromOM(faultElt, messageClass, null); final java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", messageClass); m.invoke(ex, messageObject); throw new java.rmi.RemoteException(ex.getMessage(), ex); } catch (final ClassCastException | InstantiationException | IllegalAccessException | java.lang.reflect.InvocationTargetException | NoSuchMethodException | ClassNotFoundException e) {
private static String getProxyHost(OMElement proxyConfiguration) throws AxisFault { OMElement proxyHostElement = proxyConfiguration.getFirstChildWithName(new QName(PROXY_HOST_ELEMENT)); if (proxyHostElement == null) { log.error(PROXY_HOST_ELEMENT_NOT_FOUND); throw new AxisFault(PROXY_HOST_ELEMENT_NOT_FOUND); } String proxyHost = proxyHostElement.getText(); if (proxyHost == null) { log.error(PROXY_HOST_ELEMENT_WITH_EMPTY_VALUE); throw new AxisFault(PROXY_HOST_ELEMENT_WITH_EMPTY_VALUE); } return proxyHost; }
public static MessageContext sendUsingSwA(String fileName, String targetEPR) throws IOException { OperationClient mepClient = sender.createClient(ServiceClient.ANON_OUT_IN_OP); MessageContext mc = new MessageContext(); String attachmentID = mc.addAttachment(dataHandler); OMElement request = factory.createOMElement("request", ns); OMElement imageId = factory.createOMElement("imageId", ns); imageId.setText(attachmentID); request.addChild(imageId); payload.addChild(request); env.getBody().addChild(payload); mc.setEnvelope(env); MessageContext response = mepClient.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE); SOAPBody body = response.getEnvelope().getBody(); String imageContentId = body. getFirstChildWithName(new QName("http://services.samples", "uploadFileUsingSwAResponse")). getFirstChildWithName(new QName("http://services.samples", "response")). getFirstChildWithName(new QName("http://services.samples", "imageId")). getText(); Attachments attachment = response.getAttachmentMap();
private static String getTextValueFromOMElement(OMElement omEl) { String nillValue = omEl.getAttributeValue( new QName(DBConstants.XSI_NAMESPACE, DBConstants.NIL)); if (nillValue != null && (nillValue.equals("1") || nillValue.equals("true"))) { return null; } else { return omEl.getText(); } }
public OMElement processDocument(InputStream inputStream, String contentType, MessageContext messageContext) throws AxisFault { try { //Fix for https://wso2.org/jira/browse/CARBON-7256 messageContext.setProperty(Constants.Configuration.CONTENT_TYPE, contentType); //We will create a SOAP message, which holds the input message as a blob SOAPFactory factory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope env = factory.getDefaultEnvelope(); if (inputStream != null) { OMNamespace ns = factory.createOMNamespace( RelayConstants.BINARY_CONTENT_QNAME.getNamespaceURI(), "ns"); OMElement omEle = factory.createOMElement( RelayConstants.BINARY_CONTENT_QNAME.getLocalPart(), ns); StreamingOnRequestDataSource ds = new StreamingOnRequestDataSource(inputStream); DataHandler dataHandler = new DataHandler(ds); //create an OMText node with the above DataHandler and set optimized to true OMText textData = factory.createOMText(dataHandler, true); omEle.addChild(textData); env.getBody().addChild(omEle); } return env; } catch (SOAPProcessingException e) { throw AxisFault.makeFault(e); } catch (OMException e) { throw AxisFault.makeFault(e); } }
private void createChartReportElement() { OMFactory fac = OMAbstractFactory.getOMFactory(); chartReportElement = fac.createOMElement(new QName(CHART_REPORT)); chartReportElement.addAttribute("name", chartReport.getReportName(), null); reportElement.addChild(chartReportElement); }
public String getProofKeyType() throws AxisFault { try { MessageContext msgCtx = MessageContext.getCurrentMessageContext(); AxisConfiguration config = msgCtx.getConfigurationContext().getAxisConfiguration(); AxisService service = config.getService(ServerConstants.STS_NAME); Parameter origParam = service .getParameter(SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG .getLocalPart()); if(origParam != null) { OMElement samlConfigElem = origParam.getParameterElement(). getFirstChildWithName(SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG); SAMLTokenIssuerConfig samlConfig = new SAMLTokenIssuerConfig(samlConfigElem); return samlConfig.getProofKeyType(); } else { throw new AxisFault("missing parameter : " + SAMLTokenIssuerConfig.SAML_ISSUER_CONFIG.getLocalPart()); } } catch (Exception e) { throw new AxisFault(e.getMessage(), e); } }
public void onMessage(MessageContext arg0) { SOAPBody body = arg0.getEnvelope().getBody(); OMElement echoStringResponseElem = body.getFirstChildWithName(new QName (applicationNamespaceName,echoStringResponse)); if (echoStringResponseElem==null) { System.out.println("Error: SOAPBody does not have a 'echoStringResponse' child"); return; } OMElement echoStringReturnElem = echoStringResponseElem.getFirstChildWithName(new QName (applicationNamespaceName,EchoStringReturn)); if (echoStringReturnElem==null) { System.out.println("Error: 'echoStringResponse' element does not have a 'EchoStringReturn' child"); return; } String resultStr = echoStringReturnElem.getText(); System.out.println("Callback '" + name + "' got result:" + resultStr); } }
/** * Guess the message type to use for JMS looking at the message contexts' envelope * @param msgContext the message context * @return JMSConstants.JMS_BYTE_MESSAGE or JMSConstants.JMS_TEXT_MESSAGE or null */ private String guessMessageType(MessageContext msgContext) { OMElement firstChild = msgContext.getEnvelope().getBody().getFirstElement(); if (firstChild != null) { if (BaseConstants.DEFAULT_BINARY_WRAPPER.equals(firstChild.getQName())) { return JMSConstants.JMS_BYTE_MESSAGE; } else if (BaseConstants.DEFAULT_TEXT_WRAPPER.equals(firstChild.getQName())) { return JMSConstants.JMS_TEXT_MESSAGE; } } return null; }
@Override public void setPayload(OMElement bodyContent) throws XMLStreamException { OMFactory factory = bodyContent.getOMFactory(); OMElement returnElement = factory.createOMElement(new QName(bodyContent.getNamespace().getPrefix() + ":return")); returnElement.setText(String.valueOf(succeed)); bodyContent.addChild(returnElement); }
SOAPEnvelope mes = messageContext.getEnvelope(); SOAPHeader mesh = mes.getHeader(); SOAPBody mesb = mes.getBody(); OMElement messageId = mesh.getFirstChildWithName(new QName("http://www.w3.org/2005/08/addressing","MessageID")); String messageIDStr = messageId.getText(); OMElement bodyChild = mesb.getFirstElement(); OMElement remoteAddress = bodyChild.getFirstChildWithName(new QName( "http://YourNameSpaceURI", "remoteAddress")); String remoteAddressStr = remoteAddress.getText();
private void populatePropertyName(BeanMediator mediator, OMElement elem) { String attributeValue; attributeValue = elem.getAttributeValue(new QName(BeanConstants.PROPERTY)); if (attributeValue != null) { mediator.setPropertyName(attributeValue); } else { handleException("'property' attribute of Bean mediator is required when " + "SET/GET_PROPERTY action is set."); } }
@SuppressWarnings("unchecked") private void secureVaultResolve(OMElement dbsElement) { String secretAliasAttr = dbsElement.getAttributeValue( new QName(DataSourceConstants.SECURE_VAULT_NS, DataSourceConstants.SECRET_ALIAS_ATTR_NAME)); if (secretAliasAttr != null) { dbsElement.setText(DBUtils.loadFromSecureVault(secretAliasAttr)); } Iterator<OMElement> childEls = (Iterator<OMElement>) dbsElement.getChildElements(); while (childEls.hasNext()) { this.secureVaultResolve(childEls.next()); } }
private static OMElement getSerializedDescription(MessageProcessor processor) { OMElement descriptionElem = fac.createOMElement( new QName(SynapseConstants.SYNAPSE_NAMESPACE, "description")); if (processor.getDescription() != null) { descriptionElem.setText(processor.getDescription()); return descriptionElem; } else { return null; } }
/** * This method will check the given OMElement represent either a static property or not * * @param property - OMElement to be checked for the static property * @return boolean true if the elemet represents a static property element false otherwise */ public static boolean isStaticProperty(OMElement property) { return "property".equals(property.getLocalName().toLowerCase()) && (property.getAttributeValue(new QName("expression")) == null); }
/** * Reads the SOAP body of a message and attempts to retreive the session identifier string * * @param msgCtx Axis2 MessageContext * @return a String uniquely identifying a session or null */ public static String getSourceSession(MessageContext msgCtx) { String srcSession; SOAPBody body = msgCtx.getEnvelope().getBody(); OMNamespace ns = getNamespaceOfFIXPayload(body); if (ns == null) { OMElement messageNode = body.getFirstChildWithName(new QName(FIXConstants.FIX_MESSAGE)); srcSession = messageNode.getAttributeValue(new QName( FIXConstants.FIX_MESSAGE_INCOMING_SESSION)); } else { srcSession = getSourceSession(body, ns); } return srcSession; }