我使用axis2 java2wsdl实用程序从java类生成了一个WSDL,如下所示;
java2wsdl -o C:\temp -cn com.temenos.webservices.customer.CustomerServiceWS
然后我在axis2的应用服务器(比如jBoss)中部署了相同的Web服务,我可以在http://127.0.0.1:8080/axis2/services/CustomerServiceWS?wsdl上浏览wsdl并通过调用该服务的方法标准客户端,如 SoapUI 等。
现在的问题是,当我使用标准 java 工具“ wsimport ”通过将 WSDL 位置提供为C:\temp(从 java2wsdl 实用程序生成的 WSDL)生成客户端时,我的客户端无法与已部署的 Web 服务通信。我正在使用以下代码访问 Web 服务;
// 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;
}
但是在创建(服务端口)端点时,我遇到了以下错误;
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)
我尝试了很多东西,但它似乎不喜欢任何东西。我错过了什么吗?
谢谢,
--
SJunejo