Google Groups Home
Help | Sign in
Message from discussion Object Casting in PHP
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
Joel  
View profile
 More options Apr 16, 11:15 am
From: Joel <joel...@gmail.com>
Date: Wed, 16 Apr 2008 08:15:37 -0700 (PDT)
Local: Wed, Apr 16 2008 11:15 am
Subject: Re: Object Casting in PHP
Webservices & objects are a little bit complicated in PHP 4 (since
you're using nuSOAP vs the native phpsoap library, i assume you're on
v4).

Essentially, when you're transferring data to and from a webservice,
the data is serialized. If you have a WSDL definition file, the web
service can also describe how to reconstruct the data on the other
side. Int, strings etc are easy to pass. More complex data types (such
as arrays) require a bit more work on the definition file. Thus, for
objects,  it's even more work.

Did you try serializing your object on the webservice and returning a
string, then reconstruct the object using unserialize?

On Apr 16, 9:07 am, Dave Naimish <davenaim...@gmail.com> wrote:

> Hi,

> I am newbie and recently I started working on PHP.

> Problem description:

> I have one class called Employee and it has one property called
> Salary. I am developing a web service using nuSOAP libarary which will
> expose a method to get employee details, i.e. GetEmployeeDetails. This
> web method should return object of Employee type.

> Now my first query is that how to return customized type using nuSOAP
> library?

> my code for consuming web service is like this,
> <?php
> require_once ('lib/nusoap.php');
> require ('Employee.php');

>     $client = new nusoap_client('http://localhost:5050/Projects/
> empPayroll/WebService.php');

>     $emp = new Employee();

>     $param = array('name' => 'employee name');

>     $emp = $client->call('GetEmployeeDetails', $param);

>     echo $message->Salary();
> ?>

> When I execute above file in browser it returns following error:
> Fatal error: Call to a member function Salary() on a non-object in D:
> \Program Files\wamp\www\Projects\empPayroll\index.php on line 17

> My assumption is that when I say
>   $emp = $client->call('GetEmployeeDetails', $param);
> it actually creates a new "emp" variable instead of retaining it as
> Employee type of object.

> AND THIS IS GETTING NIGHTMARE FOR ME :(

> Let me know if anyone of you have any solution for above problem.

> Regards,

> Dave Naimish


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2008 Google