How to Call a SOAP Service with the JAX-WS Dispatch API


import javax.xml.namespace.QName;
import javax.xml.transform.Source;

public final class JaxWsSample {

  public static void main(final String[] args) throws Exception {
    final Service service = Service.create(new URL("http://localhost/jaxwssample/SampleService?WSDL"), new QName("", "SampleService"));

    final Dispatch dispatch = service.createDispatch(new QName("", "SamplePort"), Source.class /* or JAXBContext */, Mode.PAYLOAD /* or Mode.MESSAGE */);

    dispatch.invoke(...); /* or invokeAsync or invokeOneWay */


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s