问题描述
我已经使用axis2 java2wsdl实用工具从Java类中生成了WSDL,如下所示:
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
然后,我已在axis2的Application Server(例如jBoss)中部署了相同的Web服务,并且可以在http://127.0.0.1:8080/axis2/services/CustomerServiceWS?wsdl上浏览wsdl并在上调用方法通过标准客户端(如SoapUI等)提供此服务.
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.
现在的问题是,当我使用标准Java工具' wsimport '通过将WSDL位置提供为 C:\ temp (从java2wsdl实用程序生成WSDL)生成客户端时, ),则我的客户端无法与Deployed Web Service通信.我正在使用以下代码访问Web服务;
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?
谢谢
-
Junejo
推荐答案
查看WSDL文件的描述,并检查targetNamespace以获取QName()中提供的URL.还要导入必要的程序包.
See the description of WSDL file and check the targetNamespace for the url to be given in QName(). Also import necessary packages.
这篇关于wsdl生成的Web Service客户端无法与已部署的Web Service一起使用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!