CXF自身会自动生成WSDL导入吗? [英] CXF autogenerates WSDL imports itself?

查看:55
本文介绍了CXF自身会自动生成WSDL导入吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I develop a code first SOAP web service with CXF, and this a WSDL which I get. Why is there a import on WSDL

第二行是其中之一:

我猜想这可能与名称空间有关?我想知道发布Web服务impl的代码是否会有所帮助?

I am guessing that maybe it has something to do with namespaces ? I wonder if publishing the code of the web service impl will help ?

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

从Web服务生成的WSDL:

WSDL generated from Web Service:

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

推荐答案

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

Because you have two different namespaces on your implementation: {http://service.wrapper.ie/} and {http://impl.service.wrapper.ie/}. You surely have the interface in package ie.wrapper.service and the implementation in ie.wrapper.service.impl. CXF is therefore assuming the namespace {http://service.wrapper.ie/} for the logical stuff (interface/portType) and the namespace {http://impl.service.wrapper.ie/} for the physical stuff (impl/service/binding). Adding the @WebService(targetNamespace = "http://whatever.you.want") annotation to both, interface and implementation should remove the (need of an) import in the WSDL.

这篇关于CXF自身会自动生成WSDL导入吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆