tags:

views:

35

answers:

2

I have a multidimensional array, such as:

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

I'm trying to feed it into a SOAP call as follows:

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

The XML request produced ignores 'c'. Why?

A: 

I have figured out the reason, but it wasn't obvious to me initially.

If the array does not perfectly match up to what the server is expecting, it won't be put into the XML.

For example, from the above example, if the server was expecting a, b and d but not c, c would have just been ignored and wouldn't show in the XML. It's that behaviour that was confusing.

bcmcfc
A: 

Hi,

I also got that problem. It will give me and error "Service Unavailable". I did what you did but still error.

This is my request:

POST /webservice/User.asmx HTTP/1.1 Host: www.sample.com.au Content-Type: text/xml; charset=utf-8 Content-Length: length SOAPAction: "http://www.sample.com.au/UpdateUserBatch"

<UpdateUserBatch xmlns="http://www.sample.com.au/"&gt;
  <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>

And this is my way of passing its parameter:

$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' )));

rayss