im trying to build a soap request for the following wsdl method= "GetData"
note that not all the values are required, i've been struggling with this for a week, any help would be very appreciated
Host: xxxxxxxxxxxxxxxx
Content-Type: text/xml; charset=utf-8
Content-Length: length
SOAPAction: "xxxxxxxxxxx"
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<GetData xmlns="xxxxxx">
<key>string</key>
<transferDef>
<Where />
<OrderBy>
<OrderByItems>
<BinaryArithmetic xsi:nil="true" />
<Categorization xsi:nil="true" />
<Function xsi:nil="true" />
<QueryField xsi:nil="true" />
<QueryForm xsi:nil="true" />
</OrderByItems>
</OrderBy>
<ProjectId>string</ProjectId>
<DbType>Production or Test</DbType>
</transferDef>
<token>
<Id>guid</Id>
<LastResponseIdReturned>long</LastResponseIdReturned>
<FirstResponseIdReturned>long</FirstResponseIdReturned>
<NumberOfResponsesReturned>long</NumberOfResponsesReturned>
<DatasetsReturned>long</DatasetsReturned>
<LastDataSet>boolean</LastDataSet>
<ProjectId>string</ProjectId>
<ChangeTrackingVersion>long</ChangeTrackingVersion>
</token>
</GetData>
</soap:Body>
</soap:Envelope>
Nowadays, the best way to consume SOAP WS in PHP is to use a WSDL to PHP such as the PackageGenerator project which will generate the classes to construct the request, then to send the request then to handle the response all that using PHP objects. The generated classes are sufficiently intuitive to construct the request. In addition, it uses composer as the autoloader.
kind of resolved the issue, the problem was with the <token></token> part.
Since it needs a value of type:guid <Id>guid</Id> that as mentioned in the wsdl and xml request, is a dataset created by a .Net library, and it's used to iterate over the samples, it's quite a complicated request, since it needs previous steps to be fulfilled, so i did the request, by omitting the <token> section
Related
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 have an issue with a SOAP request I'm sending to an external ASP Web Service. I have used both SoapUI and PHP's SoapClient class, and both times the same issue occurs - an error that tells me The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.
My Request to 'GetStudentEntitlement'
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/" xmlns:heim="http://dest.gov.au/Heims/">
<soap:Header/>
<soap:Body><adm:GetStudentEntitlement>
<heim:entitlementRequest>
<heim:RequestControlTable>
<heim:RequestId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RequestId>
<heim:ClientOrganisationCode>7591</heim:ClientOrganisationCode>
<heim:RequestLocalDateTime>2015-08-10T00:00:00</heim:RequestLocalDateTime>
</heim:RequestControlTable>
<heim:GetEntitlementIn>
<heim:RecordId>CDD1E704-1298-4D42-AAD9-0031BB90329F</heim:RecordId>
<heim:Chessn>1344</heim:Chessn>
<heim:FamilyName>Bassett</heim:FamilyName>
<heim:BirthDate>1988-05-21</heim:BirthDate>
</heim:GetEntitlementIn>
</heim:entitlementRequest>
</adm:GetStudentEntitlement>
</soap:Body>
</soap:Envelope>
The response:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<soap:Fault>
<soap:Code>
<soap:Value>soap:Sender</soap:Value>
</soap:Code>
<soap:Reason>
<soap:Text xml:lang="en">Heims.WebServices.Extensions.Exceptions.XmlSchemaValidationException: Schema validation errors
at Heims.WebServices.Extensions.SoapFilterExtension.ValidateXmlMessage(SoapMessage message, WebMethodSettings methodSettings) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 408
at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessageBeforeDeserialise(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 200
at Heims.WebServices.Extensions.SoapFilterExtension.ProcessMessage(SoapMessage message) in c:\Userdata\HEIMS.NET\Source\Development\WebService\Heims.WebService.Common\Extensions\SoapFilterExtension.cs:line 173
at System.Web.Services.Protocols.SoapMessage.RunExtensions(SoapExtension[] extensions, Boolean throwOnException)
at System.Web.Services.Protocols.SoapServerProtocol.ReadParameters()
at System.Web.Services.Protocols.WebServiceHandler.CoreProcessRequest()</soap:Text>
</soap:Reason>
<detail>
<ValidationError>
<RecordId/>
<Element>Envelope</Element>
<Line>1</Line>
<Column>2</Column>
<Description>The 'http://www.w3.org/2003/05/soap-envelope:Envelope' element is not declared.</Description>
</ValidationError>
</detail>
</soap:Fault>
</soap:Body>
</soap:Envelope>
I have tried adding and removing the trailing / on the :soap declaration, as well as trying both the 1.1 and 1.2 SOAP versions offered by this web service.
This endpoint request to 'Ping' works correctly:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:adm="http://dest.gov.au/Heims/Admin/">
<soap:Header/>
<soap:Body>
<adm:Ping/>
</soap:Body>
</soap:Envelope>
The result is returned as expected:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<soap:Body>
<PingResponse xmlns="http://dest.gov.au/Heims/Admin/">
<PingResult>Heims web services pinged. DateTime = 2015-08-10 11:11:00:05</PingResult>
</PingResponse>
</soap:Body>
</soap:Envelope>
So why would the code for one request (the ping) work perfectly, while the other request (GetStudentEntitlement) fails? Both have the soap:Envelope declaration, but the Ping request works fine.
I have also tried using xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" in the soap:Envelope element, but the error remained.
Is it possible that this is a server-side issue from the Web Service itself? Or is something simply going wrong in my code?
Answering my own question.
I contact the Government IT Assistance directly, and had them send me a code example. They were using a highly unusual and modified form of <soap wrapper, forcing me to manually generate the XML using SimpleXMLElement and submit to the Web Service using a wrapped SoapVar with the XSD_ANYXML type.
Did you get any solution to this...
I have encountered same problem today while converting UTL_DBWS utility (oracle plsql) to APEX utilities to make calls to HEIMS web service.
Ping worked but GetStudentEntitlements and AllocateStudentChessn both are failing with same envelop error.
Regards
RC
I want to read the SOAP request which is coming from a .NET WinForms application.
The request is:
<?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>
<HotelPricesRQ xmlns="http://zelsoft.ru/">
<HotelPricesRequest>
<Requestor Login="ZLS" Password="DE52F10D5089096E5D83CA559153D64824AAB0B4" />
<Conditions>
<Condition CityID="0" CountryID="0" HotelID="0" AccommodationID="0" RoomCategoryID="0" RoomTypeID="0">
<Created Begin="2013-10-31T00:00:00" End="2013-10-31T23:59:00+04:00" />
</Condition>
</Conditions>
</HotelPricesRequest>
</HotelPricesRQ>
</soap:Body>
</soap:Envelope>
So how to get the Requestor's Login, Password and the Creattion Begin Date?
I have actually build the response, we've test it and when they send me the request they got the response. I'm just sending the responce without reading the request, but I have to read it and log in diffrent users and send different response. So a real example with the request I've posted above will be much much appreciated.
I don't know why I didn't write the solution I got back then for reading the request,
but here it is, in case someone needs it:
$soap_request = file_get_contents("php://input");
Then I just parse it with the PHP XML Parser Functions like so:
$parser=xml_parser_create();
xml_parse_into_struct($parser,$soap_request,$request_array);
xml_parser_free($parser);
Now you have the data in the $request_array as an array.
You can also use The SimpleXMLElement class to get the data from the request.
It's my first time using the SOAP API by BetFair I have created one XML file and one file that will call that file. I am not understanding how can I call this and get an output. I have created the XML file below:
<?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>
<login xmlns="http://www.betfair.com/publicapi/v3/BFGlobalService/">
<request>
<locationId xmlns="">0</locationId>
<username xmlns="">usrname</username>
<password xmlns="">password</password>
<productId xmlns="">18</productId>
<vendorSoftwareId xmlns="">0</vendorSoftwareId>
</request>
</login>
</soap:Body>
</soap:Envelope>
Now to call this file I have also created one php file to do this.
BetFair has given this link for the login api: https://api.betfair.com/global/v3/BFGlobalService.wsdl
<?php
$get_data = file_get_contents("http://pixelonsell.com/dev2/betfair/login.xml");
$b = html_entity_decode($get_data);
$data= urlencode($b);
print_r($data);
$client = new SoapClient("https://api.betfair.com/global/v3/BFGlobalService.wsdl");
$result = $client->LoginReq($data);
print_r($result);
?>
I don't know why it's not working; can you help me out with this? Thank you in advance.
I would avoid using a dedicated SOAP library; in my experience they often don't work because of inconsistencies in the ways different servers implement the SOAP specification. Use a simple HTTP/HTTPS library instead, with the following headers
SOAPAction: urn:login
Content-Length: #{myContentLength}
Content-Type: text/xml
User-Agent: #{myUserAgent}
and the following payload (assuming you're using the Free API):
<SOAP-ENV:Envelope xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<SOAP-ENV:Body>
<m:login xmlns:m="https://api.betfair.com/global/v3/BFGlobalService">
<m:request>
<username>#{myUsername}</username>
<password>#{myPassword}</password>
<locationId>0</locationId>
<vendorSoftwareId>0</vendorSoftwareId>
<productId>82</productId>
</m:request>
</m:login>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
It looks to me like you're using the wrong namespace for the login element; should be 'https://api.betfair.com/..' not 'http://www.betfair.com/..'.
Good luck.
I'm a complete noob in XML and SOAP,
Could you give some advice on at least where to start, or some example?
(I'm not begging to write code for me)
Here are the specs:
I just expect to receive two double values. What is an easiest way to do it?
POST /CurrencyConvertor.asmx HTTP/1.1
Host: www.webservicex.net
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConversionRate xmlns="http://www.webserviceX.NET/">
<FromCurrency>PHP</FromCurrency>
<ToCurrency>USD or EUR</ToCurrency>
</ConversionRate>
</soap12:Body>
</soap12:Envelope>
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConversionRateResponse xmlns="http://www.webserviceX.NET/">
<ConversionRateResult>double</ConversionRateResult>
</ConversionRateResponse>
</soap12:Body>
</soap12:Envelope>
The above specs's origin: http://www.webservicex.net/CurrencyConvertor.asmx?op=ConversionRate
The first block is supposed to be a request, and the other response...
EDIT
Alright, I stopped at a standard PHP class, but I don't quite understand what is being asked for in this __doRequest method:
$client = new SoapClient();
$client->__doRequest ( <<<EOD
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConversionRate xmlns="http://www.webserviceX.NET/">
<FromCurrency>PHP</FromCurrency>
<ToCurrency>USD or EUR</ToCurrency>
</ConversionRate>
</soap12:Body>
</soap12:Envelope>
EOD
, "http://www.webservicex.net/CurrencyConvertor.asmx" , $???, $??? );
http://www.php.net/manual/en/soapclient.dorequest.php
What is action, and what should I put as version, I know - a soap version 1.2 but the parameter is int so it cannot be assigned a 1.2 value lol...
EDIT2:
Alright, this is what I've got so far, but it gets me an empty string...
$client = new SoapClient(null, array('location'=>'http://www.webservicex.net/CurrencyConvertor.asmx','uri'=>''));
$client->__doRequest ( <<<EOD
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<ConversionRate xmlns="http://www.webserviceX.NET/">
<FromCurrency>PHP</FromCurrency>
<ToCurrency>USD or EUR</ToCurrency>
</ConversionRate>
</soap12:Body>
</soap12:Envelope>
EOD
, "http://www.webservicex.net/CurrencyConvertor.asmx" , "ConversionRate", 2 );
echo "Response :<br>", htmlentities($client->__getLastResponse());
...I just dont get this 'uri' thing - beyond my understanding. It makes me want to hit my head to the wall.
Basically what you need are two parts.
A SOAPClient class, which solves the communication, knows about the server URL, sends requests and receives responses (which you got in XML in your question) and also triggers #2, which is:
The second part is an XML parser / marshaller, which can convert a request objects (containing fromCurrency and toCurrency) to a correct XML string the server can understand (according to the WSDL) and convert some XML into a response object again using the WSDL. This part is a bit tricky, but I found a lot of documentation for that, search for "SOAP PHP" and you get some examples). These two processes are called marshalling and unmarshalling (to help you find something quicker with Google). Your StockQuote webservice doesn't really provide a WSDL, which is basically a description of all possible operations (in your case just one: GetQuote) and its available objects (in your case only simple types string, which don't have to be defined, since they are WSDL standard)
I haven't done SOAP with PHP, but spent a lot of time with Java+SOAP and can understand how difficult it is. In theory you just send some XML to the server and get some XML back. But the XML sent has to be in the correct format and when you receive a response, you want to convert the response into an object and not deal with some XML string.
For a simple web service like this, you might consider constructing the XML request by hand (simply putting together the XML string) and substr the response to find the requested answer.