在PHP中的SOAP标头中创建函数时遇到问题

时间:2018-11-28 20:45:47

标签: php soap

我正在尝试使用网络表单在ServiceNow中创建事件。 ServiceNow API使用具有用户名,密码和apikey的基本身份验证。

身份验证始终失败,因为无法正确识别apikey。当使用Boomerang这样的SOAPClient时,它可以工作,但是我只是无法在php中正确获取它。

以下信息在Boomerang的标题中(效果很好):

Authorization - Basic SU5UU0RQTVI6TWFudWZhY3R1cmluZ1czYmYwcm0=

Content-Type - text/xml; charset=utf-8

SOAPAction - http://www.service-now.com/hlr_incident_api/createIncident

Api-Key - 97c97bd4-5226-43c4-9909-adee8332d1e0

我正在使用的代码(总是失败)如下:

    $wsdl ='sns.wsdl';
$client = new SoapClient($wsdl, array('login' => 'USER',
                                      'password' => 'PASSWORD',
                                      'soap_version' => SOAP_1_2));

$ns = 'http://www.service-now.com/hlr_incident_api';    
$header = new SoapHeader($ns, '97c97bd4-5226-43c4-9909-adee8332d1e0');
$client->__setSoapHeaders($header);

您能帮我在php中设置正确的SOAP标头吗?

非常感谢您!

0 个答案:

没有答案