public static void setXMLPayload(SOAPEnvelope envelope, OMElement element) { SOAPBody body = envelope.getBody(); if (body == null) { body = ((SOAPFactory)envelope.getOMFactory()).createSOAPBody(); if (envelope.getHeader() != null) { envelope.getHeader().insertSiblingAfter(body); } else { envelope.addChild(body); } } else { body.removeChildren(); } body.addChild(element); }
errMsg.addChild(resultSer.getFirstElement()); resBody.addChild(errMsg); resEnv.addChild(resBody);
static SOAPEnvelope getEnvelope() throws IOException { SOAPFactory soapFac = OMAbstractFactory.getSOAP11Factory(); OMFactory omFac = OMAbstractFactory.getOMFactory(); SOAPEnvelope enp = soapFac.createSOAPEnvelope(); SOAPBody sopaBody = soapFac.createSOAPBody(); OMElement content = omFac.createOMElement(new QName("message")); OMElement data1 = omFac.createOMElement(new QName("part")); data1.setText("sample data"); content.addChild(data1); sopaBody.addChild(content); enp.addChild(sopaBody); return enp; } }
/** * Build the subscription reply * * @param sub * @return */ protected SOAPEnvelope buildSubscriptionReply(Subscribe sub) throws Exception { SOAPEnvelope reply = null; SOAPFactory factory = OMAbstractFactory.getSOAP11Factory(); reply = factory.createSOAPEnvelope(); SOAPBody body = factory.createSOAPBody(); // subscription reference SubscribeResponse response = new SubscribeResponse(); response.setSubscriptionEPR(sub.getConsumerEPR()); OMElement subscribeResponseElement = WsnHelper .subscribeResponseToOM(response); body.addChild(subscribeResponseElement); // create SOAP header SOAPHeader header = factory.createSOAPHeader(); // add SOAP header reply.addChild(header); // add SOAP body reply.addChild(body); return reply; }
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
public static void setXMLPayload(SOAPEnvelope envelope, OMElement element) { SOAPBody body = envelope.getBody(); if (body == null) { SOAPVersion version = envelope.getVersion(); if (version.getEnvelopeURI().equals( SOAP11Version.SOAP_ENVELOPE_NAMESPACE_URI)) { body = OMAbstractFactory.getSOAP11Factory().createSOAPBody(); } else { body = OMAbstractFactory.getSOAP12Factory().createSOAPBody(); } if (envelope.getHeader() != null) { envelope.getHeader().insertSiblingAfter(body); } else { envelope.addChild(body); } } else { for (Iterator it = body.getChildren(); it.hasNext();) { OMNode node = (OMNode) it.next(); node.discard(); } } body.addChild(element); }
/** * This method will read the entire content from the input stream of the request if there is a parsing error. * * @param synCtx Synapse message context. */ private void consumeInputOnOmException(MessageContext synCtx) { try { RelayUtils.consumeAndDiscardMessage(((Axis2MessageContext) synCtx).getAxis2MessageContext()); } catch (AxisFault axisFault) { log.error("Exception while consuming the input stream on Om Exception", axisFault); } SOAPEnvelope soapEnvelope; if (synCtx.isSOAP11()) { soapEnvelope = OMAbstractFactory.getSOAP11Factory().createSOAPEnvelope(); soapEnvelope.addChild(OMAbstractFactory.getSOAP11Factory().createSOAPBody()); } else { soapEnvelope = OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope(); soapEnvelope.addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); } try { synCtx.setEnvelope(soapEnvelope); } catch (AxisFault e) { log.error("Exception or Error occurred resetting SOAP Envelope", e); } } }
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
/** * Gets the envelope with sample data. * * @return the envelope * @throws IOException * Signals that an I/O exception has occurred. */ public static SOAPEnvelope getEnvelope() throws IOException { SOAPFactory soapFac = OMAbstractFactory.getSOAP11Factory(); OMFactory omFac = OMAbstractFactory.getOMFactory(); SOAPEnvelope enp = soapFac.createSOAPEnvelope(); SOAPBody sopaBody = soapFac.createSOAPBody(); OMElement content = omFac.createOMElement(new QName("message")); OMElement data1 = omFac.createOMElement(new QName("part")); data1.setText("sample data"); content.addChild(data1); sopaBody.addChild(content); enp.addChild(sopaBody); return enp; }
targetEnv.addChild(AxiomUtils.copy(node));
private SOAPEnvelope buildSoapEnvelope(String clientID, String value) { SOAPFactory soapFactory = OMAbstractFactory.getSOAP12Factory(); SOAPEnvelope envelope = soapFactory.createSOAPEnvelope(); SOAPHeader header = soapFactory.createSOAPHeader(); envelope.addChild(header); OMNamespace synNamespace = soapFactory. createOMNamespace("http://ws.apache.org/ns/synapse", "syn"); OMElement clientIDElement = soapFactory.createOMElement("ClientID", synNamespace); clientIDElement.setText(clientID); header.addChild(clientIDElement); SOAPBody body = soapFactory.createSOAPBody(); envelope.addChild(body); OMElement valueElement = soapFactory.createOMElement("Value", null); valueElement.setText(value); body.addChild(valueElement); return envelope; }
resService.addChild(resultSer.getFirstElement()); resBody.addChild(resService); resEnv.addChild(resBody);
body.addChild(bodyContent); envelope.addChild(body); messageContext.setEnvelope(envelope);
soapEnvelope = OMAbstractFactory. getSOAP11Factory().createSOAPEnvelope(); soapEnvelope.addChild( OMAbstractFactory.getSOAP11Factory().createSOAPBody()); } else { soapEnvelope = OMAbstractFactory. getSOAP12Factory().createSOAPEnvelope(); soapEnvelope.addChild( OMAbstractFactory.getSOAP12Factory().createSOAPBody());
try { mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); } catch (Exception e) { handleException("Unable to attach the SOAP envelope to " +
try { mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); } catch (Exception e) { handleException("Unable to attach the SOAP envelope to " +
/** * Create a empty message context * * @return A context with empty message * @throws AxisFault on an error creating a context */ private MessageContext createMessageContext() throws AxisFault { Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration()); org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext(); axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MC.setServiceContext(svcCtx); axis2MC.setOperationContext(opCtx); axis2MC.setTransportIn(new TransportInDescription("http")); axis2MC.setTo(new EndpointReference("http://localhost:9000/services/SimpleStockQuoteService")); MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment); mc.setMessageID(UIDGenerator.generateURNString()); mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); return mc; } }
/** * Create a empty message context. * * @return A context with empty message * @throws AxisFault on an error creating a context */ private MessageContext createMessageContext() throws AxisFault { Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration()); org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext(); axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MC.setServiceContext(svcCtx); axis2MC.setOperationContext(opCtx); MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment); mc.setMessageID(UIDGenerator.generateURNString()); mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); return mc; } }
/** * Create a empty message context * * @return A context with empty message * @throws AxisFault on an error creating a context */ private MessageContext createMessageContext() throws AxisFault { Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration()); org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext(); axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MC.setServiceContext(svcCtx); axis2MC.setOperationContext(opCtx); MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment); mc.setMessageID(UIDGenerator.generateURNString()); mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); return mc; }
/** * Create a empty message context * * @return A context with empty message * @throws AxisFault on an error creating a context */ private MessageContext createMessageContext() throws AxisFault { Axis2SynapseEnvironment synapseEnvironment = new Axis2SynapseEnvironment(new SynapseConfiguration()); org.apache.axis2.context.MessageContext axis2MC = new org.apache.axis2.context.MessageContext(); axis2MC.setConfigurationContext(new ConfigurationContext(new AxisConfiguration())); ServiceContext svcCtx = new ServiceContext(); OperationContext opCtx = new OperationContext(new InOutAxisOperation(), svcCtx); axis2MC.setServiceContext(svcCtx); axis2MC.setOperationContext(opCtx); axis2MC.setTransportIn(new TransportInDescription("http")); // axis2MC.setTo(new EndpointReference("http://localhost:9000/services/SimpleStockQuoteService")); MessageContext mc = new Axis2MessageContext(axis2MC, new SynapseConfiguration(), synapseEnvironment); mc.setMessageID(UIDGenerator.generateURNString()); mc.setEnvelope(OMAbstractFactory.getSOAP12Factory().createSOAPEnvelope()); mc.getEnvelope().addChild(OMAbstractFactory.getSOAP12Factory().createSOAPBody()); return mc; } }