[英]How do I create a PHP array for a SOAP call?
Here's the SOAP function: 这是SOAP函数:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://domain.com/" xmlns:sen="http:/domain.com">
<soapenv:Header/>
<soapenv:Body>
<v2:actionContactsGroup>
<sen:pInfo>
<sen:ActionType>?</sen:ActionType>
<sen:GroupName>?</sen:GroupName>
<!--Optional:-->
<sen:ContactIdsList>
<!--1 or more repetitions:-->
<sen:Id>?</sen:Id>
</sen:ContactIdsList>
</sen:pInfo>
</v2:actionContactsGroup>
</soapenv:Body>
</soapenv:Envelope>
If I send over this XML code it works just fine: 如果我发送这个XML代码它可以正常工作:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:v2="http://domain.com" xmlns:sen="http://domain.com">
<soapenv:Header/>
<soapenv:Body>
<v2:actionContactsGroup>
<sen:pInfo>
<sen:ActionType>Add</sen:ActionType>
<sen:GroupName>MyGroup</sen:GroupName>
<sen:ContactIdsList>
<sen:Id>SomeID1</sen:Id>
<sen:Id>SomeID2</sen:Id>
<sen:Id>SomeID3</sen:Id>
</sen:ContactIdsList>
</sen:pInfo>
</v2:actionContactsGroup>
</soapenv:Body>
</soapenv:Envelope>
But I'm unable to do the same in php. 但是我无法在php中做同样的事情。 I can do it with one id at a time: 我可以一次使用一个id:
$addToGroup = array(
'pInfo'=>array(
'ActionType'=>'Add',
'GroupName'=>'MyGroup',
'ContactIdsList'=>array('Id'=>'SomeID1')
)
);
But if I try multiple ids it doesn't work no matter how I format the array. 但是,如果我尝试多个ID,无论我如何格式化数组,它都无法工作。 Ideas? 想法?
I tried this but didn't work: 我尝试了这个但是没有用:
// didnt work, came back saying "Warning: Contact not found
// [Array]WarningDuplicated contact. Only first instance was used."
$addToGroup = array(
'pInfo'=>array(
'ActionType'=>'Add',
'GroupName'=>'NCAL_SUW',
'ContactIdsList'=>array(
array('Id'=>'SomeID1'),
array('Id'=>'SomeID2')
)
)
)
I finally figured it out: the array to send out apparently doesn't need to mention the "Id" element. 我终于明白了:显然发出的数组不需要提及“Id”元素。 Directly posting a list of ids is enough. 直接发布ID列表就足够了。 So, I ended up using the array below. 所以,我最终使用下面的数组。 Why I don't need to mention the "Id" element in my array is beyond me but apparently the soap client takes care of it by itself. 为什么我不需要提到我的数组中的“Id”元素超出了我,但显然肥皂客户端自己处理它。
$addToGroup = array(
'pInfo'=>array(
'ActionType'=>'Add',
'GroupName'=>'NCAL_SUW',
'ContactIdsList'=>array(
'SomeID1',
'SomeID2'
)
)
)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.