【问题标题】:CXF incorrect WSDL automatically generated?CXF 不正确 WSDL 自动生成?
【发布时间】:2015-12-04 00:00:48
【问题描述】:

过去两天我一直在与同样的问题作斗争,但我不知道如何解决这个问题。甚至不确定这是否是错误。

我有一个我认为很奇怪的 CXF Web 服务,我想修复它。这是 Web 服务处理的调用之一:

@WebResult (name="merchantHierarchyParentResponse") MerchantHierarchyParentResponseDTO
getParent(
        @WebParam(name="institutionNumber") @XmlElement(required=true) String institutionNumber,
        @WebParam(name="clientNumber") String clientNumber,
        @WebParam(name="ourReference") String ourReference,
        @WebParam(name="accessMerch") String accessMerch,
        @WebParam(header=true, name="callerId") String callerId,
        @WebParam(header=true, name="timestamp") String timestamp,
        @WebParam(header=true, name="signature") String signature
);

如你所见,它在头部接收 4 个普通参数加上 3 个额外参数(callerId、timestamp 和 signature)。

编译成功。然后我也成功地将它部署在 WebLogic 服务器中。

最后,我使用 SoapUI 对其进行测试。我为 SoapUI 提供了 WebLogic 为我提供 WSDL 的 URL。也就是说,我没有对自动生成的 WSDL 进行任何更改。这就是我在 SoupUI 中为 getParent 得到的:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://webService.webservice.omnipay.com.server/">
   <soapenv:Header>
      <web:signature>?</web:signature>
      <web:timestamp>?</web:timestamp>
      <web:callerId>?</web:callerId>
   </soapenv:Header>
   <soapenv:Body>
      <web:getParent>
         <institutionNumber>?</institutionNumber>
         <!--Optional:-->
         <clientNumber>?</clientNumber>
         <!--Optional:-->
         <ourReference>?</ourReference>
         <!--Optional:-->
         <accessMerch>?</accessMerch>
      </web:getParent>
      <web:callerId>?</web:callerId>
      <web:timestamp>?</web:timestamp>
      <web:signature>?</web:signature>
   </soapenv:Body>
</soapenv:Envelope>

我的问题很清楚。我在标题部分看到了 3 个参数(callerId、时间戳和签名),但为什么这 3 个参数在正文部分的末尾又出现了。我不希望它们出现在正文部分,我只希望它们出现在标题中。

知道为什么会这样吗?是bug吗?

【问题讨论】:

  • 请将您的评论复制到此问题的答案中,如果解决了问题,请批准它。因此,该问题不会在系统中显示未回答的广告。

标签: header wsdl cxf


【解决方案1】:

您好,感谢帮助我解决问题的人。

这里是 wsdl:binding 中与 getParent 调用相关的部分:

<wsdl:binding name="ServiceImplServiceSoapBinding" type="tns:IService">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
    <wsdl:operation name="getParent">
        <soap:operation soapAction="" style="document"/>
        <wsdl:input name="getParent">
            <soap:header encodingStyle="" message="tns:getParent" part="callerId" use="literal"/>
            <soap:header encodingStyle="" message="tns:getParent" part="timestamp" use="literal"/>
            <soap:header encodingStyle="" message="tns:getParent" part="signature" use="literal"/>
            <soap:body use="literal"/>
        </wsdl:input>
        <wsdl:output name="getParentResponse">
            <soap:body use="literal"/>
        </wsdl:output>
</wsdl:operation>

我不得不改变部分,这一行

<soap:body use="literal"/>

为了这个

<soap:body use="literal" parts="parameters"/>

不太清楚为什么我的自动生成的 WSDL 中没有生成这个部件属性,但是,它解决了我的问题。我不喜欢在 wsdl 中进行手动更改。无论如何,至少我的问题是固定的。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-02-08
    • 1970-01-01
    • 2021-05-03
    • 2011-10-13
    相关资源
    最近更新 更多