Wsdl-example

提供:Dev Guides
移動先:案内検索

WSDL-例

以下に示すのは、単純なWSDLプログラムを示すために提供されるWSDLファイルです。

サービスが_sayHello_と呼ばれる単一の公的に利用可能な関数を提供すると仮定しましょう。 この関数は、単一の文字列パラメーターを想定し、単一の文字列グリーティングを返します。 たとえば、パラメータ_world_を渡すと、サービス関数_sayHello_は「Hello、world!」という挨拶を返します。

HelloService.wsdlファイルの内容-

<definitions name = "HelloService"
   targetNamespace = "http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns = "http://schemas.xmlsoap.org/wsdl/"
   xmlns:soap = "http://schemas.xmlsoap.org/wsdl/soap/"
   xmlns:tns = "http://www.examples.com/wsdl/HelloService.wsdl"
   xmlns:xsd = "http://www.w3.org/2001/XMLSchema">

   <message name = "SayHelloRequest">
      <part name = "firstName" type = "xsd:string"/>
   </message>

   <message name = "SayHelloResponse">
      <part name = "greeting" type = "xsd:string"/>
   </message>

   <portType name = "Hello_PortType">
      <operation name = "sayHello">
         <input message = "tns:SayHelloRequest"/>
         <output message = "tns:SayHelloResponse"/>
      </operation>
   </portType>

   <binding name = "Hello_Binding" type = "tns:Hello_PortType">
      <soap:binding style = "rpc"
         transport = "http://schemas.xmlsoap.org/soap/http"/>
      <operation name = "sayHello">
         <soap:operation soapAction = "sayHello"/>
         <input>
            <soap:body
               encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
               namespace = "urn:examples:helloservice"
               use = "encoded"/>
         </input>

         <output>
            <soap:body
               encodingStyle = "http://schemas.xmlsoap.org/soap/encoding/"
               namespace = "urn:examples:helloservice"
               use = "encoded"/>
         </output>
      </operation>
   </binding>

   <service name = "Hello_Service">
      <documentation>WSDL File for HelloService</documentation>
      <port binding = "tns:Hello_Binding" name = "Hello_Port">
         <soap:address
            location = "http://www.examples.com/SayHello/"/>
      </port>
   </service>
</definitions>

分析例

  • 定義-HelloService
  • Type -組み込みデータ型を使用し、XMLSchemaで定義されています。
  • メッセージ-
  • sayHelloRequest-firstNameパラメーター
  • sayHelloresponse-挨拶の戻り値
  • ポートタイプ-要求と応答サービスで構成されるsayHello操作。
  • Binding -SOAP HTTPトランスポートプロトコルを使用する方向。
  • サービス-http://www.examples.com/SayHello/で利用可能なサービス
  • ポート-実行中のサービスにアクセスできるURI [[1]]