I defined one function to display object in server.php, such as adodb_page()
Now, I need to display this object in client.php
I tried to modify the response type to 'object' in wsdl file,but failed
any idea about this?
thanks in advance
How to response one object type in webservices?
Moderator: General Moderators
-
andrewknight
- Forum Newbie
- Posts: 2
- Joined: Thu Jul 19, 2007 1:43 am
-
andrewknight
- Forum Newbie
- Posts: 2
- Joined: Thu Jul 19, 2007 1:43 am
code like below
feyd | Please use
Portion code of test.wsdl
below is client.php
any advice? thanks
feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
[size=150][b]server.php like shown below[/b][/size]Code: Select all
<?php
include_once ('include/adodb/adodb.inc.php');
include_once('include/adodb/adodb-pager.inc.php');
function getTemp($paraid) {
$conn
$strsql="select * where table where id=".$paraid;
$pager = new ADODB_Pager($conn,$strsql);
$pager->Render($rows_per_page=2);
$conn->Close();
return $pager;
}
ini_set("soap.wsdl_cache_enabled", "0");
$server = new SoapServer("test.wsdl");
$server->addFunction("getTemp");
$server->handle();
?>Code: Select all
<message name='getTempRequest'>
<part name='symbol' type='xsd:string'/>
</message>
<message name='getTempResponse'>
<part name='Result' type='[color=red]xsd:object'[/color]/>
</message>
<portType name='TempPortType'>
<operation name='getTemp'>
<input message='tns:getTempRequest'/>
<output message='tns:getTempResponse'/>
</operation>
</portType>Code: Select all
<?php
$paraid = $_GET['paraid'];
$client = new SoapClient("test.wsdl");
$return = $client->getTemp($paraid);
echo($return);
?>feyd | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
Last edited by andrewknight on Thu Jul 19, 2007 10:40 pm, edited 1 time in total.
Well for one thing you your getTemp() object never returns anything. Your SOAP functions should never echo anything, but only return stuff.
I would start simple. Make a function that returns a string like 'hello world'. Then a client that retrieves that value and displays it. After you get that working, then start working towards getting your function to return an object. Make small changes then test it after each change to see what happens.
Using a WSDL generator will help a lot. There is one built into Zend Studio that helps immensely and generates the WSDL complete with return values based on phpdoc blocks. I am sure that other generators exist out there as well.
In order to return an object you will need to have a classmap for that object on the client side and the class declared on that side as well I believe. Check out php.net for examples.
I would start simple. Make a function that returns a string like 'hello world'. Then a client that retrieves that value and displays it. After you get that working, then start working towards getting your function to return an object. Make small changes then test it after each change to see what happens.
Using a WSDL generator will help a lot. There is one built into Zend Studio that helps immensely and generates the WSDL complete with return values based on phpdoc blocks. I am sure that other generators exist out there as well.
In order to return an object you will need to have a classmap for that object on the client side and the class declared on that side as well I believe. Check out php.net for examples.