Google Groups Home
Help | Sign in
Object Casting in PHP
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  5 messages - Collapse all
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
Dave Naimish  
View profile
 More options Apr 16, 11:07 am
From: Dave Naimish <davenaim...@gmail.com>
Date: Wed, 16 Apr 2008 08:07:32 -0700 (PDT)
Local: Wed, Apr 16 2008 11:07 am
Subject: Object Casting in PHP
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.
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:


    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.
Dave Naimish  
View profile
 More options Apr 16, 11:28 am
From: Dave Naimish <davenaim...@gmail.com>
Date: Wed, 16 Apr 2008 08:28:28 -0700 (PDT)
Local: Wed, Apr 16 2008 11:28 am
Subject: Re: Object Casting in PHP
Hi,

Thanks for your reply,

As I mentioned I am newbie so I would request you give little more
information on php serialization. My need is very simple that
GetEmployeeDetails method should return a object of type Employee.

Is it very complex to achieve in PHP, Is serialization only way to
resolve my problem?

BTW, I am using PHP 5.0 and nuSOAP is client's requirement.

Thanks for bearing my silly questions.

Regards,

Dave Naimish

On Apr 16, 8:15 pm, Joel <joel...@gmail.com> wrote:


    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.
Joel  
View profile
 More options Apr 16, 11:49 am
From: Joel <joel...@gmail.com>
Date: Wed, 16 Apr 2008 08:49:19 -0700 (PDT)
Local: Wed, Apr 16 2008 11:49 am
Subject: Re: Object Casting in PHP
I'd say yes, it's pretty much the way to go.

serialize and base64 encode your object on the server
http://www.php.net/serialize
http://www.php.net/base64_encode

then
on the client, decode and eval the string
http://www.php.net/base64_decode
http://www.php.net/eval

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


    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.
Dave Naimish  
View profile
 More options Apr 17, 5:20 am
From: Dave Naimish <davenaim...@gmail.com>
Date: Thu, 17 Apr 2008 02:20:13 -0700 (PDT)
Local: Thurs, Apr 17 2008 5:20 am
Subject: Re: Object Casting in PHP
Right now I am not sure what all things I will be able to do but I am
going to start.

I will let you know the update.

Thanks for your help so far.

Regards,

Dave Naimish

On Apr 16, 8:49 pm, Joel <joel...@gmail.com> wrote:


    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.
End of messages
« Back to Discussions « Newer topic     Older topic »

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