document/literalに対応したWSDLの生成方法,およびJavaインタフェースとWSDLのマッピングについて説明します。
document/literalに対応したWSDLは,Java2WSDLコマンドで生成できます。Java2WSDLコマンドの-zオプションで「DOCUMENT」,-uオプションで「LITERAL」を指定します。
Java2WSDLコマンドの使用方法については,「9.1 Java2WSDLコマンド(WSDLの生成)」を参照してください。
document/literal使用時のJavaインタフェースとWSDLのマッピング,および生成されるWSDLの詳細仕様について説明します。
次に示すWSDLの生成例を基に,document/literal使用時のJavaインタフェースとWSDLのマッピングについて説明します。
図3-17 JavaインタフェースとWSDLのマッピング(document/literal)
Java2WSDLコマンドでdocument/literalに対応したWSDLを生成する場合,常にwrapped形式のWSDLが生成されます。
なお,次のどちらかが該当する場合,子要素に空のcomplexType要素(<complexType/>)を持つ「メソッド名」要素および「メソッド名」+「Response」要素が生成されます。
次の表に,Java2WSDLコマンドでdocument/literalに対応したWSDLを生成した場合の定義内容を示します。
表3-9 Java2WSDLコマンドで生成されたWSDLの定義内容(document/literal)
WSDL中の要素 | 定義内容 | ||
---|---|---|---|
wsdl:types要素 | xsd:schema要素 | xsd:schema要素 | elementFormDefault属性の値は"qualified"が定義されます。 |
リクエストメッセージに対応するxsd:element要素 |
| ||
レスポンスメッセージに対応するxsd:element要素 |
| ||
リクエストメッセージに対応するwsdl:message要素※3 | wsdl:part要素 | element属性でxsd:schema要素下で定義されている,name属性が"メソッド名"の要素が定義されます。 | |
レスポンスメッセージに対応するwsdl:message要素※3 | wsdl:part要素 | element属性でxsd:schema要素下で定義されているname属性が"メソッド名"+"Response"の要素が定義されます。 | |
wsdl:binding要素 | soap:binding要素 | style属性で"document"が定義されます。 | |
wsdl:input要素/wsdl:output要素 | soap:body要素 |
|
Javaインタフェース,Javaクラス,およびdocument/literalに対応したWSDLの生成例を示します。
package localhost;
public interface UserInfo {
public UserData getUserData(String in0, int in1);
}
package localhost;
public class UserData {
private String name;
private String section;
private String telephone;
public UserData() {
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getSection() {
return section;
}
public void setSection(String section) {
this.section = section;
}
public String getTelephone() {
return telephone;
}
public void setTelephone(String telephone) {
this.telephone = telephone;
}
<wsdl:definitions targetNamespace="http://localhost" xmlns:intf="http://localhost" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema elementFormDefault="qualified" targetNamespace="http://localhost" xmlns="http://www.w3.org/2001/XMLSchema">
<element name="getUserData">
<complexType>
<sequence>
<element name="in0" type="xsd:string"/>
<element name="in1" type="xsd:int"/>
</sequence>
</complexType>
</element>
<element name="getUserDataResponse">
<complexType>
<sequence>
<element name="getUserDataReturn" type="intf:UserData"/>
</sequence>
</complexType>
</element>
<complexType name="UserData">
<sequence>
<element name="name" nillable="true" type="xsd:string"/>
<element name="section" nillable="true" type="xsd:string"/>
<element name="telephone" nillable="true" type="xsd:string"/>
</sequence>
</complexType>
</schema>
</wsdl:types>
<wsdl:message name="getUserDataRequest">
<wsdl:part element="intf:getUserData" name="parameters"/>
</wsdl:message>
<wsdl:message name="getUserDataResponse">
<wsdl:part element="intf:getUserDataResponse" name="parameters"/>
</wsdl:message>
<wsdl:portType name="UserInfo">
<wsdl:operation name="getUserData">
<wsdl:input message="intf:getUserDataRequest" name="getUserDataRequest"/>
<wsdl:output message="intf:getUserDataResponse" name="getUserDataResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="UserInfoSoapBinding" type="intf:UserInfo">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getUserData">
<soap:operation soapAction=""/>
<wsdl:input name="getUserDataRequest">
<soap:body use="literal"/>
</wsdl:input>
<wsdl:output name="getUserDataResponse">
<soap:body use="literal"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="UserInfoService">
<wsdl:port binding="intf:UserInfoSoapBinding" name="UserInfo">
<soap:address location="http://localhost/RPCSampleService/services/UserInfo"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>