[英]Convert an array of string in php to an user defined data type in nuSOAP
In continuation to the existing question: Can nusoap return array of string? 继续存在的问题: nusoap可以返回字符串数组吗?
I want to know the code for function GetAllNews() to return string of array $stack as data type "tns:ArrayOfString" 我想知道函数GetAllNews()的代码以数据类型“ tns:ArrayOfString”返回数组$ stack的字符串
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 ? Oliver Salzburg先生仅提供了用于声明ArrayOfString类型的代码,但是如何将字符串数据类型的普通php数组转换为用户定义的数据类型ArrayOfString? So that I can call this data in my C# code as:
这样我就可以在C#代码中将此数据称为:
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. 我的目标是将字符串数组从php / nuSOAP返回到我的C#代码。
First define ArrayOfString above the code as 首先在代码上方将ArrayOfString定义为
$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 然后将方法“ GetAllNews”声明为
$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 []
)在C#中以如下方式调用方法'GetAllNews'
string [] AllNews = new WebService.GetAllNews();
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.