cxf-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dev <>
Subject Question regarding SOAPBody and precreated XML payload
Date Thu, 21 Jul 2011 20:19:11 GMT
Hi -

My problem definition is as follows: -

I need to create a WS client connecting an WS endpoint using HTTPS and
recover the ServiceName and PortName from WSDL. Once I retrieve the
ServiceName and PortName, I need to send a SOAP message. Here is where I
have run into problem. I already have a pre-created XML which will go into
the SOAP body, but I am unable to determine how to add that to the SOAPBody.

So far my code looks like this I have commented the section where I want to
insert the xml: -

                 ServiceInfo serviceInfo = getServices(wsdlUrl).get(0);
		QName serviceName = serviceInfo.getName();		
		QName portName = serviceInfo.getBindings().iterator().next().getName();

		System.out.println(serviceName.getLocalPart() + " "
				+ portName.getLocalPart());

		Service service = Service.create(serviceName);
		service.addPort(portName, SOAPBinding.SOAP12HTTP_BINDING,

		/** Create a Dispatch instance from a service. **/
		Dispatch<SOAPMessage> dispatch = service.createDispatch(portName,
				SOAPMessage.class, Service.Mode.MESSAGE);

		/** Create SOAPMessage request. **/
		// compose a request message
		MessageFactory mf = MessageFactory

		// Create a message. This example works with the SOAPPART.
		SOAPMessage request = mf.createMessage();
		SOAPPart part = request.getSOAPPart();

		// Obtain the SOAPEnvelope and header and body elements.
		SOAPEnvelope env = part.getEnvelope();
		SOAPHeader header = env.getHeader();
		SOAPBody body = env.getBody();
		// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@


		// @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@

		/** Invoke the service endpoint. **/
		SOAPMessage response = dispatch.invoke(request);

Can anyone provide some insight?

Best Regards-

View this message in context:
Sent from the cxf-dev mailing list archive at

View raw message