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.

1 Answer 1

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();
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.