Wednesday, June 22, 2011

Specify username, password and timeout in jboss webservice client

Specify the username, password and timeout ,in a jboss web service client.


In your generated client class , getting Soap instance method ,
eg:


public TESTGenericDataAccessSoap getTESTGenericDataAccessSoap(){
{
TESTGenericDataAccessSoap soap = super.getPort(TESTGenericDataAccessSoap , TESTGenericDataAccessSoap .class);
        BindingProvider bp = (BindingProvider)soap;
         Stub stub = (Stub)soap;
         stub._setProperty(StubExt.PROPERTY_CLIENT_TIMEOUT, 10); //Time out
        bp.getRequestContext().put(BindingProvider.USERNAME_PROPERTY, "jijo");//Username
        bp.getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, "jijo");//Password
        return soap;
}

The import classes are given,

import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.rpc.Stub;
import javax.xml.ws.BindingProvider;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
import javax.xml.ws.Service;
import org.jboss.ws.core.StubExt;

1 comment:

Anonymous said...

thanks for the interesting information