问题是我无法通过SOAP将类数组发送到特定的Web服务,但我无法更改其结构。
下面你会看到肥皂功能的架构:
http://www.elyotech.com/share/yoni/forum/developpeznet-soap.jpg
在这里你会找到我对应的代码:
$s = new soapclient($URL_WEBSERVICE,array('wsdl'=>true,"trace"=>true));
$params = new stdClass();
$params->loginInfo = new stdClass();
$params->loginInfo->UserName = 'username';
$params->loginInfo->Password = 'password';
$params->loginInfo->LanguageCode = 'en';
$params->reservation = new stdClass();
$params->reservation->EmailRecipient2 = 'yonia@yopmail.com';
$params->reservation->EmailRecipient3 = 'yonia2@yopmail.com';
$params->reservation->FirstName = 'Yoni'
foreach($extras as $id=>$extra)
{
$params->Extras[$id]= new stdClass();
$params->Extras[$id]->SelectedExtra = new stdClass();
$params->Extras[$id]->ExtensionData = new stdClass();
$params->Extras[$id]->SelectedExtra->Amount = 1;
$params->Extras[$id]->SelectedExtra->ID = $extra;
}
以下是发送的SOAP请求:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:CreateReservation>
<ns1:loginInfo>
<ns1:UserName>monusername</ns1:UserName>
<ns1:Password>monpass</ns1:Password>
<ns1:LanguageCode>en</ns1:LanguageCode>
</ns1:loginInfo>
<ns1:reservation>
<ns1:EmailRecipient2>yonia@yopmail.com</ns1:EmailRecipient2>
<ns1:EmailRecipient3>yonia2@yopmail.com</ns1:EmailRecipient3>
<ns1:FirstName>Yoni</ns1:FirstName>
</ns1:reservation>
</ns1:CreateReservation>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
在这个Soap请求中,我找不到Extras
对象数组。
您是否知道如何创建我的对象以便正确发送它?
答案 0 :(得分:1)
我解决了这个问题,使用了其他帖子,以及很多十分作为。
$params->Extras = array_to_objecttree($params->Extras);
array_to_objecttree在这里描述Passing array to SOAP function in PHP