简体   繁体   English

如何在PHP中传递SOAP请求属性(如SoapUI中所示)

[英]How to pass SOAP Request Properties in PHP (as shown in SoapUI)

In SOAP UI I am able to pass a few request properties, specifically Username , Password and WSS-Password Type . 在SOAP UI中,我可以传递一些请求属性,特别是UsernamePasswordWSS-Password Type They are marked in the screenshot below by a red box: 它们在下面的屏幕快照中用红色框标记:

标记了SOAP UI的屏幕截图

I've tried passing these values in PHP as the second parameter of the SoapClient function like so: 我试过像这样在PHP中将这些值作为SoapClient函数的第二个参数传递:

$soap = new SoapClient('https://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl',
        array("Username" => "blah@example.com",
              "Password" => "notarealpassword",
              "WSS-Password Type" => "PasswordText"));

But I get the security error: An error occurred when verifying security for the message. 但是我收到了安全性错误: An error occurred when verifying security for the message.

The WSDL I'm calling itself is here, though my question is about passing the request properties this way in general , really: https://rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc?wsdl 我自称的WSDL在这里, 尽管我的问题是通常以这种方式传递请求属性 ,实际上是: https : //rev-int.api.us.fleetmatics.com/Vehicle/SageQuest/VehicleService.svc? wsdl

It is likely that a security header with username and password is sent along with the message itself, but you can not see this header in the normal window in SoapUI. 带有用户名和密码的安全标头很可能与消息本身一起发送,但是您无法在SoapUI的普通窗口中看到此标头。

Click "http log" in the bottom panel of SoapUI to see the whole communication. 单击SoapUI底部面板中的“ http日志”以查看整个通信。 Look thoroughly for Header ithems. 彻底查找Header痕迹。

If any header ithems, they must be set before your function SOAP call in PHP, but after you've constructed the client. 如果头文件散乱,则必须在PHP中的函数SOAP调用之前,但在构造客户端之后,设置它们。

Use __ setSoapHeaders() to set headers in PHP 使用__ setSoapHeaders()在PHP中设置标头

I was also getting that security error. 我也收到该安全错误。

I used the soapui tool as well. 我也使用了soapui工具。 But i had better success with the Chrome App called Boomerang. 但是我使用名为Boomerang的Chrome应用取得了更好的成功。

You need to choose WSS PasswordText under Auth and then everything just seems to work. 您需要在Auth下选择WSS PasswordText,然后一切似乎都可以正常工作。

Then you can even copy the xml that Boomerang generates into PHP and it works as well. 然后,您甚至可以将Boomerang生成的xml复制到PHP,它也可以正常工作。

在此处输入图片说明

在此处输入图片说明

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM