代码之家  ›  专栏  ›  技术社区  ›  bcmcfc

SOAP不通过多维数组

  •  1
  • bcmcfc  · 技术社区  · 14 年前

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

    我试着把它输入到一个SOAP调用中,如下所示:

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

    2 回复  |  直到 12 年前
        1
  •  0
  •   bcmcfc    14 年前

    我已经找到了原因,但一开始我并不清楚。

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

    a , b d 但不是 c , c类

        2
  •  0
  •   Serjik bp3    9 年前

    我也有这个问题。它将给我和错误“服务不可用”。我做了你做的事,但还是错了。

    这是我的请求:

    主持人:www.sample.com.au 内容类型:text/xml;charset=utf-8 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'
    )));