2010-10-26 53 views
1

我有一个多维阵列中,如:SOAP不通过多维数组

$array = array(
    'a' => 1, 
    'b' => 2, 
    'c' => array('42'=>'foo', '43'=>'bar'), 
    'd' => 4 
) 

我试图把其馈送到SOAP调用如下:

$response = $client->SomeFunction($array); 

的XML请求产生忽略'c'。为什么?

回答

0

我已经找出了原因,但最初并不明显。

如果数组与服务器期望的内容不完全匹配,则不会将其放入XML中。

例如,从上面的例子,如果服务器期待abd但不cc将刚刚被忽略,在XML中就不会显示。这是令人困惑的行为。

0

我也有这个问题。它会给我和错误“服务不可用”。我做了你所做的,但仍然错误。

这是我的要求:

POST /webservice/User.asmx HTTP/1.1 主持人:www.sample.com.au 内容类型:text/xml的;字符集= UTF-8 的Content-Length:长度 的SOAPAction: “http://www.sample.com.au/UpdateUserBatch

<UpdateUserBatch xmlns="http://www.sample.com.au/"> 
    <auth> 
    <Username>string</Username> 
    <Password>string</Password> 
    </auth> 
    <request> 
    <CreateIfNotExist>boolean</CreateIfNotExist> 
    <UpdateIfExists>boolean</UpdateIfExists> 
    <UserProfile> 
     <UserID>string</UserID> 
     <BusinessID>string</BusinessID> 
     <ExternalID>string</ExternalID> 
     <Username>string</Username> 
     <Password>string</Password> 
     <Addresses xsi:nil="true" /> 
     <Demographics xsi:nil="true" /> 
     <Roles xsi:nil="true" /> 
     </UserProfile> 
     <UserProfile> 
     <UserID>string</UserID> 
     <BusinessID>string</BusinessID> 
     <ExternalID>string</ExternalID> 
     <Username>string</Username> 
     <Password>string</Password> 
     <Addresses xsi:nil="true" /> 
     <Demographics xsi:nil="true" /> 
     <Roles xsi:nil="true" /> 
     </UserProfile> 
    </Users> 
    </request> 
</UpdateUserBatch> 

这是我通过它的参数的方式:

$param = array('username' => 'username', 'password' => 'password', 'request'=>array('CreateIfNotExist' => TRUE, 'UpdateIfExists' => FALSE), 'Users' => array('UserProfile'=> array('UserID' => 'usr123', 
'BusinessID' => 'bus123', 
'ExternalID' => 'ext123', 
'Username' => 'test', 
'Password' => 'testing' 
)));