Soapclient PHP is inserting undesirable parameters

Asked

Viewed 52 times

0

I’m in need of some help.

I am trying to make a communication between a PHP page and the SOAP of a third party company, but I have tried several ways and I can’t solve.

when sending XML it is putting Tags automatically even if I do not insert in my code.

what can be?

below example of the codes I am working on

   function atualizacaoCadastralXML(){

global $log, $client, $parceria, $connMS, $connSY;

$client = new SoapClient('http://cia-118:8080/g5-senior-services/rubi_Synccom_senior_g5_rh_fp_fichaComplementar?wsdl', array('soap_version' => SOAP_1_2,
    'trace' => 1,
    'exceptions' => 0,
    'use' => SOAP_LITERAL,
    'style' => SOAP_DOCUMENT));


$user = 'nome.sobrenome';

$data = soapify(array(
    "user" => $user,
    'parameters' => array(
        'numcad' => '123456',
        'numemp' => 1,
        'TipOpe' => 'A',
        'TipCol' => 1
    ),
));

$method = 'FichaComplementar_7';

$result = $client->$method(new SoapParam($data, 'Data'));

echo "<pre>";
echo print_r(htmlentities($client->__getLastRequest()));
echo "</pre>";
die();
}

function soapify(array $data){

    foreach ($data as &$value){ 
        if (is_array($value)){ 
            $value = soapify($value);
        }
    }    
        return new SoapVar($data, SOAP_ENC_OBJECT);
}

The return of the above code is the following, note who in no time I pass something related to user, password and encritpion.

<?
 xml version="1.0" encoding="UTF-8"?>
 <env:Envelope xmlns:env="http://www.w3.org/2003/05/soap-envelope"  
 xmlns:ns1="http://services.senior.com.br">
 <env:Body>
     <ns1:FichaComplementar_7>
       <user>
          <user>nome.sobrenome</user>
          <parameters>
             <numcad>123456</numcad>
             <numemp>1</numemp>
             <TipOpe>A</TipOpe>
             <TipCol>1</TipCol>
     </parameters>
     </user><password/>
     <encryption/>
     <parameters/>
     </ns1:FichaComplementar_7>
 </env:Body>
 </env:Envelope>
  • Its function soapify it’s really weird. I could go over it, please?

  • Hi Anderson, sorry, was missing the "{ }" must have been at the time of paste.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.