Reputation: 6553
I have a php SoapClient PHP that I'm trying to get working. The SoapClient authenticates and can grab the WSDL, no problem. Then I need to initiate a soapAction using the WSDL as the endpoint, but the headers do not match the demonstration request headers I'm required to match.
Specifically, I'm missing the soapAction header and instead am getting a action parameter being set inside the Content Type. How do I change this?
The headers I want to be generating:
POST /hpq/hpq-service/hpq.wsdl HTTP/1.1
Accept-Encoding: gzip,deflate
Content-Type: text/xml;charset=UTF-8
SOAPAction: "HPQMemberValidationOperation"
Authorization: Basic EEV0Y2VsbHM898Q4c2dLSjg5aEdYenBLYmQ0akhr
Content-Length: 902
Host: ****
Connection: Keep-Alive
User-Agent: Apache-HttpClient/4.1.1 (java 1.5)
The headers that I am generating:
POST /hpq/hpq-service/hpq.wsdl HTTP/1.1
Host: ***
Connection: Keep-Alive
User-Agent: PHPSoapClient
Content-Type: application/soap+xml; charset=utf-8; action="HPQMemberValidationOperation"
Content-Length: 688
Authorization: Basic EEV0Y2VsbHM898Q4c2dLSjg5aEdYenBLYmQ0akhr
And I am calling this action via the following php code:
$opts = array(
'http'=>array(
'user_agent' => 'PHPSoapClient',
'header' => "Authorization: Basic " . base64_encode("$username:$password"),
),
'ssl' => array(
'ciphers'=>'RC4-SHA',
'verify_peer'=>false,
'verify_peer_name'=>false
),
);
ini_set( "soap.wsdl_cache_enabled", "0" );
$context = stream_context_create($opts);
$params = array(
'stream_context'=>$context,
'cache_wsdl' => WSDL_CACHE_NONE,
'encoding' => 'UTF-8',
'verifypeer' => false,
'verifyhost' => false,
'soap_version' => SOAP_1_2,
'trace' => 1,
'exceptions' => 1,
'connection_timeout' => 180,
);
$client = new SoapClient(WSDL_PATH, $params);
$response = $client->__soapCall('HPQMemberValidationOperation', array($payload), array('location'=>WSDL_PATH));
Upvotes: 2
Views: 8535
Reputation: 6553
I found out that it was this line:
'soap_version' => SOAP_1_2,
I changed it to SOAP_1_1
and it's now generating the soapAction as intended.
Upvotes: 1