共用方式為


SOAP 標頭與已使用的 Web 服務

使用 [ 新增 Web 參考 ] 對話方塊將 Web 服務新增至協調流程之後,您可以使用 Web 服務描述語言 (WSDL) 在 Web 服務中定義的 SOAP 標頭。

注意

已使用的 Web 服務不支援未知的 SOAP 標頭。

已取用 Web 服務的 WSDL 會列出繫結項目中定義的 SOAP 標頭。 下列範例顯示已取用 Web 服務 WSDL 檔案中的繫結項目:

<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:s0="http://SOAPHeaderWS.ItemAvailability" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetNamespace="http://SOAPHeaderWS.ItemAvailability" xmlns="http://schemas.xmlsoap.org/wsdl/">
       <types>
             <s:schema elementFormDefault="qualified" targetNamespace="http://SOAPHeaderWS.ItemAvailability">

                    <s:element name="OrigDest" type="s0:OrigDest"/>
                    <s:complexType name="OrigDest">
                           <s:sequence>
                                 <s:element minOccurs="0" maxOccurs="1" name="Origination" type="s:string"/>
                                 <s:element minOccurs="0" maxOccurs="1" name="Destination" type="s:string"/>
                           </s:sequence>
                    </s:complexType>
             </s:schema>
       </types>

       <binding name="ItemAvailabilityServiceSoap" type="s0:ItemAvailabilityServiceSoap">
             <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
             <operation name="ItemAvailability">
                    <soap:operation soapAction="http://SOAPHeaderWS.ItemAvailability/ItemAvailability" style="document"/>
                    <input>
                           <soap:body use="literal"/>
                           <soap:header message="s0:ItemAvailabilityOrigDest" part="OrigDest" use="literal"/>
                    </input>
                    <output>
                           <soap:body use="literal"/>
                           <soap:header message="s0:ItemAvailabilityOrigDest" part="OrigDest" use="literal"/>
                    </output>
             </operation>
       </binding>
       <service name="ItemAvailabilityService">
             <port name="ItemAvailabilityServiceSoap" binding="s0:ItemAvailabilityServiceSoap">
                    <soap:address location="http://localhost/SOAPHeaderWS/ItemAvailability.asmx"/>
             </port>
       </service>
</definitions>

For more information about using SOAP headers, see "Using SOAP Headers" in .NET Framework documentation at https://go.microsoft.com/fwlink/?LinkId=62266.

本節內容