i have a .net service i am consuming from php and the result comes in the format below.
i wish to have only the contents without the soap:envelope.
How do i achieve this?
<?xml version="1.0" encoding="utf-8"?><soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><VAccResponse xmlns="http://apps.hbng.com/"><VAccResult><VAccountSummary><Id>C0000005</Id><AccountNo>5100000014</AccountNo><AccountName>xyz HOSPITAL LTD</AccountName><SchemeCode>abc</SchemeCode><SchemeDescription>abc records</SchemeDescription><Balance>6627282</Balance><CurrencyCode>DOLLARS</CurrencyCode><AccountManagerId>F05</AccountManagerId><Debit>0</Debit><Credit>0</Credit><Tran>NO TRANSACTION DONE</Tran></VAccountSummary></VAccResult></VAccResponse></soap:Body></soap:Envelope>
How do i get the xml result without the soap:body, soap envelope etc...
Related
I call a method with php soapClient class, like this:
$client->ResetAppPassword($request);
and my envelope is send like this
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://xmlns.xxxx.com/PATH/TO/V1/schema"
xmlns:ns2="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<SOAP-ENV:Body>
<ns1:ResetAppPasswordRequest>
<ns1:username>TEST</ns1:username>
<ns1:app>TEST</ns1:app>
</ns1:ResetAppPasswordRequest>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
But the server response:
The message must be an instance of: {http://www.w3.org/2003/05/soap-envelope}Envelope
and this is because the service is specting other format:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:sch="http://xmlns.xxxx.com/PATH/TO/V1/schema">
<soap:Body>
<sch:ResetAppPasswordRequest>
<sch:username>TEST</sch:username>
<sch:app>DMS</sch:app>
</sch:ResetAppPasswordRequest>
</soap:Body>
</soap:Envelope>
So the i already tried to send it via php-CURL but with this solution I need to parse the XML response, so this make the process really hard, because I want to manage the response as an object.
Can someone help me... PLEASSSE..
I want to receive data using method GetCruise
How to do that in php using SoapClient, of course i know all URLs and I've got PartnerName, Password and AgencyCode
especially i need to know how to construct proper header of envelope using SoapClient::__setSoapHeaders
GetCruise
Call:
Proxy.Availability.GetCruise(“FO11060119”);
Parameters:
CruiseCode - the cruise code to be returned
Returns:
a fully described cruise (including itinerary and segments of an itinerary).
Example of soap envelope:
(headers must contain agency data - name paswword etc. i've got it)
SOAPAction: "http://schemas.costacrociere.com/WebAffiliation/GetCruise"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Header>
<Agency xmlns="http://schemas.costacrociere.com/WebAffiliation">
<Code>1111</Code>
<Culture />
</Agency>
<Partner xmlns="http://schemas.costacrociere.com/WebAffiliation">
<Name>AAAA</Name>
<Password>XXXX</Password>
</Partner></soap:Header>
<soap:Body>
<GetCruise xmlns="http://schemas.costacrociere.com/WebAffiliation">
<CruiseCode>FO11060119</CruiseCode>
</GetCruise>
</soap:Body>
</soap:Envelope>
I am writing PHP soap client.
I used wsdlbrowser to format the soap request correctly.
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://ws.iws.iaeste.net/">
<SOAP-ENV:Body>
<ns1:fetchOffers>
<token>
<token>..your token..</token>
</token>
<request>
<exchangeYear>2015</exchangeYear>
<fetchType>SHARED</fetchType></request>
</ns1:fetchOffers>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This would be correctly formatted soap request. Or to be specific, the code beetwen first token tag and last request tag is in the point of interest.
How would I transfer this request to PHP for sending it over SOAP?
THis question is connceted to: PHP Soap client, Java SOAP server
I have a soap response with this structure in PHP:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:srv="http://srv.soap.factura.sit.mx.com">
<soap:Body>
<srv:responseXMLT>
<return><tfd:ValorXML version="1.0" Key="000XY 212XH" FechaResponse="2014-05-14T14:37:45"/>
</return>
</srv:timbraCFDIXMLTestResponse>
I want to read the data inside of return and save each value in a database, but how can I read the value of .??
Thanks for all!!
I am working with the XML file string below and I've tried a number of methods to try and get access to certain parts of the XML contents. Please see the code after the XML file below for my attempt:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<Address_ListResponse xmlns="http://example.example.com/">
<Address_ListResult>
<Address>
<HoldingId xsi:nil="true"/>
<MainId>1617931</MainId>
<ContactId>8</ContactId>
<Description>Home, All Purposes</Description>
<Position/>
<Department/>
<Organisation/>
<AddressLabel>Mr Joe Bloggs</AddressLabel>
<AddressLine1>1 Fake Road</AddressLine1>
<AddressLine2/>
<AddressLine3/>
<Town>Faketown</Town>
<CountyId>818</CountyId>
<PostCode>FA33 4KE</PostCode>
<CountryId>3</CountryId>
<Phone>01234567890</Phone>
<EvePhone/>
<Mobile/>
<Email>joe#bloggs.com</Email>
<Fax/>
<WWW/>
<AddressTypeId>1</AddressTypeId>
<IsBilling>true</IsBilling>
<IsMailing>true</IsMailing>
<IsDelivery>true</IsDelivery>
<IsInherited>false</IsInherited>
<GridN/>
<GridE/>
<Latitude/>
<Longitude/>
<CensationCode/>
<IsDeleted>false</IsDeleted>
<HoldingPersonalDetailsId xsi:nil="true"/>
<IsSynced>false</IsSynced>
<BeenProcessed>false</BeenProcessed>
<CountyName/>
<CountryName/>
<AddressTypeName>Home</AddressTypeName>
</Address>
</Address_ListResult>
</Address_ListResponse>
</soap:Body>
</soap:Envelope>
Code for accessing the XML content:
$xml = simplexml_load_string($result);
echo "Town: " . $xml->children('http://schemas.xmlsoap.org/soap/envelope/')->children('http://example.example.com/')->Address_ListResponse->Town;
The above code was based on a link posted by another StackOverFlow question: http://blog.preinheimer.com/index.php?/archives/172-SimpleXML,-Namespaces-Hair-loss.html
Any help would be appreciated.
Thanks.
Consider using the SOAP extension instead.
See the example in the PHP Manual on how to write a client.
An alternative would be to use Zend_Soap as a standalone component.
Turns out the answer I was looking for wasn't SimpleXML - or at least I couldn't get that to work.
What I have done is used the xml_parse_into_struct to create an array of values returned from the XML data: http://www.php.net/manual/en/function.xml-parse-into-struct.php