简体   繁体   English

将php中的字符串数组转换为nuSOAP中的用户定义数据类型

[英]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.

相关问题 将用户定义的类型转换为字符串,并将字符串转换为用户定义的类型 - Convert the user defined type to string and string to user defined type 将字符串值转换为用户定义的类型 - Convert String Value to User Defined Type 如何将字符串类型转换为用户定义的自定义类型 - How to convert string type to user defined custom type 如何将用户定义的数据类型转换为hashset c# - how to convert user defined data type to hashset c# 将system.Type转换为用户定义的类型 - Convert system.Type to user defined type 键入从字符串到用户定义类型的转换 - Type conversion from string to User defined type 将ProjectFile类型的int参数(用户定义的数据类型)转换为数组的int - Converting an int parameter of type ProjectFile (user defined data type) to int of array dot net平台是否提供了任何api来将字符串或字节数组转换为用户定义的对象? - is there any api provided by dot net platform to convert a string or bytres array into user defined object? 我们可以将一种用户定义的数据类型(子类)转换为另一种自定义数据类型(父类) - Can we convert one User defined datatype (Child class) to another custom data type (Parent) Downcasting 将字符串数组转换为其他类型 - Convert string array to another type
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM