【问题标题】:Why my SOAP Client ignores port of the WSDL location?为什么我的 SOAP 客户端忽略 WSDL 位置的端口?
【发布时间】:2020-04-12 22:03:19
【问题描述】:

我正在尝试使用 WSDL_LOCATION 为 Web 服务生成客户端:http://localhost:8089/SWIStoZZZws/SWIStoZZZws.asmx?WSDL

我使用的是 Apache CXF 2.6.2。机器。

但是,客户端以某种方式忽略了端口 8089 并将 HTTP 请求发送到 http://localhost/SWIStoZZZws/SWIStoZZZws.asmx?WSDL,结果出现以下错误:

Caused by: org.apache.cxf.transport.http.HTTPException: HTTP response '404: Not Found' when communicating with http://localhost/SWIStoZZZws/SWIStoZZZws.asmx
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponseInternal(HTTPConduit.java:1619)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.handleResponse(HTTPConduit.java:1530)
    at org.apache.cxf.transport.http.HTTPConduit$WrappedOutputStream.close(HTTPConduit.java:1438)
    at org.apache.cxf.transport.AbstractConduit.close(AbstractConduit.java:56)
    at org.apache.cxf.transport.http.HTTPConduit.close(HTTPConduit.java:660)
    at org.apache.cxf.interceptor.MessageSenderInterceptor$MessageSenderEndingInterceptor.handleMessage(MessageSenderInterceptor.java:62)
    ... 54 more

有什么想法吗?请帮忙......我一直在为此苦苦挣扎。干杯!

【问题讨论】:

  • 您好,您是否尝试过这些解决方案:stackoverflow.com/a/5953252/390462。另一个想法:也许您可以在第一步之后下载 wsdl 并生成您的类实现。

标签: java soap wsdl cxf


【解决方案1】:

您可以关注official documentation,您将在其中找到该代码:

<beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:jaxws="http://cxf.apache.org/jaxws"
     xsi:schemaLocation="
     http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
     http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd">

     <jaxws:endpoint id="classImpl"
          implementor="org.apache.cxf.jaxws.service.Hello"
          endpointName="e:HelloEndpointCustomized"
          serviceName="s:HelloServiceCustomized"
          address="http://localhost:8080/test"
          xmlns:e="http://service.jaxws.cxf.apache.org/endpoint"
          xmlns:s="http://service.jaxws.cxf.apache.org/service" />

 </beans>

【讨论】:

  • 在我的情况下这不是一个可能的解决方案,因为我使用调用其他服务的代理 Web 服务,所以在 bean 中我应该只配置代理服务。谢谢。
【解决方案2】:

你如何获得端点地址?也许您从 IDE 中自动生成的文件中获取端点地址

【讨论】:

  • 我有几种方法来获取端点地址:首先我尝试直接从数据库中获取它,我在其中保留 Web 服务的地址并使用代理服务调用它们。比我尝试使用自动生成的访问,最后我写了一个以下 URL:URL wsdlURL1=new URL ("http://localhost:8089/SWIStoZZZws/SWIStoZZZws.asmx?WSDL"); SWIStoZZZws ss = new SWIStoZZZws(wsdlURL1, SERVICE_NAME); 这可以工作并创建 Web 服务,所以现在我得到 Could not send Message. 错误。我想我会发疯的。呵呵
  • 前段时间,当我更改 WSDL 地址时(例如在此示例中 link 我没有更改默认输出错误(例如无法从 localhost/SWIStoZZZws/SWIStoZZZws.asmx 初始化默认 wsdl)。这很重要,因为也许您在正确的 URL 上发送请求,但默认 URL 出错
  • 已解决!嘿,人们,只是想通了。问题在于地址绑定,所以,为了在运行时更改地址,我在端口定义后添加了如下代码:String endpointURL = "http://localhost:8089/SWIStoZZZws/SWIStoZZZws.asmx?WSDL"; BindingProvider bp = (BindingProvider)port; bp.getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpointURL); 此处解释为link 谢谢大家...
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2014-12-30
  • 2016-02-16
  • 1970-01-01
  • 2010-12-01
  • 1970-01-01
  • 2013-08-20
  • 1970-01-01
相关资源
最近更新 更多