Posted by: bgopi | December 3, 2011

add soap header to web service client – simple and elegant way

MyWebService  serviceToUse = new MyWebService();

Object stub = serviceToUse.getPort(new QName(“http://www.xxx.com/xx/service/schema/xx/interface/v1″,”web-port”), WebPort.class);

WSBindingProvider bp = (WSBindingProvider)stub;
HeaderHandlerResolver handlerResolver = new HeaderHandlerResolver();
serviceToUse.setHandlerResolver(handlerResolver);

myService = serviceToUse.getWebPort();

//call your web method here

myService.yourWebMethod(request);

For HeaderHandlerResolver and HeaderHandler please refer below:

http://www.java.net/external?url=http://javadb.com/using-a-message-handler-to-alter-the-soap-header-in-a-web-service-client

Advertisements

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

Categories

%d bloggers like this: