【问题标题】:wsimport with http:binding带有 http:binding 的 wsimport
【发布时间】:2013-02-19 05:36:34
【问题描述】:

我的 wsdl 中有以下绑定和服务元素:

<wsdl:binding name="MyServiceSOAP11Binding" type="impl:MyServicePortType">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
    <wsdl:operation name="getProjects4Me">
        <soap:operation soapAction="getProjects4Me" style="document"/>
        <wsdl:input>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output>
            <soap:body use="literal"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>    

<wsdl:binding name="MyServiceHttpBinding" type="impl:MyServicePortType">
    <http:binding verb="POST"/>
     <wsdl:operation name="getProjects4Me">
        <http:operation location="MyService/getProjects4Me"/>
        <wsdl:input>
            <mime:content type="text/xml" part="getProjects4Me"/>
        </wsdl:input>
        <wsdl:output>
            <mime:content type="text/xml" part="getProjects4Me"/>
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="MyService">
    <wsdl:port name="MyServiceSOAP11port_http" binding="impl:MyServiceSOAP11Binding">
        <soap:address location="http://shop.my.com:80//services/MyService"/>
    </wsdl:port>
    <wsdl:port name="MyServiceHttpport" binding="impl:MyServiceHttpBinding">
        <http:address location="http://shop.my.com:80/services/MyService"/>
    </wsdl:port>
</wsdl:service>

当我在上述 wsdl 上使用 wsimport 时,它会为“MyServiceSOAP11port_http”生成代码,但不会为“MyServiceHttpport”生成代码。我错过了什么吗?

我的 wsimport ANT 任务:

  <target name="wsimport">
    <exec executable="${jdk.home}/bin/wsimport">
      <arg line="-keep -s ../wsimportsrc -p com.sample -verbose
        -d ../wsimportclasses ../wsdl_xsd/MyService.xml"/>
    </exec>
  </target>

【问题讨论】:

    标签: java wsdl wsimport


    【解决方案1】:

    它确实会生成。你能检查 *_Service.java 文件吗?它们都共享相同的 QName,但有两个不同的端点。在您的情况下,会有类似

    的代码
     http://www.example.org/NewWSDLFile --> Consider this as Your Name Space
    
    @WebEndpoint(name = "MyServiceSOAP11port_http")
     public NewWSDLFile getNewWSDLFileSOAP1() {
        return super.getPort(new QName("http://www.example.org/NewWSDLFile/", 
       "MyServiceSOAP11port_http"), NewWSDLFile.class);
    }
    

     @WebEndpoint(name = "MyServiceHttpport")
     public NewWSDLFile getNewWSDLFileSOAP(WebServiceFeature... features) {
        return super.getPort(new QName("http://www.example.org/NewWSDLFile/", 
       "MyServiceHttpport"), NewWSDLFile.class, features);
    }
    

    仅仅拥有两个端口并不意味着每个端口类型都有不同的代码库

    【讨论】:

    • MyService.class 中不存在第一个端口类型方法,但对应于绑定类型为 http 的 MyServiceHttpport 的第二个方法不存在。我什至强行创建了一个类似于 SOAP 绑定端口类型方法的新方法,但是在运行客户端时出现以下异常:线程“main”javax.xml.ws.WebServiceException 中的异常:不支持的端点地址:com.sun.xml.internal .ws.api.pipe.TransportTubeFactory.create(Unknown Source)
    • 我没有在 wsimport 中提供任何额外的选项,但它仍然生成了
    • 好的..请保持对应的绑定和端口名相同..应该可以解决您的问题..
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-06-06
    • 2018-10-31
    • 2012-04-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多