NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Trouble on helloWorld web service using WSDL


Joined: 30 Dec 2009
Posts: 1
Reply with quote
hello everyone!

i d like to begin with a helloWorld web service using nuSOAP 1.85 library WSDL and php 5.1.4.
i also use the SWSAPI class (webservice.php) as a wrapper class.

When i run the client i get the following message:
Fatal error: Call to a member function on a non-object in C:\Program Files\Computer Solutions\InnoController\www\WebServices\ch5\soap\nusoap\helloWorld_client_wsdl.php on line 11

i wonder if the problem concerns nusoap library and php version.
But i tried with PHP 4 too and i get the same message.
When i debug nusoap.php file, i get a warning like this:
"Assigning the return value of new by reference is deprecated"

Could anyone please help me to find the error?
Thank you!


This is the wrapper class

Code:

<?php
//webservice.php -  Wrapper Class

error_reporting(E_ALL ^ E_NOTICE);
define('SOAP_IMP', 'NuSOAP');
if (SOAP_IMP=='NuSOAP'){
   
   require_once('http://localhost:85/WebServices/ch5/soap/nusoap/lib/nusoap.php');
   require_once('lib/nusoap.php');
}
   else if (SOAP_IMP=='PEAR:SOAP'){
      require_once("SOAP/Client.php");
   }
   else {
      die ('Constant SOAP_IMP not defined or not recognized');
   }
   
   
class WebService {
   //Service Proxy parses the wsdl and returns a new instance of class
   //for that wsdl.
   
   function &ServiceProxy($wsdl_fname)
   {
      if (SOAP_IMP=='NuSOAP'){
         $soapclient=new [b]nusoapclient[/b]($wsdl_fname,'wsdl');
         $soap_proxy=$soapclient->getProxy();
         return($soap_proxy);
      }else{
         if (extension_loaded('overload')){
            return new SOAP_Client($wsdl_fname,1);
         }else {
            $wsdl=new SOAP_WSDL($wsdl_fname);
            if ($wsdl->fault){
               echo $wsdl->fault->toString();
               return NULL;
            }
            $class =$wsdl->generateProxyCode();
            eval($class);
            return new $wsdl->service;
         }
      }
   }
}
?>




This is the Server impl (nusoap_hello_server.php)

Code:

<?php
require_once('lib/nusoap.php');
$server=new soap_server();
$server->register('helloWorld');
function helloWorld($message)
{
   if ($message=='')
   {  return new soap_fault('12345', 'client', 'You must supply a valid string');}
   else {return "hello $message!";}
}
$server->service($HTTP_RAW_POST_DATA);
exit();
?>



This is the client impl(helloWorld_client_wsdl.php)

Code:

<?php
//include the SWSAPI
require_once('webservice.php');

//Instantiate an object from HelloWorld.wsdl
$HelloService=WebService::ServiceProxy("http://localhost:85/WebServices/ch5/soap/nusoap/HelloWorld.wsdl");

//perform the helloworld operation
$result=$HelloService->helloWorld('World');

print $result;
?>




and the WSDL file..(HelloWorld.wsdl)

Code:

<? xml version="1.0" encoding="UTF-8"?>
<definitions name="HelloWorld"

targetNamespace="http://localhost:85/WebServices/ch5/soap/nusoap/"

<message name="HelloRequest">
<part name="message" type="xsd:string"/>
</message>

<message name="HelloResponse">
<part name="noname" type="xsd:string"/>
</message>

<portType name="HelloWorldPortType">
<operation name="helloWorld">
<input message="typens:HelloRequest"/>
<output message="typens:HelloResponse"/>
</operation>
</portType>


<binding name="HelloWorldBinding" type="typens:HelloWorldPortType">
<soap:binding style="rpc"
   transport ="http://schemas.xmlsoap.org/soap/http"/>
 <operation name="helloWorld">
 <soap:operation soapAction="http://localhost:85/WebServices/ch5/soap/nusoap"/>
 <input>
 <soap:body
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="http://localhost:85/WebServices/ch5/soap/nusoap/"
    use="encoded"/>
 </input>
 
 <output>
 <soap:body
    encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
    namespace="http://localhost:85/WebServices/ch5/soap/nusoap/"
    use="encoded"/>
 </output>
 </operation>
 </binding>
 
 
 <service name="HelloWorldService">
 <documentation>A hello Service</documentation>
 <port binding="typens:HelloWorldBinding" name="HelloWorldPort">
 <soap:address location="http://localhost:85/WebServices/ch5/soap/nusoap/nusoap_hello_server.php"/>
 </port>
 </service>
 </definitions>
 
[/b][/quote]
View user's profileFind all posts by bolvSend private message
Trouble on helloWorld web service using WSDL
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic