I am trying to get the values from my web service using the following code:
$client = new SoapClient($url);
$response = $client->GetInfoByNumeroContrato(array(
'schema' => $schema,
'numContrato' => $numContract
));
I have a method called GetInfoByNumeroContrato
that receives two parameters. When I call my web service the $response
gives me a stdClass
Object as shown below:
stdClass Object
(
[GetInfoByNumeroContratoResult] => stdClass Object
(
[schema] =>
[any] => 000559500trueTITULAR BNMARIA DORES PEIXOTO220125424DORESRIBEIRO50@GMAIL.COMR DAMIAO DE GOIS ENTRADA 71 BL 1 1 ANDAR N 90000003194460-2921646013411950-10-07T00:00:00+01:00Divorciado003501600006968540097PT50003501600006968540097CGDIPTPLBilhete de IdentidadeSENHORA DA HORAFeminino4010003002015-09-16T00:00:00+01:0024.90falseSENIORtrue2015-10-05T00:00:00+01:00true2016-09-05T00:00:00+01:002015-11-05T00:00:00+00:00M0PT47111799DÉBITO DIRETOCONNECTA000559500falseAGREGADOJOSE LUIS RIBEIRO FAIEL220125424R DAMIAO DE GOIS ENTRADA 71 BL 1 1 ANDAR N 90000003204460-2921646013411983-08-23T00:00:00+01:00Outro003501600006968540097Bilhete de IdentidadeSENHORA DA HORAMasculino4010003012015-09-16T00:00:00+01:0024.90falseSENIORtrue2015-10-05T00:00:00+01:00true2016-09-05T00:00:00+01:002015-11-05T00:00:00+00:00M0PT47111799DÉBITO DIRETOCONNECTA
)
[_exception] =>
)
The idea is to get each value individually from [any] and the POST each one. For example get "000559500" then "true" and so on.
I have already tried to parse this but without success.
Is there any better way to go about this?
When I do the following:
print $response->GetInfoByNumeroContratoResult->any;
I get the following answer:
000559500trueTITULAR BNMARIA DORES PEIXOTO220125424DORESRIBEIRO50@GMAIL.COMR DAMIAO DE GOIS ENTRADA 71 BL 1 1 ANDAR N 90000003194460-2921646013411950-10-07T00:00:00+01:00Divorciado003501600006968540097PT50003501600006968540097CGDIPTPLBilhete de IdentidadeSENHORA DA HORAFeminino4010003002015-09-16T00:00:00+01:0024.90falseSENIORtrue2015-10-05T00:00:00+01:00true2016-09-05T00:00:00+01:002015-11-05T00:00:00+00:00M0PT47111799DÉBITO DIRETOCONNECTA000559500falseAGREGADOJOSE LUIS RIBEIRO FAIEL220125424R DAMIAO DE GOIS ENTRADA 71 BL 1 1 ANDAR N 90000003204460-2921646013411983-08-23T00:00:00+01:00Outro003501600006968540097Bilhete de IdentidadeSENHORA DA HORAMasculino4010003012015-09-16T00:00:00+01:0024.90falseSENIORtrue2015-10-05T00:00:00+01:00true2016-09-05T00:00:00+01:002015-11-05T00:00:00+00:00M0PT47111799DÉBITO DIRETOCONNECTA
Is it possible to get one by one?
Is it possible to receive from the web service insted getting every thing in [any] recive for example: [contractNumer] => value then [Name] => value and so on? Individualy?
I know this is a late answer, but might save hours for someone else:
$xml= simplexml_load_string($response->GetInfoByNumeroContratoResult->any);
print_r($xml); //an array containing the whole XML
print $x->contractNumber; //individually