我使用CXF开发代码第一个SOAP Web服务,这是我得到的WSDL。为什么在WSDL上有导入
第二行是感兴趣的:
我猜这可能与命名空间有关?我想知道发布网络服务impl的代码是否有帮助?
<wsdl:import location="http://localhost:8080/abc/RaceCalc?wsdl=RaceCalc.wsdl" namespace="http://service.wrapper.ie/">
</wsdl:import>
从Web Service生成的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>
答案 0 :(得分:3)
因为您的实施中有两个不同的命名空间:{http://service.wrapper.ie/}和{http:// impl .service.wrapper.ie /}。你肯定有包ie.wrapper.service
中的接口和ie.wrapper.service.impl
中的实现。因此,CXF假设逻辑内容(interface / portType)的名称空间{http://service.wrapper.ie/}和物理内容(impl / service / binding)的名称空间{http://impl.service.wrapper.ie/}。将@WebService(targetNamespace = "http://whatever.you.want")
注释添加到接口和实现都应该删除WSDL中的(需要)导入。