Hi all, I am trying to get a grisp on the soap/php subject. I have read some articles and now I have tried the following (php4 and nusoap.php) <?php include('nusoap.php'); $client = new SoapClient("http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl"); echo("\nReturning value of getTemp() call: ".$client->getTemp("12345")); ?> Code (markup): But I get an error message: Fatal error: Call to undefined function: gettemp() But gettemp is a operation node??? Anyone knows how I can fix this or anyone knows another simple example??
You are not calling service in a right way try following code <?php include('nusoap.php'); $client = new SoapClient("http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl"); echo("\nReturning value of getTemp() call: ".$client->call("getTemp", "12345")); ?> PHP: I am assuming that function you want to call from wsdl is getTemp() Hope it helps.
Operations are not called in they way you are calling, i.e. $client->myMethod("parameters"); Because myMethod is not a member function of object client so it will give error "Call to undefined function:" Instead you can call it as, $client->call("myMethod", "parameters");
@designcode, Tx for your answer and explanation. Unfortunatly it didn't fix my problem. Let me explain, I am trying to recreate the following http://www.herongyang.com/php/php_soap.html -> the "GetTemp.php - First Example with SOAP" part, but in my case with php4 and nusoap.php. code sofar include('nusoap.php'); $client = new SoapClient("http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl", 'wsdl'); echo "\nReturning value of getTemp() call: ".$client->call("getTemp", "12345"); Code (markup): which gives me so I print_r and now I get So gettemp isn't found, but in http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl I can see Just started learning SOAP ( I am doing all of this to learn a bit more about webservices as I am about to make use of a service.asmx for a project). ps: do you have a simple working code example for me to look at and learn??
hmm, tx to another forum I do have the same output as the example url // include class include("nusoap.php"); // create a instance of the SOAP client object $soapclient = new soapclient("http://www.xmethods.net/sd/2001/DemoTemperatureService.wsdl",true); // set up an array containing input parameters to be // passed to the remote procedure $params = array('zipcode' => 12345); // invoke the method $result = $soapclient->call('getTemp',$params); // print the results of the search print_r($result); die(); PHP: Only how do you know 12345 is a zipcode??? The $params part is a bit unclear to me. Ok I know getTemp is a function and $params are the params for this function. But how do I check which params can be used??
Ok, check developer section of my website, you will surely find some some basic help from there. http://www.tutorialsgarden.com/developers/ See Ready Made App and Available Services sections
Listen, see the following part of WSDL <operation name="getTemp"> <input message="tns:getTempRequest"/> <output message="tns:getTempResponse"/> </operation> Code (markup): <input> is the basically the parameters of function and <output> is the value returned by service. No look at the message attribute of input, If its tns:something, then try to find "something" in the WSDL, and the parameters you will pass will be array, like $client->call("myFunc", array("param1"=>"abcd")); Code (markup): and message attribute is xsd:something, then you will have to send a single parameter, like $client->call("myFunc","abcd"); Code (markup):
@designcode, tx for your answers I see the zipcode part now and tns <-> xsd is array vs single parameter I am reading your tutorialsgarden.com/developers/docs/rateTutorial/ as the request and response looks like the webservice I need to use. Great site you have there!
Thanks mate for liking my website, if my post helped you please add it to my reputation and feel free to post your questions if you have problems/queries with webservices. Enjoy