Board index   FAQ   Search  
Register  Login
Board index php forum :: php coding PHP coding => General

soap array conversion to php array

Ask about general coding issues or problems here.

Moderators: macek, egami, gesf

soap array conversion to php array

Postby alif » Thu Jul 18, 2013 9:48 pm

Hello all,

Can anyone please help to convert the following soap string into php array.

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://uk.apitest.tripsta.net/flight/api/wsdl" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body>
<ns1:searchResponse>
<return SOAP-ENC:arrayType="SOAP-ENC:Struct[234]" xsi:type="SOAP-ENC:Array">
<item xsi:type="SOAP-ENC:Struct">
<legs SOAP-ENC:arrayType="SOAP-ENC:Struct[2]" xsi:type="SOAP-ENC:Array">
<item xsi:type="SOAP-ENC:Struct">
<type xsi:type="xsd:string">OB</type>
<segments SOAP-ENC:arrayType="SOAP-ENC:Struct[1]" xsi:type="SOAP-ENC:Array">
<item xsi:type="SOAP-ENC:Struct">
<airlineCode xsi:type="xsd:string">BA</airlineCode>
<flightNumber xsi:type="xsd:string">572</flightNumber>
...
....
......
........

</item>
</return>
</ns1:searchResponse>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>


Thanks in advance.
alif
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue Jul 12, 2011 10:20 pm

Re: soap array conversion to php array

Postby pbs » Thu Jul 18, 2013 10:37 pm

you will need SOAP client to call SOAP web service, check nusoap php library to do the same
pbs
New php-forum User
New php-forum User
 
Posts: 39
Joined: Sat May 11, 2013 1:40 am
Location: Nashik, India

Re: soap array conversion to php array

Postby alif » Fri Jul 19, 2013 1:31 am

Thanks for the reply.

I had already used the webservice and got reply from the third party. The response which i get is in the format as i have listed in my post. My question is that now how should i convert this soap string into php array so that i can access the data.

If i use nusoap php library to used webservice then the response will be in normal php ? If not then again the problem is same that how would i convert this soap string in php array and how would i access the data in the string.

Please, Please help me, i had got trapped in this issue.

Thanks in advance.
alif
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue Jul 12, 2011 10:20 pm

Re: soap array conversion to php array

Postby johnj » Fri Jul 19, 2013 4:59 am

Why don't you parse this xml? There are plenty of xml parsing functions in php
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: soap array conversion to php array

Postby alif » Mon Jul 22, 2013 4:04 am

Thanks for the reply.

I would like to let you know that this is soap encoded array, and i think it will not be parsed using any xml parser.

As per you post can i ask for any xml parser which will parse soap encoded xml array. Thanks in advance
alif
New php-forum User
New php-forum User
 
Posts: 4
Joined: Tue Jul 12, 2011 10:20 pm

Re: soap array conversion to php array

Postby johnj » Mon Jul 22, 2013 10:19 pm

If it is a string called $soap_str then you can type cast it like, $new_array = (array)$soap_str;
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm

Re: soap array conversion to php array

Postby johnj » Mon Jul 22, 2013 10:25 pm

$element = new SimpleXMLElement( $xmlsoapstr );
$singleElement = $element->Body->searchResponse->return->item;

$new_array = array(
$singleElement->airlineCode,
$single->Flight Number);

something like this - I did not test the above code but it is possible...
johnj
php-forum Super User
php-forum Super User
 
Posts: 1805
Joined: Thu Mar 10, 2011 5:07 pm


Return to PHP coding => General

Who is online

Users browsing this forum: No registered users and 2 guests

Sponsored by Sitebuilder Web hosting and Traduzioni Italiano Rumeno and antispam for cPanel.

cron