You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何从WSDL判断Web Service编码类型及服务类型(Document/literal等)?

How to Determine Web Service Encoding & Style from WSDL

Absolutely, you can figure out both the encoding type and the specific Web Service style (like Document/literal, RPC/encoded, etc.) straight from a WSDL file. Let me walk you through the exact indicators and steps to check—this is a routine task when working with SOAP services.

1. Start with the <binding> Element (Your Primary Clue)

The biggest hints live in the <binding> section of the WSDL. Focus on the <soap:binding> tag and the <soap:body> tags inside each <operation>—they have two critical attributes:

  • style: Tells you if the service uses RPC or Document style
  • use: Indicates if it uses encoded or literal encoding

Here’s a quick example of what this looks like in context:

<binding name="UserServiceBinding" type="tns:UserServicePortType">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
  <operation name="GetUser">
    <soap:operation soapAction="http://example.com/GetUser"/>
    <input>
      <soap:body use="literal" namespace="http://example.com"/>
    </input>
    <output>
      <soap:body use="literal" namespace="http://example.com"/>
    </output>
  </operation>
</binding>

In this case, we’re looking at a Document/literal service.

2. Distinguish RPC vs. Document Style

Let’s break down what each style value means, and how to confirm it with other parts of the WSDL:

RPC Style (style="rpc")

Think of RPC style like calling a remote function: the SOAP body structures data like method arguments, with each parameter as a separate entry.

  • In the WSDL’s <message> definitions, <part> elements will reference simple types (like xsd:string) or named complex types directly—no wrapping XML element.
  • Example RPC message:
    <message name="GetUserRequest">
      <part name="userId" type="xsd:int"/>
      <part name="includeMetadata" type="xsd:boolean"/>
    </message>
    

Document Style (style="document")

Document style means the SOAP body contains a well-formed XML document that matches an explicit schema definition.

  • In <message> definitions, <part> elements will reference a top-level <element> from the WSDL’s <types> section (not just a type).
  • Example Document message:
    <message name="GetUserRequest">
      <part name="request" element="tns:GetUserRequestElement"/>
    </message>
    <!-- In the <types> section, you'd have: -->
    <xs:element name="GetUserRequestElement">
      <xs:complexType>
        <xs:sequence>
          <xs:element name="userId" type="xs:int"/>
          <xs:element name="includeMetadata" type="xs:boolean"/>
        </xs:sequence>
      </xs:complexType>
    </xs:element>
    

Note: If the style attribute is omitted from <soap:binding>, it defaults to document for SOAP 1.1.

3. Identify Encoded vs. Literal Encoding

Next, use the use attribute (and related tags) to spot the encoding type:

Literal Encoding (use="literal")

Literal is the most common encoding today. It means the SOAP message strictly follows the exact schema defined in the WSDL’s <types> section—no extra type information is included in the message itself. It’s just plain XML that matches the schema structure.

Encoded Encoding (use="encoded")

Encoded refers to SOAP Section 5 encoding, where the message includes explicit type information (like xsi:type attributes) to describe data types. You’ll also see the encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" attribute on the <soap:body> tag to confirm this.

  • Example encoded body:
    <input>
      <soap:body use="encoded" encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://example.com"/>
    </input>
    

4. Putting It All Together: The Four Common Styles

Here’s how to map the attribute combinations to the four standard service types:

  • RPC/literal: <soap:binding style="rpc"> + <soap:body use="literal">
  • RPC/encoded: <soap:binding style="rpc"> + <soap:body use="encoded" with encodingStyle
  • Document/literal: <soap:binding style="document"> + <soap:body use="literal">
  • Document/encoded: <soap:binding style="document"> + <soap:body use="encoded" with encodingStyle (this is rare in modern services)

A quick tip: Always cross-check the <message> parts with the binding attributes—they’ll reinforce which style/encoding you’re dealing with. For example, RPC messages will have multiple parts referencing types, while Document messages will have a single part referencing an element.

内容的提问来源于stack exchange,提问作者user93353

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.21 03:46:41