Php repeating elements in soap call

I have a problem with a soap call that I am trying to make from PHP.

First, some background information: the call goes to a system that searches for a person in a large CRM system. This requires information such as name, city, date of birth, etc.). On success, it must return one or more identifiers. The soap interface is a standard element of the system, so I can not influence the layout of the call.

First, I started by creating a soap request in SoapUI to find out if I can make it work. I ended up with this soapy query that works:

 <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 create the same request with PHP, because 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>';

. , "item" , PHP , add_line_twee "interfaceFields", .

, , -, , SoapUI.

?

+3
3

? .

'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' => ' ' ),
)
+6
0

Patrik, , , :

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

, - , , "name" .

Fatal error: unclean SoapFault exception: [Sender] SOAP-ERROR: Encoding: object has no name Property

I also get the same error when I change only the first line of the call to

new SoapParam('MAGMA::PERSON','model')

It’s so clear that I'm missing something. Unfortunately, the documentation for SoapParam is not very extensive, so I'm not quite sure what I'm doing wrong here.

0
source

Source: https://habr.com/ru/post/1767181/


All Articles