我需要在PHP中使用以下SOAP结构生成SOAP请求:
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="https://.../CardBalance">
<s:element name="HelloWorld">
<s:complexType/>
</s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SecureLogin">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userProp" type="tns:UserProp"/>
<s:element minOccurs="0" maxOccurs="1" name="request" type="tns:SecureLogin"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="UserProp">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userName" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="password" type="s:string"/>
</s:sequence>
</s:complexType>
<s:complexType name="SecureLogin">
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="memberID" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="cardNumber" type="s:string"/>
<s:element minOccurs="0" maxOccurs="1" name="guid" type="s:string"/>
<s:element minOccurs="1" maxOccurs="1" name="page" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" default="" name="Population" type="s:string"/>
</s:sequence>
</s:complexType>
<s:element name="SecureLoginResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SecureLoginResult" type="tns:DTS_Response"/>
</s:sequence>
</s:complexType>
</s:element>
<s:complexType name="DTS_Response">
<s:sequence>
<s:element minOccurs="1" maxOccurs="1" name="response_Status" type="tns:Response_Status"/>
<s:element minOccurs="1" maxOccurs="1" name="errorCode" type="s:int"/>
<s:element minOccurs="0" maxOccurs="1" name="errorDescription" type="s:string"/>
</s:sequence>
</s:complexType>
<s:simpleType name="Response_Status">
<s:restriction base="s:string">
<s:enumeration value="Success"/>
<s:enumeration value="Failure"/>
<s:enumeration value="NotAvailable"/>
<s:enumeration value="GlobalException"/>
</s:restriction>
</s:simpleType>
<s:element name="SecureLoginMethod">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="userProp" type="tns:UserProp"/>
<s:element minOccurs="0" maxOccurs="1" name="request" type="tns:SecureLogin"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="SecureLoginMethodResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="SecureLoginMethodResult" type="tns:DTS_Response"/>
</s:sequence>
</s:complexType>
</s:element>
<s:element name="string" nillable="true" type="s:string"/>
</s:schema>
</wsdl:types>
我该怎么做?我尝试过:
<?php
ini_set('soap.wsdl_cache_enabled',0); // disabling WSDL cache
ini_set('soap.wsdl_cache_ttl',0);
$wsdl_path = "https://.../CARDBALANCE/CB_WS.ASMX?WSDL";
$client = new SoapClient($wsdl_path, array('trace' => 1, 'exception' => 1));
$res = $client->SecureLogin(array("UserProp"=>array("userName"=>"?","password"=>"?"),"request"=>array("memberID"=>"?","cardNumber"=>"?","guid"=>"?","page"=>1)));
echo '<br /><br />';
echo htmlentities ($client->__getLastRequest());
try {
echo "<pre>\n";
var_dump($res->SecureLoginResult);
echo "\n</pre>\n";
}
catch (SoapFault $exception) {
echo $exception;
}
?>
但我得到致命错误:
致命错误: 未捕获的SoapFault异常:[soap:Server]服务器无法处理请求。 ---&GT;你调用的对象是空的。在/var/www/u0109499/data/www/yakosmetolog.ru/soap.php:48堆栈追踪:#0 /var/www/u0109499/data/www/yakosmetolog.ru/soap.php(48):SoapClient- &gt; __ call('SecureLogin',Array)#1 /var/www/u0109499/data/www/yakosmetolog.ru/soap.php(48):SoapClient-&gt; SecureLogin(数组)#2 {main}抛出/第48行的var / www / u0109499 / data / www / yakosmetolog.ru / soap.php
如何在PHP中正确地请求该消息?感谢您的帮助。
答案 0 :(得分:0)
看看这个答案对你有帮助吗?一般来说,对SO的期望是你寻找类似的先前问题 - 如果它们存在 - 使用它们或解释它们与你的情况不符的原因。