Web Service client generated by wsdl not working with Deployed web service

axis2ws-clientwsdl

I have generated a WSDL from a java class using axis2 java2wsdl utility as follows;

java2wsdl -o C:\temp -cn com.temenos.webservices.customer.CustomerServiceWS

Then I have deployed the same web service within an Application Server (say jBoss) in axis2 and I can browse the wsdl on http:// 127.0.0.1:8080/axis2/services/CustomerServiceWS?wsdl and call the methods on this service via standard client like SoapUI etc.

The problem is now that when I generated a client using standard java tooling 'wsimport' by providing a WSDL location as C:\temp (Generated WSDL from java2wsdl utility), my client is unable to communicate with the Deployed Web Service. I am using following code to access the web service;

// Initialise WS
CustomerServiceWS service = null;
CustomerServiceWSPortType servicePort = null;
try {
URL wsdlLocation  = new URL("http://127.0.0.1:8080/axis2/services/CustomerServiceWS?wsdl");  
QName serviceName = new QName("http://customer.webservices.temenos.com", "CustomerServiceWS");
service = new CustomerServiceWS(wsdlLocation, serviceName);
servicePort = service.getCustomerServiceWSHttpSoap12Endpoint();
} catch (MalformedURLException murle) {
murle.printStackTrace();
    return;
}

But while creating an (service Port) Endpoint I am getting following error;

Exception in thread "main" javax.xml.ws.WebServiceException: An attempt was made to construct the ServiceDelegate object with an service name that is not valid: {http://customer.webservices.temenos.com}CustomerServiceWS.
    at org.apache.axis2.jaxws.ExceptionFactory.createWebServiceException(ExceptionFactory.java:173)
    at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:70)
    at org.apache.axis2.jaxws.ExceptionFactory.makeWebServiceException(ExceptionFactory.java:118)
    at org.apache.axis2.jaxws.spi.ServiceDelegate.<init>(ServiceDelegate.java:218)
    at org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Provider.java:59)
    at javax.xml.ws.Service.<init>(Service.java:56)
    at com.temenos.webservices.customer.CustomerServiceWS.<init>(CustomerServiceWS.java:42)
    at com.temenos.services.customer.client.Client.testGetLanguage(Client.java:32)
    at com.temenos.services.customer.client.Client.main(Client.java:21)

I have tried many things but it does not seems to like anything. Am I missing anything?

Thanks,

SJunejo

Best Answer

The problem was that I had axis2 in lib path because of that the call happend to org.apache.axis2.jaxws.spi.Provider.createServiceDelegate (Axi2 Provider) instead of Java WS Provider. I removed the axis2 libs from classpath and it seems to be working ok now. (though I am still unable to call my web service via client)

Related Topic