PHP在Soap调用中重复了元素 [英] PHP repeated elements in a soap call

查看:65
本文介绍了PHP在Soap调用中重复了元素的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从PHP进行肥皂呼叫时遇到问题。



首先要了解一些背景信息:该呼叫将转到执行以下操作的系统一个人在大型CRM系统上进行搜索。它要求提供诸如姓名,城市,出生日期等信息。)成功后,它应该返回一个或多个ID。 soap接口是系统的标准部分,因此我无法影响调用的布局。



我首先从在SoapUI中构建soap请求开始,看看我能否使它工作。我最终收到了这个肥皂请求,该请求正在运行:

 < soap:Envelope xmlns:soap = http:// www.w3.org/2003/05/soap-envelope xmlns:hidl = http://humaninference.com/hidl-mapped> 
< soap:Header />
< soap:Body>
< hidl:HI__DQComponents__Identify__Searching__Search>
< hidl:model> MAGMA :: PERSON< / hidl:model>
< hidl:execution> Match< / hidl:execution>
< hidl:interfaceFields>
< hidl:item>
< hidl:Name> master_id< / hidl:Name>
< hidl:Value> 0< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name>名称< / hidl:Name>
< hidl:Value> jansen< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name>出生日期< / hidl:Name>
< hidl:Value>< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name> add_id< / hidl:Name>
< hidl:Value>< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name>街道< / hidl:Name>
< hidl:Value> oudegracht< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name> dumstreet< / hidl:Name>
< hidl:Value>< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name>房屋编号< / hidl:Name>
< hidl:Value>< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name>邮政编码< / hidl:Name>
< hidl:Value>< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name> city< / hidl:Name>
< hidl:Value>乌得勒支< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name> citydum< / hidl:Name>
< hidl:Value>< / hidl:Value>
< / hidl:item>
< hidl:item>
< hidl:Name> add_line_twee< / hidl:Name>
< hidl:Value>< / hidl:Value>
< / hidl:item>
< / hidl:interfaceFields>
< / hidl:HI__DQComponents__Identify__Searching__Search>
< / soap:Body>
< / soap:Envelope>

下一步是从PHP构建相同的请求,为此我编写了这段代码:

  $ result = $ client-> HI__DQComponents__Identify__Searching__Search(array(
'model'=>'MAGMA :: PERSON',
'execution'=>'搜索',
'interfaceFields'=>数组(
'item'=>数组('Name'=>'master_id' ,'Value'=>'0'),
'item'=>数组('Name'=>'Name','Value'=>'jansen'),
' item'=>数组('Name'=>'birthdate','Value'=>''),
'item'=>数组('Name'=>'add_id',' Value'=>''),
'item'=>数组('Name'=>'street','Value'=>'Oudegracht'),
'item'= > array('Name'=>'dumstreet','Value'=>''),
'item'=> array('Name'=>'housenumber','Value'= >''),
'item'=>数组('Name'=>'postc ode, Value => ’’),
‘item’=>数组(名称 =>城市,值 => utrecht),
项目 =>数组(名称 => citydum,值 =>),
项目 =>数组(名称 => add_line_twee,值 =>‘),

));

echo’< PRE>’;
print_r($ result);
echo‘< / PRE>’;

但这失败了。这个问题非常明显,因为 item元素被重复了几次,并且在PHP中是数组的键,所以只有Item add_line_twee会在称为 interfaceFields的数组中,因为它一直被覆盖。 / p>

不幸的是,我无法弄清楚该如何做,所以我无法使请求像我从SoapUI创建的示例那样。



有什么想法吗?

解决方案

可以不使用非关联数组吗? ?即

  interfaceFields =>数组(
数组('Name'=>'master_id','Value'=>'0'),
数组('Name'=>'Name','Value'=> ;'jansen'),
数组('Name'=>'birthdate','Value'=>''),
数组('Name'=>'add_id','Value '=>''),
数组('Name'=>'street','Value'=>'Oudegracht'),
数组('Name'=>'dumstreet' ,'Value'=>''),
数组('Name'=>'housenumber','Value'=>''),
数组('Name'=>'邮政编码'','Value'=>''),
数组('Name'=>'city','Value'=>'utrecht'),
数组('Name'= >'citydum','Value'=>''),
数组('Name'=>'add_line_twee','Value'=>''),


I am having a problem with a soap call I'm trying to do from PHP.

First some background information: The call is going to a system that does a person search on a big CRM system. It requires information like name, city, birthdate, etc. ) When successful, it should return one or multiple id's. The soap interface is a standard piece of the system, so I can not influence the layout of the call.

I first started off by building the soap request in SoapUI, to see if I could get it working. I ended up with this soap request, which is working:

 <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:hidl="http://humaninference.com/hidl-mapped">
   <soap:Header/>
   <soap:Body>
      <hidl:HI__DQComponents__Identify__Searching__Search>
         <hidl:model>MAGMA::PERSON</hidl:model>
         <hidl:execution>Match</hidl:execution>
         <hidl:interfaceFields>
            <hidl:item>
               <hidl:Name>master_id</hidl:Name>
               <hidl:Value>0</hidl:Value>
            </hidl:item>
            <hidl:item>
               <hidl:Name>Name</hidl:Name>
               <hidl:Value>jansen</hidl:Value>
            </hidl:item>
            <hidl:item>
               <hidl:Name>birthdate</hidl:Name>
               <hidl:Value></hidl:Value>
            </hidl:item>
            <hidl:item>
               <hidl:Name>add_id</hidl:Name>
               <hidl:Value></hidl:Value>
            </hidl:item>
            <hidl:item>
               <hidl:Name>street</hidl:Name>
               <hidl:Value>oudegracht</hidl:Value>
            </hidl:item>
            <hidl:item>
               <hidl:Name>dumstreet</hidl:Name>
               <hidl:Value></hidl:Value>
            </hidl:item>
            <hidl:item>
               <hidl:Name>housenumber</hidl:Name>
               <hidl:Value></hidl:Value>
            </hidl:item>
            <hidl:item>
               <hidl:Name>postcode</hidl:Name>
               <hidl:Value></hidl:Value>
            </hidl:item>
        <hidl:item>
               <hidl:Name>city</hidl:Name>
               <hidl:Value>Utrecht</hidl:Value>
            </hidl:item>
        <hidl:item>
               <hidl:Name>citydum</hidl:Name>
               <hidl:Value></hidl:Value>
            </hidl:item>
        <hidl:item>
               <hidl:Name>add_line_twee</hidl:Name>
               <hidl:Value></hidl:Value>
            </hidl:item>
         </hidl:interfaceFields>
      </hidl:HI__DQComponents__Identify__Searching__Search>
   </soap:Body>
</soap:Envelope>

The next step was to build the same request from PHP, for that I wrote this piece of code:

$result = $client->HI__DQComponents__Identify__Searching__Search(array(
    'model' => 'MAGMA::PERSON', 
    'execution' => 'Search',
    'interfaceFields' => array (
        'item' => array ('Name' => 'master_id',     'Value' => '0' ),
        'item' => array ('Name' => 'Name',          'Value' => 'jansen' ),
        'item' => array ('Name' => 'birthdate',     'Value' => ' ' ),
        'item' => array ('Name' => 'add_id',        'Value' => ' ' ),
        'item' => array ('Name' => 'street',        'Value' => 'Oudegracht' ),
        'item' => array ('Name' => 'dumstreet',     'Value' => ' ' ),
        'item' => array ('Name' => 'housenumber',   'Value' => ' ' ),
        'item' => array ('Name' => 'postcode',      'Value' => ' ' ),
        'item' => array ('Name' => 'city',          'Value' => 'utrecht' ),
        'item' => array ('Name' => 'citydum',       'Value' => ' ' ),
        'item' => array ('Name' => 'add_line_twee', 'Value' => ' ' ),
        )
    ));

echo '<PRE>';
print_r($result);
echo '</PRE>';

This however fails. The problem is pretty obvious, since the "item" element is repeated several times, and in PHP it is the key of the array, only the Item add_line_twee will be in the array called "interfaceFields", since it's overwritten all the time.

Unfortunately I can't figure out how to do this another way around, so I can't get the request to be like in the example I created from SoapUI.

Any ideas?

解决方案

Could you not use a non-associative array? I.e.

'interfaceFields' => array (
    array ('Name' => 'master_id',     'Value' => '0' ),
    array ('Name' => 'Name',          'Value' => 'jansen' ),
    array ('Name' => 'birthdate',     'Value' => ' ' ),
    array ('Name' => 'add_id',        'Value' => ' ' ),
    array ('Name' => 'street',        'Value' => 'Oudegracht' ),
    array ('Name' => 'dumstreet',     'Value' => ' ' ),
    array ('Name' => 'housenumber',   'Value' => ' ' ),
    array ('Name' => 'postcode',      'Value' => ' ' ),
    array ('Name' => 'city',          'Value' => 'utrecht' ),
    array ('Name' => 'citydum',       'Value' => ' ' ),
    array ('Name' => 'add_line_twee', 'Value' => ' ' ),
)

这篇关于PHP在Soap调用中重复了元素的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆