Advertisement
Guest User

Untitled

a guest
Feb 24th, 2017
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. $wsdl = "http://cnx.test.dat.com:9280/wsdl/TfmiFreightMatching.wsdl";
  2.  
  3. $client = new SoapClient($wsdl, array('trace' => true));
  4. $params = array('loginOperation'=>array('loginId'=>'ryder_cnx1','password'=>'ryder1','thirdPartyId'=>'dl'));
  5.  
  6. $client->Login($params);
  7.  
  8. $data = $client->__getLastResponse();
  9.  
  10. $p = xml_parser_create();
  11. xml_parse_into_struct($p, $data, $vals, $index);
  12. xml_parser_free($p);
  13.  
  14. $token = [];
  15.  
  16. foreach ($vals as $key => $value) {
  17. foreach ($value as $key1 => $value1) {
  18. if($key1 == "value")
  19. $token[] = $value1;
  20. }
  21. }
  22.  
  23. echo "Primary Token = ".$token[0];
  24. echo "<br> Secondary Token = ".$token[1];
  25. //echo "<br> Expiry Date = ".$token[2];
  26.  
  27. $params_session = array("sessionToken"=> array("primary"=>$token[0], "secondary"=>$token[1]));
  28.  
  29. $namespace = 'http://www.tcore.com/TcoreTypes.xsd'; // I am not sure about this namespace. Whether its correct or not.
  30.  
  31. $header = new SoapHeader($namespace,'sessionHeader',$params_session,true);
  32. $client->__setSoapHeaders($header);
  33.  
  34. $params_data = array('lookupRateOperations'=> array(
  35. 'equipment'=>'Vans',
  36. 'origin'=>array('postalCode'=>array('country'=>'US','code'=>'30004')),
  37. 'destination'=>array('postalCode'=>array('country'=>'US','code'=>'10001'))
  38. ));
  39.  
  40. try{
  41. $result = $client->LookupRate($params_data);
  42.  
  43. print_r($result);
  44.  
  45. }catch (SoapFault $exception){
  46. //or any other handling you like
  47. print_r(get_class($exception));
  48. enter code hereprint_r($exception);
  49. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement