首页 文章

wsdl生成的Web服务客户端不使用已部署的Web服务

提问于
浏览
1

我使用axis2 java2wsdl实用程序从java类生成了一个WSDL,如下所示;

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等标准客户端

问题是,当我使用标准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;
}

但是在创建(服务端口) endpoints 时,我遇到了以下错误;

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

2 回答

  • 0

    问题是我在lib路径中有axis2,因为调用发生在org.apache.axis2.jaxws.spi.Provider.createServiceDelegate(Axi2 Provider)而不是Java WS Provider . 我从classpath中删除了axis2 libs,它现在似乎正常工作 . (虽然我仍然无法通过客户端调用我的Web服务)

  • 0

    请参阅WSDL文件的描述并检查targetNamespace以获取在QName()中给出的url . 还导入必要的包 .

相关问题