1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 | import java.io.IOException; import javax.xml.namespace.QName; import javax.xml.soap.*; import javax.xml.ws.*; import javax.xml.ws.soap.SOAPBinding; public class DispatchClient { public static void main(String args[]) { String prefix = "ns1" ; Service svc = Service.create( new QName(svcNamespace, "stockService" )); QName portQName = new QName(svcNamespace, "stockPort" ); svc.addPort(portQName, SOAPBinding.SOAP11HTTP_BINDING, Dispatch<SOAPMessage> dispatch = svc.createDispatch(portQName, SOAPMessage. class , Service.Mode.MESSAGE); try { MessageFactory msgFactory = MessageFactory.newInstance( SOAPConstants.SOAP_1_1_PROTOCOL); SOAPMessage request = msgFactory.createMessage(); request.getSOAPBody(). addChildElement( "getBeersFrom" , prefix, svcNamespace).addChildElement( "arg0" ). addTextNode( "Belgium" ); SOAPMessage response = dispatch.invoke(request); response.writeTo(System.out); } catch (SOAPException | IOException ex) { ex.printStackTrace(); } } // end main } // end class |
2 February 2014
Creating a JAX-WS based Dispatch client
Labels:
DWS-4050-EE6,
java,
JAX-WS,
JAXB
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment