I am pulling my hair out. I have tried many different ways, but nothing works:
<?php
// Proxy is for Fiddler
$soap = new soapClient( 'http://testi.lemonsoft.eu:22000/CTP/lemonweb/userservices.svc?wsdl', array(
'proxy_host' => 'localhost',
'proxy_port' => '8888'
));
try {
$test = new stdClass();
$test->UserName = "foo";
$test->Password = "bar";
$test->CompanyDatabase = "baz";
// This should work:
print_r($soap->LogIn($test));
/** The rest are alternative experiments, no avail: **/
print_r($soap->LogIn(array($test)));
print_r($soap->LogIn(array('parameters' => $test)));
print_r($soap->login(array(
'UserName' => 'foo',
'Password' =>'bar',
'CompanyDatabase' => 'baz'
)));
print_r($soap->__soapCall('LogIn', array('parameters' => $test)));
print_r($soap->__soapCall('LogIn', array('parameters' => array(
'UserName' => 'foo',
'Password' =>'bar',
'CompanyDatabase' => 'baz'
))));
print_r($soap->LogIn(new SoapParam($test, "LogIn")));
print_r($soap->LogIn(new SoapParam(array(
'UserName' => 'foo',
'Password' =>'bar',
'CompanyDatabase' => 'baz'
), "LogIn")));
print_r($soap->__soapCall('LogIn', array('parameters' => array(
new SoapParam(array(
'UserName' => 'foo',
'Password' =>'bar',
'CompanyDatabase' => 'baz'
), "LogIn")
))));
} catch (SoapFault $fault) {
print_r($fault);
}
?>
I captured the requests with fiddler and the response always looks like this:
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://tempuri.org/">
<SOAP-ENV:Body>
<ns1:LogIn/>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
as if the LogIn parameters are never sent. Does the empty ns1:LogIn tag really mean that? Can there be some instance inbetween, which I can not control, for some reason stripping the parameters? According to my understanding the method LogIn takes one parameter, which, according to the documentation, should be a PHP stdClass.
Try this:
class LogInInfo{
public $UserName = '1';
public $Password = '2';
public $CompanyDatabase = '3';
}
ini_set('display_error', 1);
error_reporting(E_ALL);
$client = new SoapClient('http://testi.lemonsoft.eu:22000/CTP/LemonWeb/UserServices.svc?singleWsdl', array(
'classmap'=>array('LogInInfo'=>'LogInInfo'),
'debug'=>true,
'trace'=>true
));
try {
$info = new LogInInfo();
$resp = $client->LogIn($info);
} catch(Exception $e) {
var_dump($e);
}
print_r($client->__getLastRequest());
Result:
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.datacontract.org/2004/07/Lemonsoft.LemonsoftServiceLibrary.User" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns2="http://tempuri.org/">
<SOAP-ENV:Body>
<ns2:LogIn xsi:type="ns1:LogInInfo">
<ns1:CompanyDatabase>3</ns1:CompanyDatabase>
<ns1:Password>2</ns1:Password>
<ns1:UserName>1</ns1:UserName>
</ns2:LogIn>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
Can you show content of the WSDL file?
ns1:LogIn tag means that method LogIn is from ns1 namespace (defined above).
The only way I manage to pass the params in SOAP request from PHP is like this:
// __setSoapHeaders here
$listCriteriaXML = '<List xmlns="LINKHERE">
<listCriteria>
<ListCriterion>
<Name>DateNeeded</Name>
<SingleValue>' . date("Y-m-d", strtotime("+120 days")) . '</SingleValue>
</ListCriterion>
<ListCriterion>
<Name>limitresults</Name>
<SingleValue>false</SingleValue>
</ListCriterion>
</listCriteria>
</List>';
$listCriteria = new SoapVar($listCriteriaXML, XSD_ANYXML);
$response = $client->List($listCriteria);
echo $client->__getLastRequest();
Related
How I can do below soap request in php,
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:v="http://incometaxindiaefiling.gov.in/ditws/TaxCredMismatch/v_1_0">
<soapenv:Header/>
<soapenv:Body>
<v:getTaxCredMismatchRequest>
<LoginInfo>
<userName>XXXXXXXXXX</userName>
<password>XXXXXXXXXX</password>
</LoginInfo>
<UserInput>
<panNo>XXXXXXXXXX</panNo>
<asseessmentyear>XXXX-XX</asseessmentyear>
</UserInput>
</v:getTaxCredMismatchRequest>
</soapenv:Body>
</soapenv:Envelope>
I tried below code,
<?php
$url = "https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/getTaxCredMismatchRequest.wsdl";
try {
$options = array(
'soap_version'=>SOAP_1_1,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient($url,$options);
$requestParams = array(
'userName' => 'AJAPA5855E',
'password' => 'pass123',
'panNo' => 'AJAPA5855E',
'asseessmentyear' => '2014-15'
);
$response = $client->__soapCall("getTaxCredMisMatch", array($requestParams));
var_dump($response);
} catch (Exception $e) {
echo $e->getMessage();
}
?>
but getting the response as
SOAP-ERROR: Encoding: object has no 'LoginInfo' property
I know, I'm sending the parameter in correct way, may I know how to correct it.
I never used that soap client, but I would expect this:
<?php
$url = "https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/getTaxCredMismatchRequest.wsdl";
try {
$options = array(
'soap_version'=>SOAP_1_1,
'exceptions'=>true,
'trace'=>1,
'cache_wsdl'=>WSDL_CACHE_NONE
);
$client = new SoapClient($url,$options);
$requestParams = array(
'LoginInfo' => array (
'userName' => 'AJAPA5855E',
'password' => 'pass123',
),
'UserInput' => array (
'panNo' => 'AJAPA5855E',
'asseessmentyear' => '2014-15'
)
);
$response = $client->__soapCall("getTaxCredMisMatch", array($requestParams));
var_dump($response);
} catch (Exception $e) {
echo $e->getMessage();
}
?>
However as said above, this is just a wild guess. It certainly would make sense to take a look at the documentation of that extension: http://php.net/manual/en/class.soapclient.php. Such things should be explained in there...
Using the WSDL from https://incometaxindiaefiling.gov.in/e-FilingWS/ditws/getTaxCredMismatchRequest.wsdl, you could generate the corresponding package from wsdltophp.com in order to be sure on how to structure your request in PHP as every element will be a PHP object with setters/getters. It uses the native PHP SoapClient class so you'll understand easily and quickly who to send these requests if you're familiar with PHP
I'm trying to make a SOAP request using PHP and I don't seem to be able to seperate my parameters I need to send with the call. I can use the service through out a SOAP testing tool, and the snippet I'm using there is (with ccn3 and ccn2 removed):
<?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>
<tns:GetUser>
<tns:auth>
<ccn3:Username>testuser</ccn3:Username>
<ccn3:Password>testpass</ccn3:Password>
<ccn3:AuthID>55125621</ccn3:AuthID>
</tns:auth>
<tns:user>
<ccn2:Address>Testvägen 1</ccn2:Address>
<ccn2:CustNo/>
<ccn2:FirstName/>
<ccn2:LastName/>
<ccn2:SSN>1234567890</ccn2:SSN>
</tns:user>
</tns:GetUser>
</soap:Body>
</soap:Envelope>
This do work and gives the desired answer from the service. But when connecting to it through php it doesn't. The php code I'm currently using looks like this:
<?php
$username = "testuser";
$password = "testpass";
$authID = 55125621;
$client = new SoapClient("https://url/service.svc?wsdl");
$param = array(
'Username'=>$username,
'Password'=>$password,
'AuthID'=>$AuthID,
'Address'=>'Testvägen 1',
'SSN'=>'1234567890',
'FistName'=>'',
'LastName'=>''
);
$res = $client->GetUser($param);
echo "<pre>";
print_r($res);
echo "</pre>";
?>
In my XML query I'm using two "groups" of parameters. I send auth data towards my ccn3 (tns:auth) and my data to ccn2 (tns:user). I'm guessing that's my problem, but how do I do this seperation in php?
Try this:
$params = array(
'auth' => array(
'Username' => $username,
'Password' => $password,
'AuthID' => $AuthID,
),
'user' => array(
'Address' => 'Testvägen 1',
'SSN' => '1234567890',
'FistName' => '',
'LastName' => ''
));
$res = $client->GetUser($params);
I am using PHP SoapClient in WSDL mode.
This is what the expected SOAP request should look like:
<soapenv:Envelope
xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns="http://xml.m4u.com.au/2009">
<soapenv:Header/>
<soapenv:Body>
<ns:sendMessages>
<ns:authentication>
<ns:userId>Username</ns:userId>
<ns:password>Password</ns:password>
</ns:authentication>
<ns:requestBody>
<ns:messages>
<ns:message>
<ns:recipients>
<ns:recipient>61400000001</ns:recipient>
</ns:recipients>
<ns:content>Message Content</ns:content>
</ns:message>
</ns:messages>
</ns:requestBody>
</ns:sendMessages>
</soapenv:Body>
</soapenv:Envelope>
And this is what PHP SoapClient is sending:
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:ns1="http://xml.m4u.com.au/2009">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<ns1:sendMessages>
<ns1:authentication>
<userId>Username</userId>
<password>Password</password>
</ns1:authentication>
<ns1:requestBody>
<messages>
<message>
<recipients>
<recipient>61400000001</recipient>
</recipients>
<content>Message Content</content>
</message>
</messages>
</ns1:requestBody>
</ns1:sendMessages>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>
This is how I constructed the client and params:
function sendMessages($recipient, $content) {
$authenticationType = new SoapVar(array('userId' => $this->username, 'password' => $this->password), SOAP_ENC_OBJECT);
$recipientsType = new SoapVar(array('recipient' => $recipient), SOAP_ENC_OBJECT);
$messageType = new SoapVar(array('recipients' => $recipientsType, 'content' => $content), SOAP_ENC_OBJECT);
$messagesType = new SoapVar(array('message' => $messageType), SOAP_ENC_OBJECT);
$requestBodyType = new SoapVar(array('messages' => $messagesType), SOAP_ENC_OBJECT);
$params = array(
'authentication' => $authenticationType,
'requestBody' => $requestBodyType
);
try {
$this->soapClient = new SoapClient($this->wsdl, array('trace' => 1));
$this->soapClient->__setSoapHeaders(array());
return $this->soapClient->sendMessages($params);
} catch (SoapFault $fault) {
echo '<h2>Request</h2><pre>' . htmlspecialchars($this->soapClient->__getLastRequest(), ENT_QUOTES) . '</pre>';
trigger_error("SOAP Fault: (faultcode: {$fault->faultcode}, faultstring: {$fault->faultstring})", E_USER_ERROR);
}
}
Why is 'ns1' present for 'authentication' and 'requestBody' but missing for their child nodes?
What am I doing wrong? The WSDL is located here => http://soap.m4u.com.au/?wsdl
Appreciate anyone who can help.
You must specify the URI of the namespace to encode the object. This will include everything necessary (including your missing namespace). The acronym of the namespace name is irrelevant.
This:
$authenticationType = new SoapVar(array('userId' => $this->username, 'password' => $this->password), SOAP_ENC_OBJECT);
should be:
$authenticationType = new SoapVar(array('userId' => $this->username, 'password' => $this->password), SOAP_ENC_OBJECT, "authentication","http://xml.m4u.com.au/2009");
The problem you're seeing with the namespace serialization comes from using soapvar without all the parameters. When it serializes the request prior to sending it assumes the namespace is already included. If, instead, you had created each as a simple array and included them in $params it would include the namespace for the internal parameters correctly. By way of demonstration:
$authenticationType = array('userId' => $this->username, 'password' => $this->password)
try using nusoap library. Below is sample code:
<?php
$wsdl = "http://soap.m4u.com.au/?wsdl";
// generate request veriables
$data = array();
$action = ""; // ws action
$param = ""; //parameters
$options = array(
'location' => 'http://soap.m4u.com.au',
'uri' => ''
);
// eof generate request veriables
//$client = new soap_client($wsdl, $options);// create soap client
$client = new nusoap_client($wsdl, 'wsdl');
$client->setCredentials($api_username, $api_password);// set crendencials
$opt = $client->call($action, $param, '', '', false, true);
print_r($opt);
?>
There a Webservice on my server written in php that update a customer in an Acomba table. The service update correctly the customer but when i receive the response the webpage crash because the xml is not properly closed. I call the Webservice with ajax.
I didn't wrote either the call or the webservice but i have to fix it...
Logged error:
SoapFault exception: [Client] looks like we got no XML document in C:\inetpub\wwwroot\eureka\ajax\syncContratAvenant.php:85
Stack trace:
C:\inetpub\wwwroot\eureka\ajax\syncContratAvenant.php(85): SoapClient->__soapCall('saveClientAvena...', Array)
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:SOAP_AvenantAcomba" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:saveClientAvenant><param0 xsi:type="ns2:Map"><item><key xsi:type="xsd:string">noContrat</key><value xsi:type="xsd:string">FP00000000</value></item>
<item><key xsi:type="xsd:string">acombaUidClient</key><value xsi:type="xsd:string">945</value></item><item><key xsi:type="xsd:string">name</key><value xsi:type="xsd:string">Test</value></item><item><key xsi:type="xsd:string">institution</key><value xsi:type="xsd:string">000</value></item><item><key xsi:type="xsd:string">folio</key><value xsi:type="xsd:string">000000</value></item><item><key xsi:type="xsd:string">transit</key><value xsi:type="xsd:string">00000</value></item><item><key xsi:type="xsd:string">zip</key><value xsi:type="xsd:string">XXX XXX</value></item><item><key xsi:type="xsd:string">adress</key><value xsi:type="xsd:string">2 testtown</value></item><item><key xsi:type="xsd:string">phone</key><value xsi:type="xsd:string"></value></item><item><key xsi:type="xsd:string">city</key><value xsi:type="xsd:string">Test</value></item></param0></ns1:saveClientAvenant>
</SOAP-ENV:Body></SOAP-ENV:Envelope>
<?xml version="1.0" encoding="UTF-8"?>
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="urn:SOAP_AvenantAcomba" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:ns2="http://xml.apache.org/xml-soap" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Body><ns1:saveClientAvenantResponse><return xsi:type="ns2:Map"><item><key xsi:type="xsd:string">reponse</key><value xsi:type="xsd:boolean">true</value></item><item><key xsi:type="xsd:string">errorMessage</key><value xsi:type="xsd:string"></value></item></return></ns1:saveClientAvenantResponse>
</SOAP-ENV:Body></SOAP-ENV:Envelop
Notice how the envelope is not properly closed there... don't know why through....
The call :
$client = new SoapClient(null, array('location' => ACOMBA_WEB_SERVICE_Avenant,
'uri' => "urn:SOAP_AvenantAcomba",
'trace' => 1,
'encoding' => 'ISO-8859-1'));
$info = array($arraySOAP => array(
'noContrat' => getNoContratTxt($contract->getCols('noContract')),
'acombaUidClient' => $contract->getCols('acombaUidClient'),
'name' => $contract->getCols('name') ,
'institution' => $contract->getCols('noInstitution'),
'folio' => $contract->getCols('noFolio'),
'transit' => $contract->getCols('noTransit'),
'zip' => makeSQasDQ($contract->getCols('zipAddAssurer')),
'adress' => makeSQasDQ(utf8_decode($contract->getCols('noAddAssurer') . ' ' . $contract->getCols('streetAddAssurer'))),
'phone' => '',
'city' => makeSQasDQ(utf8_decode($contract->getCols('townAddAssurer'))))
);
$resultClient = $client->__soapCall('saveClientAvenant', $info); // crash here
The service :
<?php
require_once('variables.php');
set_time_limit(900);
function saveClientAvenant($arraySOAP){
$conn = odbc_connect(ACOMBA_DRIVER, ACOMBA_USER, base64_decode(ACOMBA_PASS));
if (odbc_commit($conn)) {
try {
$nxtContrat = $arraySOAP['noContrat'];
$nom = $arraySOAP['name'];
$noInstitution = $arraySOAP['institution'];
$noFolio = $arraySOAP['folio'];
$noTransit = $arraySOAP['transit'];
$zipCode = $arraySOAP['zip'];
$adress = $arraySOAP['adress'];
$phone = $arraySOAP['phone'];
$city = $arraySOAP['city'];
$acombaUidClient = $arraySOAP['acombaUidClient'];
$sqlQuery = "UPDATE " . TABLE_ACOMBA_CLIENT . "
SET
CuSortKey = '$nom',
CuName = '$nom',
CuAddress = '$adress',
CuCity = '$city',
CuPostalCode = '$zipCode',
CuPhoneNumber1 = '$phone',
CuInstitutionNumber = '$noInstitution',
CuBranchNumber = '$noTransit',
CuAccountNumber = '$noFolio'
WHERE
CuUnique = $acombaUidClient
";
if (!odbc_exec($conn, $sqlQuery)) {
throw new Exception($sqlQuery . odbc_errormsg());
}
} catch (Exception $e) {
return array('reponse' => false,
'errorMessage' => $e->getMessage() );
}
odbc_close($conn);
return array('reponse' => true,
'errorMessage' => '' );
}
}
$server = new SOAPServer(null, array('uri' => 'urn:SOAP_AvenantAcomba',
'encoding' => 'ISO-8859-1'));
$server->addFunction('saveClientAvenant');
$HTTP_RAW_POST_DATA = file_get_contents('php://input');
$server->handle();
?>
Have you tried changing:
'encoding' => 'ISO-8859-1'
to:
'encoding'=>'UTF-8'
?
I would expect a slightly different content length with those, which is what i see as your issue.
I have experienced the same issue with invalid SOAP XML, specifically it missing </SOAP-ENV:Envelope missing its closing > when our server has been using Brotli compression to compress the XML, for some reason Brotli and Soap don't work well together.
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));