Making the SoapHeader for DHL - php

I'm trying to make a soapHeader with nested parameters as it shown in an example from dhl developer portal:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:cis="http://dhl.de/webservice/cisbase"
xmlns:bcs="http://dhl.de/webservices/businesscustomershipping"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Header>
<cis:Authentification>
<cis:user>2222222222_01</cis:user>
<cis:signature>pass</cis:signature>
</cis:Authentification>
</soap:Header>
The way I do the header:
class DhlSoapClient {
public $apiUrl = 'https://cig.dhl.de/cig-wsdls/com/dpdhl/wsdl/geschaeftskundenversand-api/1.0/geschaeftskundenversand-api-1.0.wsdl';
public $dhlSandboxUrl = 'https://cig.dhl.de/services/sandbox/soap';
public $soapClient;
public $credentials;
public function buildClient($credentials, $sandbox = false)
{
$this->soapClient = new \SoapClient($this->apiUrl, ['trace' => 1]);
$this->credentials = $credentials;
$this->buildAuthHeader();
return $this->soapClient;
}
public function buildAuthHeader()
{
$authParams = [
'user' => $this->credentials['user'],
'signature' => $this->credentials['signature'],
'type' => 0
];
$authvalues = new \SoapVar(new \SoapVar($authParams, SOAP_ENC_OBJECT), SOAP_ENC_OBJECT);
$soapHeader = new \SoapHeader($this->dhlSandboxUrl, 'Authentification', $authvalues);
$this->soapClient->__setSoapHeaders($soapHeader);
}}
So I get this client:
object(SoapClient) {
trace => (int) 1
_soap_version => (int) 1
sdl => resource
__default_headers => [
(int) 0 => object(SoapHeader) {
namespace => 'https://cig.dhl.de/services/sandbox/soap'
name => 'Authentification'
data => object(SoapVar) {
enc_type => (int) 301
enc_value => object(SoapVar) {
enc_type => (int) 301
enc_value => [
'user' => '2222222222_01',
'signature' => 'pass'
]}}mustUnderstand => false}]}
And as a result I get this header:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://dhl.de/webservice/cisbase"
xmlns:ns2="http://de.ws.intraship"
xmlns:ns3="https://cig.dhl.de/services/sandbox/soap">
<SOAP-ENV:Header>
<ns3:Authentification>
<user>2222222222_01</user>
<signature>pass</signature>
</ns3:Authentification>
</SOAP-ENV:Header>
As I try to get $response = $this->client->CreateShipmentDD($shipmentInfo);
I get this:
object(SoapFault) {
faultstring => 'Authorization Required'
faultcode => 'HTTP'
[protected] message => 'Authorization Required'
Maybe the problem is that parameters user and signature inside Authentification have no prefix as it has to be and it cause the SoapFault exception, but they are adding automatically so I have to make kind of nested SoapHeader.

I had the same problem. The Authorization Required is for the HTTP Auth. You need to add the authorization values to the $options array in SoapClient::__construct($wsdlUri, $options).
$this->soapClient = new \SoapClient($this->apiUrl,
['trace' => 1,
'login' => <DHL_DEVELOPER_ID>,
'password' => <DHL_DEVELOPER_PASSWD>,
]
);
You can add the location to select the sandbox:
$this->soapClient = new \SoapClient($this->apiUrl,
['trace' => 1,
'login' => <DHL_DEVELOPER_ID>,
'password' => <DHL_DEVELOPER_PASSWD>,
'location' => <DHL_SANDBOX_URL>|<DHL_PRODUCTION_URL>,
'soap_version' => SOAP_1_1,
'encoding' => 'utf-8',
]
);
The DHL_DEVELOPER_ID is not a mail address. You find it in "Mein Konto" (My Account).

Related

Can't work with live model srmklive-paypal

I'm working with srmk/paypal package 1.0.
Been working with this awesome package for some months in sandbox mode, yet I've been struggling to work with live mode.
I've been all over the issues others had and elsewhere and haven't been able to find a solution for this.
If I remove sandbox credentials I get an infinite loop right after dd($response) from $response = $provider->setExpressCheckout($checkoutData);
I'm using 1.0 so ExpressCheckout should not be the problem
I've tested on live server with same results.
My config
return [
'mode' => 'live', // Can only be 'sandbox' Or 'live'. If empty or invalid, 'live' will be used.
'sandbox' => [
'username' => env('PAYPAL_SANDBOX_API_USERNAME', ''),
'password' => env('PAYPAL_SANDBOX_API_PASSWORD', ''),
'secret' => env('PAYPAL_SANDBOX_API_SECRET', ''),
'certificate' => env('PAYPAL_SANDBOX_API_CERTIFICATE', ''),
'app_id' => 'APP-80W284485P519543T', // Used for testing Adaptive Payments API in sandbox mode
],
'live' => [
'username' => env('PAYPAL_LIVE_API_USERNAME', ''),
'password' => env('PAYPAL_LIVE_API_PASSWORD', ''),
'secret' => env('PAYPAL_LIVE_API_SECRET', ''),
'certificate' => env('PAYPAL_LIVE_API_CERTIFICATE', ''),
'app_id' => '', // Used for Adaptive Payments API
],
'payment_action' => 'Sale', // Can only be 'Sale', 'Authorization' or 'Order'
'currency' => env('PAYPAL_CURRENCY', 'MXN'),
'billing_type' => 'MerchantInitiatedBilling',
'notify_url' => '', // Change this accordingly for your application.
'locale' => env('PAYPAL_LOCALE', 'es_ES'), // force gateway language i.e. it_IT, es_ES, en_US ... (for express checkout only)
'validate_ssl' => false, // Validate SSL when creating api client.
];
env and env.example
#PayPal Setting & API Credentials - sandbox
PAYPAL_SANDBOX_API_USERNAME=sb-tr4z02598960_api1.business.example.com
PAYPAL_SANDBOX_API_PASSWORD=VSYUE32AU7MT7VY4
PAYPAL_SANDBOX_API_SECRET=ACdNh.ieqXXfGzIFBkj6F-fUdA49AIBmvpyOyz5MhLCsLyQVdcB74zVJ
PAYPAL_SANDBOX_API_CERTIFICATE=
#PayPal Setting & API Credentials - live
PAYPAL_LIVE_API_USERNAME=********************api1.gmail.com
PAYPAL_LIVE_API_PASSWORD=**********************K9W
PAYPAL_LIVE_API_SECRET=******************************FCBABE
PAYPAL_LIVE_API_CERTIFICATE= storage_path('cert_key_pem.txt'); // also tested empty
I use the new API credentials provided by PayPal
public function getExpressCheckout ($orderId) {
$checkoutData = $this->checkoutData($orderId);
$provider = new ExpressCheckout();
$response = $provider->setExpressCheckout($checkoutData);
dd($response);
return redirect($response['paypal_link']);
}
private function checkoutData($orderId)
{
$cart = \Cart::getContent();
$cart2 = \Cart::getTotal();
$cartItems = array_map( function($item){
return [
'name' => $item['name'],
'price' => $item['price'],
'qty' => $item['quantity']
];
}, $cart->toarray());
$checkoutData = [
'items' => $cartItems,
'return_url' => route('paypal.success', $orderId),
'cancel_url' => route('paypal.cancel'),
'invoice_id' => uniqid(),
'invoice_description' => 'order description',
'total' => $cart2
];
return $checkoutData;
}
public function getExpressCheckoutSuccess(Request $request, $orderId)
{
$token = $request->get('token');
$payerId = $request->get('PayerID');
$provider = new ExpressCheckout();
$checkoutData = $this->checkoutData($orderId);
$response = $provider->getExpressCheckoutDetails($token);
if (in_array(strtoupper($response['ACK']),['SUCCESS','SUCCESSWITHWARNING'])) {
$payment_status = $provider->doExpressCheckoutPayment($checkoutData,$token,$payerId);
$status = $payment_status['PAYMENTINFO_0_PAYMENTSTATUS'];
if (in_array($status, ['Completed','Processed'])) {
$order = Order::find($orderId);
$order->is_paid = 1;
$order->save();
Mail::to($order->buyer_email)->send(new OrderMail($order));
\Cart::clear();
return view ('newOrder.success', compact('order'));
}
The infinite loop pops when calling this function from the package
private function doPayPalRequest($method)
{
// Setup PayPal API Request Payload
$this->createRequestPayload($method);
try {
// Perform PayPal HTTP API request.
$response = $this->makeHttpRequest();
// dd($response); // I'm stuck here
return $this->retrieveData($method, $response);
} catch (Throwable $t) {
$message = collect($t->getTrace())->implode('\n');
}
return [
'type' => 'error',
'message' => $message,
];
}
Thanks all,

How to pass xsi type of parameter in PHP SoapClient

I am trying to consume soapclient based API of https://developer.signicat.com/documentation/signing/get-started-with-signing/full-flow-example/
There are tow methods of it
1- you have to upload a document and it returns you an SDS ID, this part works fine
2- then you need to use this SDS ID in second part of API to create a sign request method name is createRequest(),
This is where I am getting problem, I have passed all the parameters but still getting an error on one parameter which is xsi:type I am not sure how to pass this parameter from php array.
Here is the sample XML
<document xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" ref-sds-id="090520195vbxk9uuw4dks9tjm2pmpy7sx3na397xz6qclxtepaslnb00q7" send-to-archive="false" xsi:type="sds-document">
<sign-text-entry/>
<description>Loan contract.pdf</description>
</document>
here xsi:type="sds-document" this part is causing the issue
My Code:
$url = 'https://preprod.signicat.com/ws/documentservice-v3?wsdl';
$soap_setting = array(
"trace" => 1,
'features' => SOAP_SINGLE_ELEMENT_ARRAYS + SOAP_USE_XSI_ARRAY_TYPE
);
$client = new SoapClient($url,$soap_setting);
$subject_type = $client->__getTypes();
$functions = $client->__getFunctions();
$subject = array(
'national-id'=> '198003010306',
'first-name' => 'Oskar',
'last-name' => 'Johansson',
'email' => 'kamran#creativerays.com'
);
$notification = array(
'recipient' => 'http://localhost/sign/php/',
'type' => 'URL',
'message' => 'Please seign ${taskUrl}',
'header'=> 'Test',
'notification-id' => '001'
);
$sdsdocument = array(
'ref-sds-id' => '100520193oz5vev0onyueul43ury4vz8g1hsnhr7w69pcwnoan96ojbtbb',
'send-to-archive' => true,
'description'=> 'test',
'sign-text-entry'=> 'test',
'xsi:type' => 'sds-document'
);
$documentaction = array(
'document'=> $sdsdocument,
'type'=> 'sign',
'optional'=> true,
'send-result-to-archive'=> true
);
$tasks = array(
'subject'=> $subject,
'document-action'=> $documentaction,
'notification'=> $notification,
'on-task-postpone'=> 'http://localhost/sign/php/?requestId=${requestId}&taskId=${taskId}&status=taskpostponed',
'on-task-complete'=> 'http://localhost/sign/php/?requestId=${requestId}&taskId=${taskId}&status=taskcomplete',
'on-task-cancel'=> 'http://localhost/sign/php/?requestId=${requestId}&taskId=${taskId}&status=taskcancelled',
'configuration'=> 'default',
'signature' =>array('method'=>'nbid-sign'),
'id'=> 'task00001',
'bundle'=> False
);
$request = array(
'language'=> 'en',
'task'=> $tasks
);
$tparam = array(
'service'=>'demo',
'password'=>'Bond007',
'request' =>$request
);
$create = $client->createRequest($tparam);
echo '<pre>';
print_r($create);
echo $client->__getLastRequestHeaders();
echo '</pre>';
The Error I am getting:
Fatal error: Uncaught SoapFault exception: [soap:Client] Failed to register new document action request: Document with id null must have subtype archive-document, sds-document, result-document, upload-document or provided-document

Delete hosted zone resource record set with PHP on amazon

I can't figure out how to delete hosted zone resource record set with Amazon PHP sdk.
So my code is following
public function __construct(\ConsoleOutput $stdout = null, \ConsoleOutput $stderr = null, \ConsoleInput $stdin = null) {
parent::__construct($stdout, $stderr, $stdin);
/** #var \Aws\Route53\Route53Client route53Client */
$this->route53Client = Route53Client::factory([
'version' => '2013-04-01',
'region' => 'eu-west-1',
'credentials' => [
'key' => <my-key>,
'secret' => <my-secret-key>
]
]);
}
And this is my function for deleting resource record set
private function deleteResourceRecordSet() {
$response = $this->route53Client->changeResourceRecordSets([
'ChangeBatch' => [
'Changes' => [
[
'Action' => 'DELETE',
'ResourceRecordSet' => [
'Name' => 'pm-bounces.subdomain.myDomain.com.',
'Region' => 'eu-west-1',
'Type' => 'CNAME',
],
]
]
],
'HostedZoneId' => '/hostedzone/<myHostedZoneId>'
]);
var_dump($response);
die();
}
And the error I'm keep getting is
Error executing "ChangeResourceRecordSets" on "https://route53.amazonaws.com/2013-04-01/hostedzone/<myHostedZoneId>/rrset/"; AWS HTTP error: Client error: `POST https://route53.amazonaws.com/2013-04-01/hostedzone/<myHostedZoneId>/rrset/` resulted in a `400 Bad Request` response:
<?xml version="1.0"?>
<ErrorResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><Error><Type>Sender</Type><Co (truncated...)
InvalidInput (client): Invalid request: Expected exactly one of [AliasTarget, all of [TTL, and ResourceRecords], or TrafficPolicyInstanceId], but found none in Change with [Action=DELETE, Name=pm-bounces.subdomain.myDomain.com., Type=CNAME, SetIdentifier=null] - <?xml version="1.0"?>
<ErrorResponse xmlns="https://route53.amazonaws.com/doc/2013-04-01/"><Error><Type>Sender</Type><Code>InvalidInput</Code><Message>Invalid request: Expected exactly one of [AliasTarget, all of [TTL, and ResourceRecords], or TrafficPolicyInstanceId], but found none in Change with [Action=DELETE, Name=pm-bounces.subdomain.myDomain.com., Type=CNAME, SetIdentifier=null]</Message>
So what exactly is minimum required set of params so I will be available to delete resource record from hosted zone? If you need any additional informations, please let me know and I will provide. Thank you
Ok I have figure it out. If you wan't to delete resource record set from hosted zones, then the code/function for deleting record set should look like following
private function deleteResourceRecordSet($zoneId, $name, $ResourceRecordsValue, $recordType, $ttl) {
$response = $this->route53Client->changeResourceRecordSets([
'ChangeBatch' => [
'Changes' => [
[
'Action' => 'DELETE',
"ResourceRecordSet" => [
'Name' => $name,
'Type' => $recordType,
'TTL' => $ttl,
'ResourceRecords' => [
$ResourceRecordsValue // should be reference array of all resource records set
]
]
]
]
],
'HostedZoneId' => $zoneId
]);
}

SOAP-ERROR: Encoding: object has no 'FinalBookingDate' property

Before starting, I know, this errors means that I should have defined the property FinalBookingDate, but just keep reading and you will understand my point of view.
The url is: http://bestbuyhotel1.cangooroo.net/ws/2013/ClientBackOffice_b.asmx?op=getBookingList
I was testing first with SoapUi, and I successfull get the list that I need:
And on php, I only can get this response:
The SoapClient from php is:
$params = array('soap_version' => SOAP_1_2, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'encoding'=>'UTF-8', 'trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new \SoapClient('http://bestbuyhotel1.cangooroo.net/ws/2013/ClientBackOffice_b.asmx?wsdl', $params);
And then, the code to retrieve the data:
/*
$query = array(
'InitialServiceDate' => '2015-01-20',
'InitialBookingDate' => '2015-01-20',
'FinalBookingDate' => '2015-01-20',
'FinalServiceDate' => '2015-01-20',
'CreationUserId' => 1338,
'CityId' => 4166,
'ServiceTypes' => array('eServiceType' => 'HOTEL')
);
*/
$query = array(
'InitialBookingDate' => '2015-01-20',
'ServiceTypes' => array('eServiceType' => 'HOTEL')
);
$args = new \stdClass;
$args->credential = new \stdClass;
$args->credential->UserName = $conn['userPass']['usr'];
$args->credential->Password = $conn['userPass']['pass'];
$args->searchBookingCriteria = new \stdClass;
$args->searchBookingCriteria->InitialBookingDate = '2015-01-20';
$args->searchBookingCriteria->ServiceTypes = new \stdClass;
$args->searchBookingCriteria->ServiceTypes->eServiceType = 'HOTEL';
//$args = array('credential'=>$credentials, 'searchBookingCriteria' => $query);
$data = $conn['client']->getBookingList($args);
print_r($data);
exit;
As you can see, I tried 2 ways to send the $args to getBookingList, as far I know both of then is valid and yet both of then (with array or object) return the same error. On the code commented at first you can see that I tried to define all does properties that the web service asks but after defining all of then I get a empty result.
My question is, there is some extra param to define on SoapClient that I should do? Why the SoapUI can do it with success? What I have missing here?
Bonus: A print of SoapUI full screen with the default request including the optional params https://www.evernote.com/shard/s14/sh/fb5ac276-8147-4e09-95bb-afa0be66d7a6/d273441c74186bf1e600b42ab3303899/deep/0/SoapUI-5.0.0.png
Can you try this more direct approach:
try {
$params = array('soap_version' => SOAP_1_2, 'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP, 'encoding'=>'UTF-8', 'trace' => 1, 'exceptions' => true, 'cache_wsdl' => WSDL_CACHE_NONE, 'features' => SOAP_SINGLE_ELEMENT_ARRAYS);
$client = new SoapClient('http://bestbuyhotel1.cangooroo.net/ws/2013/ClientBackOffice_b.asmx?wsdl',$params);
} catch (SoapFault $E) {
echo $E->faultstring;
}
if ($client) {
$req_params = array('credential' =>
array('userName' => 'XXXXXXX',
'Password' => 'XXXXXXX'),
'searchBookingCriteria' =>
array('BookingNumber' => array('int' => 'XXXXXXXXX'),
'ServiceTypes' => array('eServiceType' => 'HOTEL'),
'PassengerName'=> 'XXXXXXXX',
'InitialBookingDate'=> '2015-01-16',
'FinalBookingDate'=> '2015-01-16',
'InitialServiceDate' => '2015-01-18',
'FinalServiceDate' => '2015-01-18',
'BookingStatus'=> array('eStatus' => 'ACTIVATED'),
'PaymentStatus'=> array('ePaymentStatus' => 'Payed'),
'CreationUserId'=> 'XXX',
'CityId'=> 'XXXX',
'ExternalReference'=> '')
);
$response = $client->__soapCall('getBookingList',array($req_params));
var_dump($response);
}
Try (and add) this approach:
$args->searchBookingCriteria->FinalBookingDate = '2015-01-22';
$args->searchBookingCriteria->InitialServiceDate = '2015-01-22';
$args->searchBookingCriteria->FinalServiceDate = '2015-01-22';
$args->searchBookingCriteria->CreationUserId = 'abc';
$args->searchBookingCriteria->CityId = 'abc';

Need help sending SOAP request to Estes

I need to send a SOAP request to Estes to retrieve rate quotes. I'm having trouble doing this as the other APIs I have worked with either post the XML or use a URL string. This is a bit different for me.
I believe my problem is that I cannot figure out the array that needs to be sent for the request.
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:rat="http://ws.estesexpress.com/ratequote" xmlns:rat1="http://ws.estesexpress.com/schema/2012/12/ratequote">
<soapenv:Header>
<rat:auth>
<rat:user>XXXXX</rat:user>
<rat:password>XXXX</rat:password>
</rat:auth>
</soapenv:Header>
<soapenv:Body>
<rat1:rateRequest>
<rat1:requestID>XXXXXX</rat1:requestID>
<rat1:account>XXXXXXX</rat1:account>
<rat1:originPoint>
<rat1:countryCode>XX</rat1:countryCode>
<rat1:postalCode>XXXXX</rat1:postalCode>
<rat1:city>XXXXXX</rat1:city>
<rat1:stateProvince>XX</rat1:stateProvince>
</rat1:originPoint>
<rat1:destinationPoint>
<rat1:countryCode>XX</rat1:countryCode>
<rat1:postalCode>XXXXX</rat1:postalCode>
</rat1:destinationPoint>
<rat1:payor>X</rat1:payor>
<rat1:terms>XX</rat1:terms>
<rat1:stackable>X</rat1:stackable>
<rat1:baseCommodities>
<rat1:commodity>
<rat1:class>X</rat1:class>
<rat1:weight>XXX</rat1:weight>
</rat1:commodity>
</rat1:baseCommodities>
</rat1:rateRequest>
</soapenv:Body>
</soapenv:Envelope>
This was the code I was using before and it is not working.
<?php
$client = new SoapClient("https://www.estes-express.com/rating/ratequote/services/RateQuoteService?wsdl");
$request_object = array(
"header"=>array(
"auth"=>array(
"user"=>"XXXXX",
"password"=>"XXXXX",
)
),
"rateRequest"=>array(
"requestID"=>"XXXXXXXXXXXXXXX",
"account"=>"XXXXXX",
),
"originPoint"=>array(
"countryCode"=>"XX",
"postalCode"=>"XXXXX",
"city"=>"XXXXX",
"stateProvince"=>"XX",
),
"destinationPoint"=>array(
"countryCode"=>"XX",
"postalCode"=>"XXXXX",
),
"payor"=> "X",
"terms"=> "XXXX",
"stackable"=> "X",
"baseCommodities"=>array(
"commodity"=>array(
"class"=>"XX",
"weight"=>"XXXX",
)
),
);
$result = $client->rateRequest(array("request"=>$request_object));
var_dump($result);
?>
Here is the error
Fatal error: Uncaught SoapFault exception: [Client] Function ("rateRequest") is not a valid method for this service in /home/content/54/11307354/html/test/new/estes.php:36
Stack trace: #0 /home/content/54/11307354/html/test/new/estes.php(36): SoapClient->__call('rateRequest', Array) #1 /home/content/54/11307354/html/test/new/estes.php(36):
SoapClient->rateRequest(Array) #2 {main} thrown in /home/content/54/11307354/html/test/new/estes.php on line 36
This is my $params array that is passed to the Estes API
$params = array(
"requestID" => "xxxxxxxx",
"account" => "xxxxxxxx",
"originPoint" => array('countryCode' => 'US', 'postalCode' => $fromzip),
"destinationPoint" => array('countryCode' => 'US', 'postalCode' => $shipzip),
"payor" => 'T',
"terms" => 'PPD',
"stackable" => 'N',
"baseCommodities" => array('commodity' => $comArray ),
"accessorials" => array('accessorialCode' => $accArray)
If there are no accessorials, that array needs to be deleted from the $params array
);
// remove accessorials entry if no accessorial codes
if(sizeof($accArray) == 0){
$params = array_slice($params, 0, 8); // remove accesorials entry
}
THis is how I build the commodities array from a class array & a weight
array:
// load the $params commodities array
$comArray = array();
for ($i=0; $i<count($class_tbl); $i++) {
$comArray[] = array('class'=>$class_tbl[$i], 'weight'=>$weight_tbl[$i]);
}
The following code formats the accessorials array
if($inside == "Yes") {
$accArray[$i] = "INS";
++$i;
}
if($liftgate == "Yes") {
$accArray[$i] = "LGATE";
++$i;
}
if($call == "Yes") {
$accArray[$i] = "NCM";
++$i;
}
The Estes destination accessorial code also should be added to the $accArray array if delivery is to other than a business (for instance school. church, etc.)
See if anything in our soap call helps. We are doing the soap call like this:
// define transaction arrays
$url = "http://www.estes-express.com/rating/ratequote/services/RateQuoteService?wsdl";
$username = 'xxxxxxxx';
$password = 'xxxxxxxx';
// setting a connection timeout of five seconds
$client = new SoapClient($url, array("trace" => true,
"exceptions" => true,
"connection_timeout" => 5,
"features" => SOAP_WAIT_ONE_WAY_CALLS,
"cache_wsdl" => WSDL_CACHE_NONE));
$old = ini_get('default_socket_timeout');
ini_set('default_socket_timeout', 5);
//Prepare SoapHeader parameters
$cred = array(
'user' => $username,
'password' => $password
);
$header = new SoapHeader('http://ws.estesexpress.com/ratequote', 'auth', $cred);
$client->__setSoapHeaders($header);
$params = array(
"requestID" => "xxxxxxxx",
"account" => "xxxxxxxx",
"originPoint" => array('countryCode' => 'US', 'postalCode' => $fromzip),
"destinationPoint" => array('countryCode' => 'US', 'postalCode' => $shipzip),
"payor" => 'T',
"terms" => 'PPD',
"stackable" => 'N',
"baseCommodities" => array('commodity' => $comArray ),
"accessorials" => array('accessorialCode' => $accArray)
);
// remove accessorials entry if no accessorial codes
if(count($accArray) == 0){
$params = array_slice($params, 0, 8); // remove accesorials entry
}
// call Estes API and catch any errors
try {
$reply = $client->getQuote($params);
}
catch(SoapFault $e){
// handle issues returned by the web service
//echo "Estes soap fault<br>" . $e . "<br>";
$edit_error_msg = "Estes quote API timed out or failed to return a quote";
return "0.00";
}
catch(Exception $e){
// handle PHP issues with the request
//echo "PHP soap exception<br>" . $e . "<br>";
$edit_error_msg = "Estes quote API timed out or failed to return a quote";
return "0.00";
}
unset($client);
ini_set('default_socket_timeout', $old);
// print_r($reply);
Looking up the WSDL with a validator it looks like the two methods available are echo and getQuote.
Looking at the WSDL itself you can see that too:
<wsdl:operation name="getQuote">
<wsdl:input name="rateRequest" message="tns:rateRequestMsg"></wsdl:input>
<wsdl:output name="quoteInfo" message="tns:rateQuoteMsg"></wsdl:output>
<wsdl:fault name="schemaErrorMessage" message="tns:schemaErrorMsg"></wsdl:fault>
<wsdl:fault name="generalErrorMessage" message="tns:generalErrorMsg"></wsdl:fault>
</wsdl:operation>
Try calling getQuote instead of rateRequest.
$result = $client->__soapCall('getQuote', array("request"=>$request_object));

Categories