PHP and object class that return from web service
Moderator: General Moderators
PHP and object class that return from web service
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
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
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).
Maybeworks.
Maybe
Code: Select all
$oType = $myCom->TestClass(1,2);
echo $oType->x, '/', $oType->y;then maybe
only guessing 
Code: Select all
$oType = $myCom->TestClass(1,2);
echo com_get($oType, 'x'), '/', com_get($oType, 'y');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 withBut searching how to create this WSML-def is probably worth the time 
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();
?>