简体   繁体   中英

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 . 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:

$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.

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

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.

Click "http log" in the bottom panel of SoapUI to see the whole communication. Look thoroughly for Header ithems.

If any header ithems, they must be set before your function SOAP call in PHP, but after you've constructed the client.

Use __ setSoapHeaders() to set headers in PHP

I was also getting that security error.

I used the soapui tool as well. But i had better success with the Chrome App called Boomerang.

You need to choose WSS PasswordText under Auth and then everything just seems to work.

Then you can even copy the xml that Boomerang generates into PHP and it works as well.

在此处输入图片说明

在此处输入图片说明

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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