Tiger API Soap request. Highly confusing - php

I'm at the beginning of setting up the Tiger Air API. They have given few URLs for testing but these doesn't seem to work. Following are the details I received from them
Contact mail:
For testing, we have linked this account to your
xxxxxx agency in TEST (currency SGD).
Username: xxx
P/W: xxx (password will have to be changed on first login)
Domain: xxx
RoleCode: xxx
The URL’s for the API to test for connectivity are as follows:
Test: https://trtestr3xapi.navitaire.com/sessionmanager.svc
For the access to the various services, you will want to make your calls to the following DNS:
Test: https://trtestr3xapi.navitaire.com
SOAP sample request
The above two URLs don't seem to work at all. Its surprising that they did not provide the WSDL url. I have got the sample request from them.
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:web="http://schemas.navitaire.com/WebServices"
xmlns:ses="http://schemas.navitaire.com/WebServices/ServiceContracts/SessionService"
xmlns:ses1="http://schemas.navitaire.com/WebServices/DataContracts/Session"
>
<soapenv:Header>
<web:ContractVersion>320</web:ContractVersion>
</soapenv:Header>
<soapenv:Body>
<ses:LogonRequest>
<!--Optional:-->
<ses:logonRequestData>
<!--Optional:-->
<ses1:DomainCode>EXT</ses1:DomainCode>
<!--Optional:-->
<ses1:AgentName>MyAgent</ses1:AgentName>
<!--Optional:-->
<ses1:Password>P#ssword</ses1:Password>
<!--Optional:-->
<ses1:LocationCode></ses1:LocationCode>
<!--Optional:-->
<ses1:RoleCode></ses1:RoleCode>
<!--Optional:-->
<ses1:TerminalInfo></ses1:TerminalInfo>
</ses:logonRequestData>
</ses:LogonRequest>
</soapenv:Body>
</soapenv:Envelope>
I was struggling for a long time trying to figure out the basic setup but going into a loop.

your server ip need to be allowed for requests on this link
<?
$Username = 'xxx';
$Password: 'xxx';
$Domain: 'xxx';
$url = "https://trtestr3xapi.navitaire.com/SessionManager.svc?wsdl";
$client = new SoapClient($url);
$params = array(
'logonRequestData' => array(
'DomainCode' => $Domain,
'AgentName' => $Username,
'Password' => $Password,
)
);
print_r($client->Logon($params));
?>
another useful code
<?
$url = "https://trtestr3xapi.navitaire.com/SessionManager.svc?wsdl";
$client = new SoapClient($url);
print_r($client->__getFunctions());
print_r($client->__getTypes());
?>
and
<?
$url = "https://trtestr3xapi.navitaire.com/BookingManager.svc?wsdl";
$client = new SoapClient($url);
print_r($client->__getFunctions());
print_r($client->__getTypes());
?>

Related

Interacting with a soap API without WSDL in PHP

Recently got access to a soap API for a hotel management service. They have provided documentation which shows a basic example of a request:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<Auth xmlns="http://xxxx/xxxxAPI">
<FromSystemId ID="1">CompanyName</FromSystemId>
<UserName>username</UserName>
<Password>password</Password>
</Auth>
</soapenv:Header>
<soapenv:Body>
<GetRegions Timestamp="2016-04-11" Version="1.0" Lang="en"
xmlns="http://xxxx/xxxxAPI">
<Country Code="GB" />
</GetRegions>
</soapenv:Body>
</soapenv:Envelope>
They have also provided a list of functions in their documentation and the parameters required for each of the functions. But i am abit confused on how to perform a request as i have never used a soap API before. They also haven't provided a WSDL, does this matter?
Anyway, here is how i thought to try and perform a request
$soapURL = "http://xxxx/xxxxAPI" ;
$soapParameters = Array('login' => "username", 'password' => "password") ;
$soapFunction = "getRegions";
$soapFunctionParameters = Array('countrycode' => 'GB');
$soapClient = new SoapClient($soapURL, $soapParameters);
$soapResult = $soapClient->__soapCall($soapFunction,
$soapFunctionParameters) ;
if(is_array($soapResult) && isset($soapResult['someFunctionResult'])) {
// Process result.
} else {
// Unexpected result
if(function_exists("debug_message")) {
debug_message("Unexpected soapResult for {$soapFunction}: ".print_r($soapResult, TRUE)) ;
}
}
Am i going about this the right way? i am unable to test this right now as i haven't received my authentication but wanted to make a start on it now.
Any help would be great.
Here is a small example.
$opts = array(
'location' => 'http://xxxx/xxxxAPI',
'uri' => 'urn:http://test-uri/'
);
$client = new SOAPClient(null, $opts);
$headerData = array(
'FromSystemId' => 'CompanyName',
'UserName' => 'username',
'Password' => 'password',
);
// Create Soap Header.
$header = new SOAPHeader('http://xxxx/xxxxAPI', 'Auth', $headerData);
// Set the Headers of Soap Client.
$client->__setSoapHeaders($header);
$result = $client->__soapCall('getRegions', array('GB'));
// $return = $client->__soapCall('getRegions', array(new SoapParam(new SoapVar('GB', XSD_STRING), 'countryCode')));
var_dump($result);
They also haven't provided a WSDL, does this matter?
To be able to add the HEADER attributes they must be mentioned in WSDL. If they not exist in WSDL they WILL NOT appear as attributes but rather <item><key/><value/></item> elements.
Tipp: If you know how the request has to be and you have no WSDL, then try to generate the HTTP header and XML body manually and execute the request with CURL or Guzzle.
Example with Guzzle:
$soapContent = '<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header>
<Auth xmlns="http://xxxx/xxxxAPI">
<FromSystemId ID="1">CompanyName</FromSystemId>
<UserName>username</UserName>
<Password>password</Password>
</Auth>
</soapenv:Header>
<soapenv:Body>
<GetRegions Timestamp="2016-04-11" Version="1.0" Lang="en"
xmlns="http://xxxx/xxxxAPI">
<Country Code="GB" />
</GetRegions>
</soapenv:Body>
</soapenv:Envelope>';
$client = new GuzzleHttp\Client([
'headers' => [ 'SOAPAction' => '"urn:http://xxxx/xxxxAPI/#getRegions"' ]
]);
$response = $client->post('http://xxxx/xxxxAPI',
['body' => $soapContent]
);
echo $response;

SOAP envelope with header authentication call php

I have to consume a webservice, but can't find a proper way to create the call.
This is the xml the company provide as example
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:Qpay.POS.Gateway.ServiceContracts" xmlns:urn1="urn:Qpay.POS.Gateway.DataContracts">
<soapenv:Header/>
<soapenv:Body>
<urn:GetProvidersRequest>
<!--Optional:-->
<urn:Header>
<urn1:CertPublicKey>XX-XX-XX-XX-XX</urn1:CertPublicKey>
<!--Optional:-->
<urn1:UIID>XX</urn1:UIID>
<urn1:User>XXXX</urn1:User>
</urn:Header>
</urn:GetProvidersRequest>
</soapenv:Body>
</soapenv:Envelope>
Tried using this:
$soapURL = "https://pos.qpay123.biz/dBar/Gateway.svc?" ;
$soapParameters = Array('UIID' => "63", 'User' => "System") ;
$soapFunction = "GetProvidersRequest" ;
$soapClient = new SoapClient($soapURL, $soapParameters);
$soapResult = $soapClient->__soapCall($soapFunction) ;
var_dump($soapResult);
But i get a false as var dump, can you point me on the right direction to solve it?
Thanks

How can I create PHP SOAP request to call web service implemented in ColdFusion

I have implemented web service in ColdFusion. I am trying to call that webservice using php. But getting errors.
Can someone help me to prepare SAOP request in php? xml request is below in SOAP UI.
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://localhost:8501/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:ASK soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<AgentID> 1 </AgentID>
<Passwd> 12345 </Passwd>
<TransactionNumber >XXX </TransactionNumber >
<Sign >XXX </Sign >
</soapenv:Body>
</soapenv:Envelope>
I have used below code in php
$soapUrl = "http://domain.com/webservice/transaction.cfc?WSDL"; // asmx URL of WSDL
$xml_post_string = '<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://localhost:8501/webservice">
<soapenv:Header/>
<soapenv:Body>
<web:ASK soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"/>
<AgentID> 1 </AgentID>
<Passwd> 12345 </Passwd>
<TransactionNumber >XXX </TransactionNumber >
<Sign >XXX </Sign >
</soapenv:Body>
</soapenv:Envelope>';
$xml_array['AgentID'] = '1';
$xml_array['Passwd'] = "12345";
$xml_array['TransactionNumber'] = "XXX";
$client = new SoapClient($soapUrl, array( 'soap_version'=>SOAP_1_1, 'trace'=>1));
$xml= $client-> ASK($xml_array,$soapUrl,"POST",0);
(OR)
$xml= $client-> ASK($xml_post_string ,$soapUrl,"POST",0);
print "<pre>";
print_r($xml);
print "</pre>";
?>
Returns below error in both case
Fatal error: Uncaught SoapFault exception: [Server.userException] No such operation 'ASK' in C:\xampp\htdocs\webservice\

Send soap xml data in php

Please how can I send the following xml to a remote webservice(**/quick.svc?wsdl) using soap in php
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:quic="http://services.interswitchng.com/quicktellerservice/">
<soapenv:Header/>
<soapenv:Body>
<quic:SendBillPaymentAdvice>
<!--Optional:-->
<quic:xmlParams>
<![CDATA[<BillPaymentAdvice>
<Amount>10000</Amount>
<PaymentCode>145536</PaymentCode>
<CustomerMobile>0856534</CustomerMobile>
<CustomerEmail>luvysols#gmail.com</CustomerEmail>
<CustomerId>Trdfg001</CustomerId>
<TerminalId>2323001</TerminalId>
<RequestReference>123456789</RequestReference>
</BillPaymentAdvice>]]>
</quic:xmlParams>
</quic:SendBillPaymentAdvice>
</soapenv:Body>
</soapenv:Envelope>
The SoapClient class provides a client for SOAP 1.1, SOAP 1.2 servers. It can be used in WSDL or non-WSDL mode.
$url = "";
$client = new SoapClient($url, array("trace" => 1, "exception" => 0));
Ref: http://php.net/manual/en/class.soapclient.php
First Include the nusoap.php and after it add this code.
$sen_code='XML CODE';
$client->debug($headers,$sen_code);
$client->decode_utf8 = FALSE;
$rel_lgoin = $client->call('method_for_call');

Create this SOAP XML request with PHP's SOAP extension

I'm trying to recreate this XML request using PHP's SOAP extension and having trouble doing it:
<?xml version="1.0"?>
<soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://services.web.stormpost.skylist.com">
<soapenv:Header>
<authInfo xmlns:soap="http://skylist.com/services/SoapRequestProcessor" xsi:type="soap:authentication">
<!--You may enter the following 2 items in any order-->
<username xsi:type="xsd:string">****#example.com</username>
<password xsi:type="xsd:string">*******</password>
</authInfo>
</soapenv:Header>
<soapenv:Body>
<ser:doImportFromTemplate soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<impTempId xsi:type="xsd:int">7</impTempId>
<data xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xsi:type="soapenc:string">
Joe|Doe|joe#example.com John|Doe|john#example.com </data>
</ser:doImportFromTemplate>
</soapenv:Body>
</soapenv:Envelope>
Here is my testing code so far:
// set connection params
$wsdl = 'http://api.stormpost.datranmedia.com/services/SoapRequestProcessor?wsdl';
$namespace = 'https://api.stormpost.datranmedia.com/services/SoapRequestProcessor';
$credentials = (object)array(
'username' => '****#example.com',
'password' => '*******'
);
$auth_values = new SoapVar($credentials, SOAP_ENC_OBJECT);
$header = new SoapHeader($namespace, "authInfo", $auth_values);
// set client, headers, and call function
$client = new SoapClient($wsdl, array('trace' => true));
$client->__setSoapHeaders(array($header));
$client->__soapCall("doImportFromTemplate", array(7, 'Joe|Doe|joe#example.com John|Doe|john#example.com'));
It doesn't seem to be implementing the authInfo node correctly with the xsi:type="soap:authentication" among other things. How should I change my code to output this XML? I'm having trouble finding good implementation examples.
I struggled with the php SOAP client myself a while ago, i didn't really got a full understanding but this worked for me:
$auth_values = array('username' => '****#example.com', 'password' => '*******');
$header = new SoapHeader($namespace, "authInfo", $auth_values, false);
// set client, headers, and call function
$client = new SoapClient($wsdl, array('trace' => true));
$client->__setSoapHeaders(array($header));

Categories