String namespace = "http://www.csapi.org/s"; String nsPrefix = "loc"; envelope.setAttribute("xmlns:" + nsPrefix , namespace); SOAPHeader header = envelope.getHeader(); SOAPBody body = envelope.getBody(); QName bodyName = new QName(namespace, "syncOrderRelationResponse", nsPrefix); SOAPBodyElement purchaseLineItems = body.addBodyElement(bodyName); QName childName = new QName(namespace,"result", nsPrefix); SOAPElement product = purchaseLineItems.addChildElement(childName); product.addTextNode("0"); childName = new QName(namespace,"resultDescription", nsPrefix); product = purchaseLineItems.addChildElement(childName); product.addTextNode("0");
SOAPBodyElement artifactResponseElement = (SOAPBodyElement) iterator.next(); if (StringUtils.equals(SAMLConstants.SAML20P_NS, artifactResponseElement.getNamespaceURI()) && StringUtils.equals(ArtifactResponse.DEFAULT_ELEMENT_LOCAL_NAME, artifactResponseElement.getLocalName())) { artifactResponseElement.getNamespaceURI() + " and localName: " + artifactResponseElement.getLocalName());
soapBodyElement.addChildElement(soapElement); soapBodyElement.addTextNode(nodeValue);
SOAPMessage sm = MessageFactory.newInstance().createMessage(); sm.setProperty(SOAPMessage.WRITE_XML_DECLARATION, "true"); sm.setProperty(SOAPMessage.CHARACTER_SET_ENCODING, "UTF-8"); SOAPPart sp = sm.getSOAPPart(); SOAPEnvelope se = sp.getEnvelope(); se.setEncodingStyle("http://schemas.xmlsoap.org/soap/encoding/"); se.setAttribute("xmlns:SOAP-ENC", "http://schemas.xmlsoap.org/soap/encoding/"); se.setAttribute("xmlns:soa", "http://www.sbg.com"); SOAPBody sb = sm.getSOAPBody(); SOAPBodyElement el = sb.addBodyElement(new QName("http://www.sbg.com", "response", "soa")); el.setAttribute("_ctxID", "cid=xref_members,cn=admin"); el.setAttribute("status", "OK"); SOAPElement in = el.addChildElement("response_code"); in.setValue("0000"); sm.writeTo(System.out);
bodyElement.removeContents(); bodyElement.addChildElement("Include", "xop", XOP_NAMESPACE).setAttribute("href", "cid:" + ref.toString());
SOAPElement uName = bodyElement.addChildElement("uName"); uName.addTextNode("k2r2t1zvc"); SOAPElement uPin = bodyElement.addChildElement("uPin"); uPin.addTextNode("21737629"); SOAPElement MSISDN = bodyElement.addChildElement("MSISDN"); MSISDN.addTextNode("09278328310"); SOAPElement returnElement = (SOAPElement)responseElement.getChildElements().next();
private void checkReturn(final SOAPBodyElement result, final String name) { Assert.assertNotNull(result); Assert.assertEquals(XmlUtil.toString(result), "submit", result.getElementName().getLocalName()); Assert.assertEquals(XmlUtil.toString(result), this.processNamespace, result.getElementName().getURI()); Assert.assertNotNull(XmlUtil.toString(result), result.getFirstChild()); Assert.assertNotNull(XmlUtil.element(result)); final Element st = XmlUtil.element(result); Assert.assertEquals("st", st.getLocalName()); Assert.assertEquals(XmlUtil.toString(st), this.processNamespace, st.getNamespaceURI()); Assert.assertNotNull(st.getFirstChild()); Assert.assertTrue(st.getFirstChild() instanceof Text); final Text text = (Text) st.getFirstChild(); Assert.assertEquals("hello " + name, text.getData()); }
@Override public SOAPMessage invoke(SOAPMessage soapMessage) { String targetSystem = extractTargetSystemFromUrl(); String callingSystem = extractCallingSystemFromRequest(); try { String sourceSystem = extractCallingSystemFromRequest(); String correlationId = extractCorrelationIdFromRequest(); // Get a DOM document from the SOAP body element. Document soapBody = XmlUtils.documentFromSoapBody(soapMessage); // Extract document type and xml String serviceContract = XmlUtils.getFirstElementChild(soapMessage.getSOAPBody()).getNamespaceURI(); String messageBody = XmlUtils.getDocumentAsString(soapBody); String targetOrg = extractTargetOrg(soapMessage); MessageMeta message = messageService.create(sourceSystem, targetSystem, targetOrg, serviceContract, messageBody, correlationId); if ( log.isInfoEnabled() ) { String msgId = message.getId().toString(); logInfo(getLogger(), identifyMsg(message) + " saved by " + callingSystem, msgId, message); } return getReturnCode(); } catch (Exception e) { if ( log.isErrorEnabled() ) { String msg = "Error for ServiceConsumer " + callingSystem + " when trying to send message"; logError(getLogger(), msg, null, null, e); } // generate a SOAPFAult with the MT0001 error message in the <faultstring> node throw new RuntimeException(ReceiveErrorCodes.MB0001.toString()); } finally { resetLogContext(); } }
Name soapName = soapBodyElement.getElementName(); QName xmlElementName = new QName(soapName.getURI(), soapName.getLocalName()); opMetaData = epMetaData.getOperation(xmlElementName);
public SOAPMessage sendMessage() throws Exception { SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = conFactory.createConnection(); MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_1_PROTOCOL); SOAPMessage msg = msgFactory.createMessage(); SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-mtom:1.0", "image")); bodyElement.setTextContent(imageData); return connection.call(msg, new URL(SWITCHYARD_WEB_SERVICE)); }
public SOAPMessage sendMessage() throws Exception { SOAPConnectionFactory conFactory = SOAPConnectionFactory.newInstance(); SOAPConnection connection = conFactory.createConnection(); MessageFactory msgFactory = MessageFactory.newInstance(SOAPConstants.SOAP_1_2_PROTOCOL); SOAPMessage msg = msgFactory.createMessage(); SOAPBodyElement bodyElement = msg.getSOAPBody().addBodyElement(new QName("urn:switchyard-quickstart:soap-attachment:1.0", "echoImage")); bodyElement.addTextNode("cid:switchyard.png"); // CXF does not set content-type. msg.getMimeHeaders().addHeader("Content-Type", "multipart/related; type=\"text/xml\"; start=\"<root.message@cxf.apache.org>\""); msg.getSOAPPart().setContentId("<root.message@cxf.apache.org>"); AttachmentPart ap = msg.createAttachmentPart(); ap.setDataHandler(new DataHandler(new StreamDataSource())); ap.setContentId("<switchyard.png>"); msg.addAttachmentPart(ap); return connection.call(msg, new URL(SWITCHYARD_WEB_SERVICE)); }
private void checkReturn(final SOAPBodyElement result, final String name) { Assert.assertNotNull(result); Assert.assertEquals(XmlUtil.toString(result), "submit", result.getElementName().getLocalName()); Assert.assertEquals(XmlUtil.toString(result), this.helloProcessNamespace, result.getElementName().getURI()); Assert.assertNotNull(XmlUtil.toString(result), result.getFirstChild()); Assert.assertNotNull(XmlUtil.element(result)); final Element st = XmlUtil.element(result); Assert.assertEquals("st", st.getLocalName()); Assert.assertEquals(XmlUtil.toString(st), this.helloProcessNamespace, st.getNamespaceURI()); Assert.assertNotNull(st.getFirstChild()); Assert.assertTrue(st.getFirstChild() instanceof Text); final Text text = (Text) st.getFirstChild(); Assert.assertEquals(name, text.getData()); }
String serviceContract = XmlUtils.getFirstElementChild(soapMessage.getSOAPBody()).getNamespaceURI(); String messageBody = XmlUtils.getDocumentAsString(soapBody);
if (soapBodyElement != null) Name soapName = soapBodyElement.getElementName(); faultString = "Endpoint " + epMetaData.getPortName() + " does not contain operation meta data for: " + soapName;
private SOAPMessage createSoapMessage( SOAPVersion soapVersion, String contentId ) throws SOAPException { String soapProtocol = SOAPConstants.SOAP_1_2_PROTOCOL; if ( isSoap11( soapVersion ) ) soapProtocol = SOAPConstants.SOAP_1_1_PROTOCOL; MessageFactory messageFactory = MessageFactory.newInstance( soapProtocol ); SOAPMessage message = messageFactory.createMessage(); SOAPPart soapPart = message.getSOAPPart(); SOAPEnvelope envelope = soapPart.getEnvelope(); SOAPBody body = envelope.getBody(); envelope.createName( "response", CommonNamespaces.WMS_PREFIX, CommonNamespaces.WMSNS ); Name name = envelope.createName( "response", CommonNamespaces.WMS_PREFIX, CommonNamespaces.WMSNS ); SOAPBodyElement bodyElement = body.addBodyElement( name ); bodyElement.setTextContent( contentId ); return message; }
String namespace = "http://www.csapi.org/s"; SOAPHeader header = envelope.getHeader(); SOAPBody body = envelope.getBody(); QName bodyName = new QName(namespace, "syncOrderRelationResponse"); SOAPBodyElement purchaseLineItems = body.addBodyElement(bodyName); QName childName = new QName(namespace,"result"); SOAPElement product = purchaseLineItems.addChildElement(childName); product.addTextNode("0"); childName = new QName(namespace,"resultDescription"); product = purchaseLineItems.addChildElement(childName); product.addTextNode("0"); outgoingMessage.writeTo(System.out);
private void checkReturn(final SOAPBodyElement result, final String name) { Assert.assertNotNull(result); Assert.assertEquals(XmlUtil.toString(result), "submit", result.getElementName().getLocalName()); Assert.assertEquals(XmlUtil.toString(result), this.helloProcessNamespace, result.getElementName().getURI()); Assert.assertNotNull(XmlUtil.toString(result), result.getFirstChild()); Assert.assertNotNull(XmlUtil.element(result)); final Element st = XmlUtil.element(result); Assert.assertEquals("st", st.getLocalName()); Assert.assertEquals(XmlUtil.toString(st), this.helloProcessNamespace, st.getNamespaceURI()); Assert.assertNotNull(st.getFirstChild()); Assert.assertTrue(st.getFirstChild() instanceof Text); final Text text = (Text) st.getFirstChild(); Assert.assertEquals(name, text.getData()); }
final SOAPBodyElement result = this.getSOAPBodyElement(response); Assert.assertNotNull(result); Assert.assertEquals(XmlUtil.toString(result), "CreateSequenceResponse", result.getElementName().getLocalName()); Assert.assertEquals(XmlUtil.toString(result), WSRMTest.WS_RM_NS_URI, result.getElementName().getURI()); sequenceIdentifier = XmlUtil.element(result, WSRMTest.WS_RM_NS_URI, "Identifier").getTextContent(); } else {
SOAPBody body = message.getSOAPBody(); QName bodyName = new QName("http://www.webserviceX.NET", "GetAtomicNumber"); SOAPBodyElement bodyElement = body.addBodyElement(bodyName); SOAPElement symbol = bodyElement.addChildElement("MyMetal"); symbol.addTextNode("iron"); SOAPConnection connection = SOAPConnectionFactory.newInstance().createConnection(); SOAPMessage response = connection.call(message, endpoint); connection.close(); message.writeTo(System.out); System.out.println(); response.writeTo(System.out); System.out.println();
public void process(Exchange exchange) throws Exception { byte[] body2 = (byte[]) exchange.getOut().getBody(); ByteArrayInputStream bais = new ByteArrayInputStream( body2 ); SOAPMessage soapMessage = MessageFactory.newInstance().createMessage(); SOAPBody soapBody = soapMessage.getSOAPPart().getEnvelope().getBody(); QName payloadName = new QName( "http://soap.jax.drools.org/", "executeResponse", "ns1" ); QName responseName = new QName( "http://soap.jax.drools.org/", "return", "ns1" ); SOAPBodyElement payload = soapBody.addBodyElement( payloadName ); SOAPElement response = payload.addChildElement( responseName ); response.addTextNode( StringUtils.toString( bais ) ); ByteArrayOutputStream baos = new ByteArrayOutputStream(); soapMessage.writeTo( baos ); exchange.getOut().setBody( new String( baos.toByteArray() ) ); }