RubyでSOAP-RPCサーバを作る1(WSDL作成)
SOAP-RPCサーバをちゃんと作ろうと思ってWSDLを書き始めたのですがこれがまた大変でした。いまひとつ理解が浅いのか例によって動くまでに丸1日がかりでした。そもそも、WSDLって手で書くモノなのでしょうか?インタフェースを入力するとWSDLを吐き出してくれるツールがあっても良さそうなんだけどなあ。さすが、Javaにはツールが揃っていそうでしたが...とりあえず僕はviで。何に苦労したかと言えばnamespaceに尽きます。soap4r付属の、wsdl2rubyでチェックしながら作成したんですが、このnamespaceの理解がいまひとつのため、散々苦労しました。
以下、なんとか書き上がったWSDL全文。少々、長いのでこの記事ではここまで。続きは次回以降書いていくつもりです。(というか、ここまでできると今回やろろうとしている程度の処理なら終わったも同然なんですが...)
<?xml version="1.0" encoding="UTF-8"?>
<definitions name="LovemacService"
targetNamespace="urn:LovemacService"
xmlns:typens="urn:LovemacService"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns="http://schemas.xmlsoap.org/wsdl/">
<types>
<xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" targetNamespace="urn:LovemacService">
<xsd:complexType name="ItemInfoResult">
<xsd:all>
<xsd:element name="name" type="xsd:string"/>
<xsd:element name="age" type="xsd:unsignedInt"/>
</xsd:all>
</xsd:complexType>
<xsd:complexType name="ItemInfoResultArray">
<xsd:complexContent>
<xsd:restriction base="soapenc:Array">
<xsd:attribute ref="soapenc:arrayType" wsdl:arrayType="typens:ItemInfoResult[]"/>
</xsd:restriction>
</xsd:complexContent>
</xsd:complexType>
</xsd:schema>
</types>
<message name="ConnRequest"></message>
<message name="ConnResponse">
<part name="conn_bool" type="xsd:boolean" />
</message>
<message name="GetItemInfoRequest">
<part name="find_age" type="xsd:unsignedInt" />
</message>
<message name="GetItemInfoResponse">
<part name="result" type="typens:ItemInfoResultArray"/>
</message>
<message name="DissConnRequest"></message>
<message name="DissConnResponse"></message>
<portType name="LovemacPortType">
<operation name="Conn">
<input message="typens:ConnRequest"/>
<output message="typens:ConnResponse"/>
</operation>
<operation name="GetItemInfo">
<input message="typens:GetItemInfoRequest"/>
<output message="typens:GetItemInfoResponse"/>
</operation>
<operation name="DissConn">
<input message="typens:DissConnRequest"/>
<output message="typens:DissConnResponse"/>
</operation>
</portType>
<binding name="LovemacBinding" type="typens:LovemacPortType">
<soap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<operation name="Conn">
<soap:operation soapAction="" />
<input name="ConnRequest">
<soap:body use="encoded"
namespace="urn:LovemacService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output name="ConnResponse">
<soap:body use="encoded"
namespace="urn:LovemacService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="GetItemInfo">
<soap:operation soapAction=""/>
<input name="GetItemInfoRequest">
<soap:body use="encoded"
namespace="urn:LovemacService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output name="GetItemInfoResponse">
<soap:body use="encoded"
namespace="urn:LovemacService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
<operation name="DissConn">
<soap:operation soapAction="" />
<input name="DissConnRequest">
<soap:body use="encoded"
namespace="urn:LovemacService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</input>
<output name="DissConnResponse">
<soap:body use="encoded"
namespace="urn:LovemacService"
encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
</output>
</operation>
</binding>
<service name="LovemacServer">
<port name="LovemacPortType" binding="typens:LovemacBinding">
<soap:address location="http://10.0.0.1:3000/lovemac/service" />
</port>
</service>
</definitions>
それにしてもXMLって....疲れる。ケドだんだん面白くなってきました。








Comments
comment1,
comment1,