PHP and object class that return from web service

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
lerchart
Forum Newbie
Posts: 4
Joined: Mon Jan 13, 2003 2:00 am

PHP and object class that return from web service

Post by lerchart »

i created my web service in C# that returns class

public class MyInfo
{
public int x;
public int y;
}

...
[WebMethod]
public MyInfo TestClass(int num1,int num2)
{
MyInfo info = new MyInfo();
info.x=num1;
info.y=num2;
return info;
}

then i use MSSOAP COM for calling web service
<?php

$myCom = new COM("MSSOAP.SoapClient");
$myCom->mssoapinit("http://localhost/WebService1/Service1.asmx?WSDL", "Service1");

echo $myCom->TestClass(1,2);
?>

it returns a word "OBJECT"


i dont know how can i get this result to show..

and ive tried..
$myCom->TestClass(1,2);
echo $myCom->x;

or
echo com_get($myCom->TestClass(1,2),"x");

it returns..
Warning: Unable to lookup x: Unknown name.

if ... gettype($myCom->TestClass(1,2)); it returns ..object

if ... get_class($myCom->TestClass(1,2)); it returns .. COM


please help me
thanks in advance
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

your soap-method returns a complex type which is probably mapped as COM-Object as well but returned from that method call (never tried soap).
Maybe

Code: Select all

$oType = $myCom->TestClass(1,2); 
echo $oType->x, '/', $oType->y;
works.
lerchart
Forum Newbie
Posts: 4
Joined: Mon Jan 13, 2003 2:00 am

Post by lerchart »

ive tried..

$oType = $myCom->TestClass(1,2);
echo $oType->x, '/', $oType->y;

it returns..

Warning: Unable to lookup x: Unknown name.
Warning: Unable to lookup y: Unknown name.


?>
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

then maybe

Code: Select all

$oType = $myCom->TestClass(1,2);
echo com_get($oType, 'x'), '/', com_get($oType, 'y');
only guessing :D
glo-wurm
Forum Newbie
Posts: 13
Joined: Mon Jan 13, 2003 2:07 pm
Location: Naples, FL

Post by glo-wurm »

Try commenting out your echo line, and place this right before/after it...

echo '<pre>';
print_r($myCom);
echo '</pre>';

That should print out the details of your entire $myCom object, so you can see where the data you want is located.
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I doubt a com-object exposes more properties than its resource id to print_r :(
lerchart
Forum Newbie
Posts: 4
Joined: Mon Jan 13, 2003 2:00 am

Post by lerchart »

:?

echo print_r($myCom->TestClass(1,2));

return..

COM Object
(
[0] => Resource id #2
)
1


ohhh man how can i do
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

I found that without a proper WSML-definition (4. parameter of mssoapinit) you will retrieve an IXMLDOMSelection for complex types.
Well I know nothing about soap, WSDL & WSML but I do know that you should be able to extract the values of the selection with

Code: Select all

<?php
$myCom = new COM("MSSOAP.SoapClient30");
$myCom->mssoapinit("http://hermes/WebService1/Service1.asmx?WSDL", "Service1");
$o = $myCom->TestClass(1,2);
$x = $o->Item(0);
$y = $o->Item(1);
echo $x->nodeTypedValue(), '/', $y->nodeTypedValue();
?>
But searching how to create this WSML-def is probably worth the time ;)
lerchart
Forum Newbie
Posts: 4
Joined: Mon Jan 13, 2003 2:00 am

Post by lerchart »

bloody brilliant man

oh yeah !!

thanks very much volka

it means a lot to me.

:wink: :) :D
Post Reply