0

In continuation to the existing question: Can nusoap return array of string?

I want to know the code for function GetAllNews() to return string of array $stack as data type "tns:ArrayOfString"

Mr. Oliver Salzburg gave the code only for the declaration of type ArrayOfString but how do I convert a normal php array of string data type to user defined data type ArrayOfString ? So that I can call this data in my C# code as:

wService.Service WebS = new wService.Service();
wService.ArrayOfString StringArray = new wService.ArrayOfString();
StringArray = WebS.GetAll();
string [] All= StringArray.itemName[0];

My aim is to return an array of string from php/nuSOAP to my C# code.

Community
  • 1
  • 1
Computer User
  • 2,839
  • 4
  • 47
  • 69

1 Answers1

1

First define ArrayOfString above the code as

$server->wsdl->addComplexType(
'ArrayOfString',
'complexType',
'array',
'all',
'SOAP-ENC:Array',
array(),
array(
array(
   'ref'=>'SOAP-ENC:arrayType',
   'wsdl:arrayType'=>'xsd:string[]'
   )
),
'xsd:string'
);

Then declare method 'GetAllNews' as

$server->register('GetAllNews', 
 array(),
 array('return' => 'tns:ArrayOfString'),  //use 'tns:ArrayOfString' instead of 'xsd:string[]'
 'urn:NewsService',
 'urn:NewsService#GetAllNews',
 'rpc',
 'literal',  //You can also use 'encoded'
 ''
);

The above code will return an array of string (string []) Call the method 'GetAllNews' in C# as

string [] AllNews = new WebService.GetAllNews();
Sourabh
  • 140
  • 1
  • 1
  • 8