美文网首页
第十一章 SOAP 消息变体 - 消息变体的例子

第十一章 SOAP 消息变体 - 消息变体的例子

作者: Cache技术分享 | 来源:发表于2024-05-29 07:51 被阅读0次

    第十一章 SOAP 消息变体 - 消息变体的例子

    消息变体的例子

    作为参考,本节展示了不同模式下的消息示例(不建议使用document/encoded模式)。

    Wrapped Document/Literal

    这是最常见的消息样式(也是 web服务的默认消息样式)。

    <SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/' 
                       xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
                       xmlns:s='https://www.w3.org/2001/XMLSchema'>
      <SOAP-ENV:Body>
        <MyMethod xmlns="https://www.demoservice.org">
            <A>stringA</A>
            <B>stringB</B>
            <C>stringC</C>
        </MyMethod>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    Message/Unwrapped Document/Literal

    这是前一种风格的轻微变化。

    <SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
                       xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
                       xmlns:s='https://www.w3.org/2001/XMLSchema'>
      <SOAP-ENV:Body>
          <A xmlns="https://www.demoservice.org">stringA</A>
          <B xmlns="https://www.demoservice.org">stringB</B>
          <C xmlns="https://www.demoservice.org">stringC</C>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    RPC/Encoded

    这是第二常见的样式。下面显示了SOAP 1.1rpc/编码消息:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
                       xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
                       xmlns:s='https://www.w3.org/2001/XMLSchema'
                       xmlns:SOAP-ENC='https://schemas.xmlsoap.org/soap/encoding/'
                       xmlns:tns='https://www.demoservice.org'
                       xmlns:types='https://www.demoservice.org'>
      <SOAP-ENV:Body SOAP-ENV:encodingStyle='https://schemas.xmlsoap.org/soap/encoding/'>
        <types:MyMethod>
          <A>stringA</A>
          <B>stringB</B>
          <C>stringC</C>
        </types:MyMethod>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    对于SOAP 1.2,编码规则是不同的,因此消息是不同的:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV='https://www.w3.org/2003/05/soap-envelope'
                       xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
                       xmlns:s='https://www.w3.org/2001/XMLSchema'
                       xmlns:SOAP-ENC='https://www.w3.org/2003/05/soap-encoding'
                       xmlns:tns='https://www.demoservice.org'
                       xmlns:types='https://www.demoservice.org'>
      <SOAP-ENV:Body>
        <types:MyMethod SOAP-ENV:encodingStyle="https://www.w3.org/2003/05/soap-encoding">
          <A>stringA</A>
          <B>stringB</B>
          <C>stringC</C>
        </types:MyMethod>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    RPC/Literal

    下面是rpc/literal消息的一个示例:

    <SOAP-ENV:Envelope xmlns:SOAP-ENV='https://schemas.xmlsoap.org/soap/envelope/'
                       xmlns:xsi='https://www.w3.org/2001/XMLSchema-instance'
                       xmlns:s='https://www.w3.org/2001/XMLSchema'
                       xmlns:tns='https://www.demoservice.org'>
      <SOAP-ENV:Body>
        <tns:MyMethod>
          <tns:A>stringA</tns:A>
          <tns:B>stringB</tns:B>
          <tns:C>stringC</tns:C>
        </tns:MyMethod>
      </SOAP-ENV:Body>
    </SOAP-ENV:Envelope>
    

    相关文章

      网友评论

          本文标题:第十一章 SOAP 消息变体 - 消息变体的例子

          本文链接:https://www.haomeiwen.com/subject/zvikqjtx.html