我有一个肥皂请求声明如下:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
>
<soap:Body xmlns:myResource="example.org/api/soap/myResource">
<myResource:create_resource>
<myResource:myResourcesList>
<myResource:myResource>
<myResource:title>FIRST TITLE</myResource:title>
</myResource:myResource>
<myResource:myResource>
<myResource:title>SECOND TITLE</myResource:title>
</myResource:myResource>
</myResource:myResourceList>
</myResource:create_resource>
</soap:Body>
</soap:Envelope>
我想编写一个可以处理此类请求的WSDL文件。让我们说我已经宣布了基本的定义和模型:
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<wsdl:definitions
name="mySoapApi"
targetNamespace="http://example.org/api/soap/?wsdl"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap12="http://schemas.xmlsoap.org/wsdl/soap12/"
xmlns:soap12enc="http://www.w3.org/2003/05/soap-encoding"
xmlns:soap12env="http://www.w3.org/2003/05/soap-envelope"
xmlns:tns="http://example.org/api/soap/?wsdl"
xmlns:xs="http://www.w3.org/2001/XMLSchema"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
>
<wsdl:types>
<xs:schema targetNamespace="http://example.org/api/soap/?wsdl">
<xs:complexType name="myResource">
<xs:sequence>
<xs:element name="title" type="xs:string"/>
</xs:sequence>
</xs:complexType>
<xs:element name="myResource" type="tns:myResource"/>
<xs:complexType name="myResourceList">
<xs:sequence>
<xs:element name="myResource" type="tns:myResource" minOccurs="0" maxOccurs="unbounded" nillable="true"/>
</xs:sequence>
</xs:complexType>
<xs:element name="myResourceList" type="tns:myResourceList"/>
<xs:complexType name="createMyResourceListResponse">
<xs:sequence>
<xs:element name="myResourceList" type="tns:myResourceList"/>
</xs:sequence>
</xs:complexType>
<xs:element name="createMyResourceListResponse" type="tns:myResourceList"/>
</xs:schema>
</wsdl:types>
我有一些问题。
我不知道如何处理请求正文标记中声明的命名空间:
<soap:Body xmlns:myResource="example.org/api/soap/myResource">
<myResource:create_resource>
<myResource:myResourcesList>
<myResource:myResource>
<myResource:title>FIRST TITLE</myResource:title>
</myResource:myResource>
<myResource:myResource>
<myResource:title>SECOND TITLE</myResource:title>
</myResource:myResource>
</myResource:myResourceList>
</myResource:create_resource>
</soap:Body>
据我所知,每个Type和操作都应在WSDL文件中的适当命名空间中声明。怎么做?如何编写WSDL文件,以便响应此请求,我会得到类似的结果:
<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2003/05/soap-envelope/"
soap:encodingStyle="http://www.w3.org/2003/05/soap-encoding"
>
<soap:Body xmlns:myResource="example.org/api/soap/myResource">
<myResource:created_resource>
<myResource:myResourcesList>
<myResource:myResource>
<myResource:title>FIRST TITLE</myResource:title>
</myResource:myResource>
<myResource:myResource>
<myResource:title>SECOND TITLE</myResource:title>
</myResource:myResource>
</myResource:myResourceList>
</myResource:created_resource>
</soap:Body>
</soap:Envelope>
主要是myResource:create_resource
更改为myResource:created_resource
? (让我们说正确执行创建资源的逻辑)