【问题标题】:Web Service client generated by wsdl not working with Deployed web servicewsdl 生成的 Web 服务客户端无法与已部署的 Web 服务一起使用
【发布时间】:2012-06-21 14:00:04
【问题描述】:

我已经使用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 服务进行通信。我正在使用以下代码访问网络服务;

// 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

【问题讨论】:

  • 我想我问了一些没人遇到过的问题...

标签: wsdl axis2 ws-client


【解决方案1】:

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

【讨论】:

    【解决方案2】:

    查看 WSDL 文件的描述并检查 targetNamespace 中要在 QName() 中给出的 url。同时导入必要的包。

    【讨论】:

      猜你喜欢
      • 2015-09-09
      • 2013-01-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-03-19
      • 2018-07-03
      • 2011-05-09
      • 1970-01-01
      相关资源
      最近更新 更多