Advertisement
Guest User

Untitled

a guest
Mar 24th, 2017
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.65 KB | None | 0 0
  1. $XMLRequest = <<<XMLSCR
  2. <?xml version="1.0" encoding="UTF-8"?>
  3. <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">
  4. <soap12:Header>
  5. <AuthenticationHeader xmlns="http://gso.com/GsoShipWS">
  6. <UserName>username</UserName>
  7. <Password>password</Password>
  8. </AuthenticationHeader>
  9. </soap12:Header>
  10. <soap12:Body>
  11. <GetServiceTypes xmlns="http://gso.com/GsoShipWS">
  12. <GetServiceTypesRequest>
  13. <AccountNumber>12345</AccountNumber>
  14. </GetServiceTypesRequest>
  15. </GetServiceTypes>
  16. </soap12:Body>
  17. </soap12:Envelope>
  18. XMLSCR;
  19.  
  20. I've also try with passing array
  21.  
  22. $xml_array = array(
  23. 'GetServiceTypesRequest' => array(
  24. 'AccountNumber' => 12345,
  25. )
  26. );
  27.  
  28. $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
  29. <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">
  30. <soap12:Header>
  31. <AuthenticationHeader xmlns="http://gso.com/GsoShipWS">
  32. <UserName>username</UserName>
  33. <Password>password</Password>
  34. </AuthenticationHeader>
  35. </soap12:Header>
  36. <soap12:Body>
  37. <GetServiceTypes xmlns="http://gso.com/GsoShipWS">
  38. <GetServiceTypesRequest>
  39. <AccountNumber>12345</AccountNumber>
  40. </GetServiceTypesRequest>
  41. </GetServiceTypes>
  42. </soap12:Body>
  43. </soap12:Envelope>';
  44.  
  45. // data from the form, e.g. some ID number
  46.  
  47.  
  48.  
  49. $headers = array(
  50. "POST /GSOShipWS1.0/GSOShipWS.asmx HTTP/1.1",
  51. "Host: wsa.gso.com",
  52. "Content-Type: application/soap+xml; charset=utf-8",
  53. "Content-length: ".strlen($xml_post_string),
  54. ); //SOAPAction: your op URL
  55.  
  56. $url = $soapUrl;
  57.  
  58. // PHP cURL for https connection with auth
  59. $ch = curl_init();
  60. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
  61. curl_setopt($ch, CURLOPT_URL, $url);
  62. //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  63. curl_setopt($ch, CURLOPT_USERPWD, username.":".password); // username and password - declared at the top of the doc
  64. curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
  65. curl_setopt($ch, CURLOPT_TIMEOUT, 10);
  66. curl_setopt($ch, CURLOPT_POST, true);
  67. curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
  68. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  69.  
  70. // converting
  71. $response = curl_exec($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement