Rob Ganly
Rob Ganly

Reputation: 403

Consuming a webservice and changing an endpoint with SOAPCLIENT

I am consuming a third-party webservice and I'm using soapUI to test it. I was advised to load the WSDL, leave it untouchted, then change the endpoint in SOAPUI before executing the calls to the endpoints. This works fine and is behaving as I would expect it to.

I'm now trying to emulate this in PHP but I'm having problems changing the endpoint. I'm loading the WSDL into SOAPCLIENT and then using this command to change the endpoint:

$client->__setLocation($endpointURI);

However this is not acting like I'd expect it to and is giving me a "500:Internal Server Error" response when I the go to make a soap call after modifying the location/endpoint. I'm certain that all other parameters are correct and was wondering if anyone could shed some light on the issue and confirm that doing this 'set location' cmd should be the equivalent of changing the endpoint manually in SOAPUI.

Any ideas/opinions appreciated.

Upvotes: 1

Views: 9843

Answers (2)

Frug
Frug

Reputation: 458

Try calling __soapCall with the location override in there:

$result = $this->soap_client->__soapCall('whatever', ['location' => $file_location]);

I'm finding __setLocation is not working while the above workaround does.

Upvotes: 1

Ricardo Velhote
Ricardo Velhote

Reputation: 4690

While instantiating SoapClient try to add an array key named 'location' with the new endpoint.

$options = array('login' => 'x', 'password' => 'y', 'location' => $endpointURI);
$client = new SoapClient($address, $options);

Upvotes: 1

Related Questions