如何基于 WSDL 文件构建 SOAP 标头命名空间

发布于 2024-11-17 14:32:07 字数 3859 浏览 1 评论 0原文

我在 SOAP 请求的标头表示中遇到了一些问题。我想我错过了一些东西。

我的(部分)wsdl 看起来像这样:

<wsdl:definitions   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
                    xmlns:aws="http://xml.xxx.com"
                    xmlns:security_authenticate_6_1="http://xml.xxx.com/VLSSLQ_06_1_1A" 
                    xmlns:security_authenticatereply_6_1="http://xml.xxx.com/VLSSLR_06_1_1A"
                    targetNamespace="http://xml.xxx.com">  
  <wsdl:types>
    <xsd:schema targetNamespace="http://xml.xxx.com">
      <xsd:import namespace="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd" schemaLocation="WBS_Session-2.0.xsd"/>      
      <xsd:import namespace="http://xml.xxx.com/VLSSLQ_06_1_1A" schemaLocation="Security_Authenticate_06_1_1A.xsd"/>
      <xsd:import namespace="http://xml.xxx.com/VLSSLR_06_1_1A" schemaLocation="Security_AuthenticateReply_06_1_1A.xsd"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="Session" xmlns:ns0="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd">
    <wsdl:part name="Session" element="ns0:Session"/>
  </wsdl:message>  
  <wsdl:message name="Security_Authenticate_6_1">
    <wsdl:part name="Security_Authenticate_6_1" element="security_authenticate_6_1:Security_Authenticate"/>
  </wsdl:message>
  <wsdl:message name="Security_AuthenticateReply_6_1">
    <wsdl:part name="Security_AuthenticateReply_6_1" element="security_authenticatereply_6_1:Security_AuthenticateReply"/>
  </wsdl:message>
  <wsdl:portType name="XXXWebServicesPT">    
    <wsdl:operation name="Security_Authenticate">
      <wsdl:input message="aws:Security_Authenticate_6_1"/>
      <wsdl:output message="aws:Security_AuthenticateReply_6_1"/>
    </wsdl:operation>    
  </wsdl:portType>
  <wsdl:binding name="XXXWebServicesBinding" type="aws:XXXWebServicesPT">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>    
    <wsdl:operation name="Security_Authenticate">
      <soap:operation soapAction="http://webservices.xxx.com/1ASIWJTUTUA/VLSSLQ_06_1_1A"/>
      <wsdl:input>
        <soap:header message="aws:Session" part="Session" use="literal"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:header message="aws:Session" part="Session" use="literal"/>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="XXXWebServices">
    <wsdl:port name="XXXWebServicesPort" binding="aws:XXXWebServicesBinding">
      <soap:address location="https://test.webservices.xxx.com"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

我想访问 Security_Authenticate 操作,在这种情况下,标头必须看起来像这样:

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
    <soapenv:Header>
      <wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'>
        <wbs:SessionId></wbs:SessionId>
        <wbs:SequenceNumber></wbs:SequenceNumber>
        <wbs:SecurityToken></wbs:SecurityToken>
      </wbs:Session>
    </soapenv:Header>
    <soapenv:Body>
      <vls:Security_Authenticate>
        <vls:tagX>
          <vls:tagY>yyy</vls:tagY>
          <vls:tagZ>Z</vls:tagZ>
        </vls:tagX>
      </vls:Security_Authenticate>
    </soapenv:Body>
</soapenv:Envelope>

我应该如何构建我的肥皂信封和标头命名空间?

谢谢。

I've been experiencing some issues with the header presentation of a SOAP Request. I think I'm missing something.

My (partial) wsdl looks like this:

<wsdl:definitions   xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" 
                    xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
                    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" 
                    xmlns:aws="http://xml.xxx.com"
                    xmlns:security_authenticate_6_1="http://xml.xxx.com/VLSSLQ_06_1_1A" 
                    xmlns:security_authenticatereply_6_1="http://xml.xxx.com/VLSSLR_06_1_1A"
                    targetNamespace="http://xml.xxx.com">  
  <wsdl:types>
    <xsd:schema targetNamespace="http://xml.xxx.com">
      <xsd:import namespace="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd" schemaLocation="WBS_Session-2.0.xsd"/>      
      <xsd:import namespace="http://xml.xxx.com/VLSSLQ_06_1_1A" schemaLocation="Security_Authenticate_06_1_1A.xsd"/>
      <xsd:import namespace="http://xml.xxx.com/VLSSLR_06_1_1A" schemaLocation="Security_AuthenticateReply_06_1_1A.xsd"/>
    </xsd:schema>
  </wsdl:types>
  <wsdl:message name="Session" xmlns:ns0="http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd">
    <wsdl:part name="Session" element="ns0:Session"/>
  </wsdl:message>  
  <wsdl:message name="Security_Authenticate_6_1">
    <wsdl:part name="Security_Authenticate_6_1" element="security_authenticate_6_1:Security_Authenticate"/>
  </wsdl:message>
  <wsdl:message name="Security_AuthenticateReply_6_1">
    <wsdl:part name="Security_AuthenticateReply_6_1" element="security_authenticatereply_6_1:Security_AuthenticateReply"/>
  </wsdl:message>
  <wsdl:portType name="XXXWebServicesPT">    
    <wsdl:operation name="Security_Authenticate">
      <wsdl:input message="aws:Security_Authenticate_6_1"/>
      <wsdl:output message="aws:Security_AuthenticateReply_6_1"/>
    </wsdl:operation>    
  </wsdl:portType>
  <wsdl:binding name="XXXWebServicesBinding" type="aws:XXXWebServicesPT">
    <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>    
    <wsdl:operation name="Security_Authenticate">
      <soap:operation soapAction="http://webservices.xxx.com/1ASIWJTUTUA/VLSSLQ_06_1_1A"/>
      <wsdl:input>
        <soap:header message="aws:Session" part="Session" use="literal"/>
        <soap:body use="literal"/>
      </wsdl:input>
      <wsdl:output>
        <soap:header message="aws:Session" part="Session" use="literal"/>
        <soap:body use="literal"/>
      </wsdl:output>
    </wsdl:operation>
  </wsdl:binding>
  <wsdl:service name="XXXWebServices">
    <wsdl:port name="XXXWebServicesPort" binding="aws:XXXWebServicesBinding">
      <soap:address location="https://test.webservices.xxx.com"/>
    </wsdl:port>
  </wsdl:service>
</wsdl:definitions>

I want to access the Security_Authenticate action, in which case, the header must look something like:

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
    <soapenv:Header>
      <wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'>
        <wbs:SessionId></wbs:SessionId>
        <wbs:SequenceNumber></wbs:SequenceNumber>
        <wbs:SecurityToken></wbs:SecurityToken>
      </wbs:Session>
    </soapenv:Header>
    <soapenv:Body>
      <vls:Security_Authenticate>
        <vls:tagX>
          <vls:tagY>yyy</vls:tagY>
          <vls:tagZ>Z</vls:tagZ>
        </vls:tagX>
      </vls:Security_Authenticate>
    </soapenv:Body>
</soapenv:Envelope>

How should I built my soapenvelope and my header namespaces?

Thanks.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

南巷近海 2024-11-24 14:32:07

在使用 xsd 中的对象之前,您必须声明名称空间,因此在您的情况下,要使用 Session 对象:

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
  <soapenv:Header>
    <wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'>
      <wbs:SessionId></wbs:SessionId>
      <wbs:SequenceNumber></wbs:SequenceNumber>
      <wbs:SecurityToken></wbs:SecurityToken>
    </wbs:Session>
  </soapenv:Header>
  ...

You have to declare the namespace before you use the object in the xsd, so in your case, to use the Session object:

<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/'>
  <soapenv:Header>
    <wbs:Session xmlns:wbs='http://xml.xxx.com/ws/2009/01/WBS_Session-2.0.xsd'>
      <wbs:SessionId></wbs:SessionId>
      <wbs:SequenceNumber></wbs:SequenceNumber>
      <wbs:SecurityToken></wbs:SecurityToken>
    </wbs:Session>
  </soapenv:Header>
  ...
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文