5

我使用 CXF 开发了一个代码优先的 SOAP Web 服务,这是我得到的一个 WSDL。为什么要在 WSDL 上导入

第二行是兴趣之一:

我猜也许它与命名空间有关?我想知道发布 Web 服务 impl 的代码是否有帮助?

<wsdl:import location="http://localhost:8080/abc/RaceCalc?wsdl=RaceCalc.wsdl" namespace="http://service.wrapper.ie/">
</wsdl:import>

从 Web 服务生成的 WSDL:

    <?xml version='1.0' encoding='UTF-8'?><wsdl:definitions name="RaceCalcImplService" targetNamespace="http://impl.service.wrapper.ie/" xmlns:ns1="http://service.wrapper.ie/" xmlns:ns2="http://cxf.apache.org/bindings/xformat" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.service.wrapper.ie/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <wsdl:import location="http://localhost:8080/abc/RaceCalc?wsdl=RaceCalc.wsdl" namespace="http://service.wrapper.ie/">
    </wsdl:import>
<wsdl:binding name="RaceCalcImplServiceSoapBinding" type="ns1:RaceCalc">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="setRaceCalcHelper">
  <soap:operation soapAction="" style="document" />
  <wsdl:input name="setRaceCalcHelper">
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output name="setRaceCalcHelperResponse">
    <soap:body use="literal" />
  </wsdl:output>
</wsdl:operation>
<wsdl:operation name="calculate">
  <soap:operation soapAction="" style="document" />
  <wsdl:input name="calculate">
    <soap:body use="literal" />
  </wsdl:input>
  <wsdl:output name="calculateResponse">
    <soap:body use="literal" />
  </wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="RaceCalcImplService">
<wsdl:port binding="tns:RaceCalcImplServiceSoapBinding" name="RaceCalcImplPort">
  <soap:address location="http://localhost:8080/abc/RaceCalc" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
4

1 回答 1

4

因为您的实现中有两个不同的命名空间:{ http://service.wrapper.ie/ } 和 {http:// impl .service.wrapper.ie/}。你肯定有包中的接口ie.wrapper.serviceie.wrapper.service.impl. 因此,CXF 假设名称空间 { http://service.wrapper.ie/ } 用于逻辑内容(interface/portType),名称空间 { http://impl.service.wrapper.ie/ } 用于物理内容(impl /服务/绑定)。将@WebService(targetNamespace = "http://whatever.you.want")注释添加到接口和实现应该删除 WSDL 中的(需要)导入。

于 2015-09-23T09:46:32.407 回答