Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $XMLRequest = <<<XMLSCR
- <?xml version="1.0" encoding="UTF-8"?>
- <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">
- <soap12:Header>
- <AuthenticationHeader xmlns="http://gso.com/GsoShipWS">
- <UserName>username</UserName>
- <Password>password</Password>
- </AuthenticationHeader>
- </soap12:Header>
- <soap12:Body>
- <GetServiceTypes xmlns="http://gso.com/GsoShipWS">
- <GetServiceTypesRequest>
- <AccountNumber>12345</AccountNumber>
- </GetServiceTypesRequest>
- </GetServiceTypes>
- </soap12:Body>
- </soap12:Envelope>
- XMLSCR;
- I've also try with passing array
- $xml_array = array(
- 'GetServiceTypesRequest' => array(
- 'AccountNumber' => 12345,
- )
- );
- $xml_post_string = '<?xml version="1.0" encoding="utf-8"?>
- <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">
- <soap12:Header>
- <AuthenticationHeader xmlns="http://gso.com/GsoShipWS">
- <UserName>username</UserName>
- <Password>password</Password>
- </AuthenticationHeader>
- </soap12:Header>
- <soap12:Body>
- <GetServiceTypes xmlns="http://gso.com/GsoShipWS">
- <GetServiceTypesRequest>
- <AccountNumber>12345</AccountNumber>
- </GetServiceTypesRequest>
- </GetServiceTypes>
- </soap12:Body>
- </soap12:Envelope>';
- // data from the form, e.g. some ID number
- $headers = array(
- "POST /GSOShipWS1.0/GSOShipWS.asmx HTTP/1.1",
- "Host: wsa.gso.com",
- "Content-Type: application/soap+xml; charset=utf-8",
- "Content-length: ".strlen($xml_post_string),
- ); //SOAPAction: your op URL
- $url = $soapUrl;
- // PHP cURL for https connection with auth
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
- curl_setopt($ch, CURLOPT_URL, $url);
- //curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_USERPWD, username.":".password); // username and password - declared at the top of the doc
- curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
- curl_setopt($ch, CURLOPT_TIMEOUT, 10);
- curl_setopt($ch, CURLOPT_POST, true);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $xml_post_string); // the SOAP request
- curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
- // converting
- $response = curl_exec($ch);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement