p2p.wrox.com Forums

Need to download code?

View our list of code downloads.


Go Back   p2p.wrox.com Forums > PHP/MySQL > Beginning PHP
I forgot my password Register Now
Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Beginning PHP Beginning-level PHP discussions. More advanced coders should post to the Pro PHP forum.

Welcome to the p2p.wrox.com Forums.

You are currently viewing the Beginning PHP section of the Wrox p2p Programmer to Programmer discussion community. This is a community of more than 40,000 computer programmers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining our free Wrox p2p community you can post your own programming questions and respond to other programmers’ questions. Registered users also don't have to see the ads that are displayed to guests. Registration is fast, simple and absolutely free so please, join today!
Join today and post to win prizes! Post more to increase your chances of being Wrox’s top poster of the month.

Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old September 26th, 2009, 05:14 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default NuSoap to .Net Complex Types

Howdy,

I'm using NuSoap to call a php service.
Then I'm using .Net to consume the NuSoap wrapper.

I'm new to php.
I can return a string no problem, on my NuSoap registration I simply specify:
$server->register('Authenticate',
array('userName' => 'xsd:string', 'password' => 'xsd:string'),
array('return' => 'xsd:string'));

however I will need to return more than 1 value, so I will need to return a complex type, lets say an object with a string for Debtor code and a string for Session ID. Simple to do in .Net, and I assume simple in PHP too, however I'm clueless.

I'd imagine one option is to build up an xml string and return that, but it sounds like a hell of a lot of work for something so easy.

Please could somebody give me some advice or an example of returning a complex type consumable by .Net from a PHP - NuSoap Web Service?

Thanx,
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
  #2 (permalink)  
Old September 26th, 2009, 11:28 AM
Registered User
Points: 8, Level: 1
Points: 8, Level: 1 Points: 8, Level: 1 Points: 8, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2009
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Resolved

The bits of code I was missing:

Setup Response Complex type in the wsdl
Code:
$server->wsdl->addComplexType('AuthResponseType',
	'complexType',
	'struct',
	'all',
	'',
	array(
		'DebtorCode' => array('name' => 'DebtorCode',
					'type' => 'xsd:string'),
		'SessionCode' => array('name' => 'SessionCode',
					'type' => 'xsd:string')
		)
	);
Register the function with the server
Code:
$server->register('Authenticate',
	array('userName' => 'xsd:string', 
		'password' => 'xsd:string'),
	array('return' => 'tns:AuthResponseType'),
	'MyApiWrapper',
	'MyApiWrapper#Authenticate',
	'rpc',
	'encoded',
	'Authenticates the login credentials and returns the debtor code and session id of the authenticated session');
The actual function, see the return array...
Code:
function Authenticate($userName, $password){
	$client = new SoapClient(null, array('location' => "http://blah.com/api.php", 'uri' => "http://blah.com/"));
	$AuthResponse = $client->authenticate($userName, $password);
	
	return array(
			'DebtorCode' => $AuthResponse->debtorCode,
			'SessionCode' => $AuthResponse->session);
}
Still seems like a lot of code, but it works. I got my response in .Net and all was well.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Reddit!
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
.NET bug: Error reflecting complex object with Nul peterwood .NET Web Services 0 February 7th, 2008 11:35 AM
Is Silverlight / ASP.NET really THIS Complex? Gary Frank BOOK: Silverlight 1.0 ISBN 978-0-470-22840-1 3 December 7th, 2007 06:46 PM
Schema: element is choice of complex types? jkmyoung XML 3 July 18th, 2007 05:54 PM
Using named complex types in XSD dsolovay BOOK: Professional ASP.NET 2.0 XML 0 March 5th, 2006 03:15 PM
.net and c# complex bindgrid page KarmenC SQL Server 2000 1 January 16th, 2005 04:23 AM



All times are GMT -4. The time now is 08:32 AM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
© 2008 Wiley Publishing, Inc