LinuxQuestions.org
Review your favorite Linux distribution.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 11-17-2007, 05:42 PM   #1
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Rep: Reputation: 30
PHP SOAP server returns array using NuSOAP Library


Hi,
I have a function in my SOAP server that returns an array. When the client calls this function, it only receives "array", and when I use foreach to print each member of this array, it tells me that this is not an array. If I change the returned value of the function to a string or integer type everything works fine though, so I don't think that there is any problem with the client.

I am using NuSOAP library on php to achieve that.

I had doubt when declaring the type of return value of the function. In XML schema there is no array type, so I specified the return value as a string like this:

PHP Code:
$server->register("getLocation",
                array(
'country_population' => 'xsd:string',
                
'city_population' => 'xsd:string'),
                array (
'return' => 'xsd:string'),
                
'urn:world',
                
'urn:worldquote#getLocation'); 
The return values is a result of a query from database.

Any idea how I can declare array element in XML schema?
 
Old 11-18-2007, 10:10 AM   #2
Guttorm
Senior Member
 
Registered: Dec 2003
Location: Trondheim, Norway
Distribution: Debian and Ubuntu
Posts: 1,453

Rep: Reputation: 446Reputation: 446Reputation: 446Reputation: 446Reputation: 446
Hi

In the register call, you are saying that your function returns a string. You need to make the type yourself. Something like:

PHP Code:
$server->wsdl->addComplexType("ArrayOfString",
                 
"complexType",
                 
"array",
                 
"",
                 
"SOAP-ENC:Array",
                 array(),
                 array(array(
"ref"=>"SOAP-ENC:arrayType","wsdl:arrayType"=>"xsd:string[]")),
                 
"xsd:string"); 
Then, when use something like this for return type:
PHP Code:
array("return" => "tns:ArrayOfString"), 
instead of
PHP Code:
array ('return' => 'xsd:string'), 
Haven't tested it, but I coded something like that before, but I don't have it here now.
 
Old 11-18-2007, 09:27 PM   #3
mohtasham1983
Member
 
Registered: Apr 2005
Location: San Jose
Distribution: Fedora 3,4- Ubuntu 6.06 to 8.10, Gentoo and Arch
Posts: 408

Original Poster
Rep: Reputation: 30
thanks, I got it working. I really appreciate your help.
 
  


Reply



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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
How to pass array to a function in Java so that it returns changed? kornerr Programming 1 09-19-2006 12:16 PM
Cannot get nusoap to work eikeland Linux - Software 3 06-05-2006 07:54 PM
Standard C library numeric array functions? bulliver Programming 8 04-12-2006 08:45 PM
Best Python float array library? zero79 Programming 0 08-31-2005 05:25 PM
advx php soap support? schallig Mandriva 1 07-15-2005 01:15 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 07:03 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration