【发布时间】:2017-03-27 11:52:12
【问题描述】:
我正在使用 PHP 密码和用户名中的 CURL 处理 SOAP 请求,但需要 API 一个额外的 ConfigurationName 文件,我在 Header 中添加了这个,但响应显示错误
身份验证失败
以下是我的标头代码,请检查:
$headers=array(
"Content-type:text/xml;charset=\"utf-8\"",
"Accept:text/xml",
"Cache-Control:no-cache",
"Pragma:no-cache",
"SOAPAction:\"actionurl\"",
"Content-length:".strlen($xml_post_string),
"ConfigurationName: ConfigurationName",
);
$url=$soapUrl;
$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,$soapUser.":".$soapPassword);//usernameandpassword-declaredatthetopofthedoc
curl_setopt($ch,CURLOPT_HTTPAUTH,CURLAUTH_ANY);
curl_setopt($ch,CURLOPT_TIMEOUT,100);
curl_setopt($ch,CURLOPT_POST,true);
curl_setopt($ch,CURLOPT_POSTFIELDS,$xml_post_string);//theSOAPrequest
curl_setopt($ch,CURLOPT_HTTPHEADER,$headers);
请帮助我如何在标题中添加 ConfigurationName 的这个额外值。
【问题讨论】:
-
您是否尝试将其作为 post 参数发送?
-
你的意思是在 $xml_post_string 中?
-
我建议你使用 SoapClient :php.net/manual/en/class.soapclient.php
-
是的......但我猜 ConfigurationName 所以我猜它不会工作
-
在 Postman 中工作正常