我有一个PHP SoapClient PHP,我正在努力工作。 SoapClient验证并且可以获取WSDL,没问题。然后我需要使用WSDL作为端点启动soapAction,但是标头与我需要匹配的演示请求标头不匹配。
具体来说,我缺少soapAction标头,而是在内容类型中设置了一个动作参数。我该如何更改?
我想要生成的标题:
2016-04-01 11:16:30.745:[11878][TEST][wait|hold|name(0x03154246) 101ms]
我正在生成的标题:
value1: 2016-04-01 11:16:30.745
value2: 0x03154246
value3: 101
我通过以下php代码调用此操作:
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)
答案 0 :(得分:1)
我发现这就是这条线:
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
我将其更改为 $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));
,现在正按预期生成soapAction。