Page 1 of 1

PHP and object class that return from web service

Posted: Mon Jan 13, 2003 2:00 am
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

Posted: Mon Jan 13, 2003 4:00 am
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.

Posted: Mon Jan 13, 2003 6:01 am
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.


?>

Posted: Mon Jan 13, 2003 9:43 am
by volka
then maybe

Code: Select all

$oType = $myCom->TestClass(1,2);
echo com_get($oType, 'x'), '/', com_get($oType, 'y');
only guessing :D

Posted: Mon Jan 13, 2003 2:28 pm
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.

Posted: Mon Jan 13, 2003 11:01 pm
by volka
I doubt a com-object exposes more properties than its resource id to print_r :(

Posted: Tue Jan 14, 2003 1:00 am
by lerchart
:?

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

return..

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


ohhh man how can i do

Posted: Tue Jan 14, 2003 10:52 am
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 ;)

Posted: Wed Jan 15, 2003 1:02 am
by lerchart
bloody brilliant man

oh yeah !!

thanks very much volka

it means a lot to me.

:wink: :) :D