【发布时间】:2011-11-15 05:14:01
【问题描述】:
我想调用一个只有 WSDL 文件的 Web 服务。我将列出 WSDL 文件中的重要位,并将上下文相关的名称替换为通用名称:
我要调用的函数:
<wsdl:operation name="myFunction">
<wsdl:input message="ns:myFunctionRequest" wsaw:Action="urn:myFunction"/>
<wsdl:output message="ns:myFunctionResponse" wsaw:Action="urn:myFunctionResponse"/>
</wsdl:operation>
函数说明:
<xs:element name="myFunction">
<xs:complexType>
<xs:sequence>
<xs:element minOccurs="0" name="param0" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="param1" nillable="true" type="somens:MyType"/>
<xs:element minOccurs="0" name="param2" nillable="true" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
'MyType'的描述:
<xs:complexType name="MyType">
<xs:sequence>
<xs:element minOccurs="0" name="date1" nillable="true" type="xs:dateTime"/>
<xs:element minOccurs="0" name="date2" nillable="true" type="xs:dateTime"/>
<xs:element minOccurs="0" name="string1" nillable="true" type="xs:string"/>
<xs:element minOccurs="0" name="int1" nillable="true" type="xs:int"/>
<xs:element minOccurs="0" name="int2" nillable="true" type="xs:int"/>
</xs:sequence>
</xs:complexType>
我的 PHP 代码看起来有点像这样:
$client = new SOAPClient('my soap URL');
$result = $client->setState(array('param0'=>'bla', 'param1'=><undecided>, 'param2'=>'bla');
我的问题是在未决定的部分放什么。那应该是一个将复杂类型中的名称映射到值的数组吗?还是应该是我用相应类型的字段定义自己的类?目前我没有一个很好的试验场来尝试这个,我希望能够在它可用之前继续前进。
我看到很多与 SOAP 相关的问题没有得到解答,所以我希望我能走运 :)。如果我碰巧发现自己,我当然会分享我的结果。
提前致谢!
【问题讨论】:
标签: php web-services soap wsdl complextype