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

import java.net.URL;

import javax.xml.namespace.QName;
import javax.xml.transform.Source;
import javax.xml.ws.Dispatch;
import javax.xml.ws.Service;
import javax.xml.ws.Service.Mode;

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("http://fernandoribeiro.eti.br/sample/jaxws", "SampleService"));

    final Dispatch dispatch = service.createDispatch(new QName("http://fernandoribeiro.eti.br/sample/jaxws", "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:

WordPress.com Logo

You are commenting using your WordPress.com 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