【问题标题】:How to pass the parameters using multidimensional array in webservice如何在webservice中使用多维数组传递参数
【发布时间】:2010-10-26 10:28:11
【问题描述】:

如何使用此请求在 Web 服务中传递参数:

POST /webservice/User.asmx HTTP/1.1 内容类型:文本/xml;字符集=utf-8 内容长度:长度 SOAPAction:“http://sample.com/UpdateUserBatch”

<UpdateUserBatch xmlns="http://sample.com/">
  <auth>
    <Username>string</Username>
    <Password>string</Password>
  </auth>
  <request>
    <CreateIfNotExist>boolean</CreateIfNotExist>
    <UpdateIfExists>boolean</UpdateIfExists>
    <Users>
      <UserProfile>
        <UserID>string</UserID>
        <BusinessID>string</BusinessID>
        <ExternalID>string</ExternalID>
        <Username>string</Username>
        <Password>string</Password>
        <UpdateDate>dateTime</UpdateDate>
      </UserProfile>
      <UserProfile>
        <UserID>string</UserID>
        <BusinessID>string</BusinessID>
        <ExternalID>string</ExternalID>
        <Username>string</Username>
        <Password>string</Password>
        <UpdateDate>dateTime</UpdateDate>
      </UserProfile>
    </Users>
  </request>
</UpdateUserBatch>

我想使用该网络服务导入数据。

【问题讨论】:

    标签: php arrays web-services soap


    【解决方案1】:

    我不确定POST 请求,但在GET 请求中,您通常对多维数组使用方括号表示法。例如:

    http://api.example.com/object/?foo[]=bar&amp;foo[]=baz

    这将在 API 端进行组装,如下所示:

    'foo' => array(
        0 => 'bar',
        1 => 'baz'
    );
    

    当然,您可以使用索引数组以及数值数组。

    【讨论】:

    • 感谢您的回复,但似乎不起作用。我收到错误“服务不可用”。
    • 这不是您的实施问题,而是您将请求发送到的实际服务。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-03-10
    相关资源
    最近更新 更多