Phil Jones Phil Jones - 5 years ago 177
PHP Question

PHP to WebService

I want to connect to a webservice.

I have the following code to test connecting to the service;

$soapURL = 'http://xxx.xxx.xx.xx4/wsdl/wsdl' ;
$soapParameters = Array('login' => "xxx", 'password' => "1234") ;
$client = new SoapClient($soapURL, $soapParameters);
var_dump($client->__getFunctions());


Which works fine and give me back the following;

array(6) {
[0]=> string(35) "CallResponse Call(Call $parameters)"
[1]=> string(59) "FieldManagerResponse FieldManager(FieldManager $parameters)"
[2]=> string(56) "FixScheduleResponse FixSchedule(FixSchedule $parameters)"
[3]=> string(44) "GeocodeResponse Geocode(Geocode $parameters)"
[4]=> string(59) "ShowCallInfoResponse ShowCallInfo(ShowCallInfo $parameters)"
[5]=> string(59) "WorkScheduleResponse WorkSchedule(WorkSchedule $parameters)"
}


I want to call the ShowCallinfo function which has 2 parameters, an integer 0, and a string 'CA12345' - and should return a set of data;

Latest combination I have tried (immediately after the other code) are;

$result = $client->ShowCallInfo(0,'CA212345');


Which results in a SoapFault exception: [HTTP] Not Found in

Answer Source

The SoapFault you're facing is not due to the parameters but due to the fact that the SoapAction address is not reachable from your network or is simply invalid.

  • You should first check the url in <soap:address location="{url}" /> in the WSDL and ensure that it is reachable,
  • You should then use a WSDL to php generator that will ease you the task of sending the request. Indeed you won't have to wonder about soap as you'll only deal with objects or at least you'll know exactly how to send the parameters. I can only advise you to try the PackageGenerator as it's mine but you can find other project of this type out there
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download