2010-10-26 45 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' 
)));