如何在webservice的webmethod中传递数组 [英] how to pass array in webmethod in webservice
问题描述
如何一次传递具有"sessiontoken"和"{Name,Age,DOB,Qualification}"的数组和字符串变量,例如"8b563bdb-2b41-41-4169-97dc-dd15d46ffb6b" ',''{''''Ranjit'',23,''23-03-1988'',''B.Tech'''',''Swapnil'',24,''04-07 -1989''''}''在网络服务的网络方法中????
请帮助我....
How can i pass an array and a string variable at a time which have ''sessiontoken'' and ''{Name,Age,DOB,Qualification}'' e.g ''8b563bdb-2b41-4169-97dc-dd15d46ffb6b'',''{''''Ranjit'',23,''23-03-1988'',''B.Tech'''',''''Swapnil'',24,''04-07-1989''''}'' in webmethod of a webservice????
plz help me....
推荐答案
这不是特定的解决方案,仅是一种解决方法.
1.保持web方法接受字符串参数.
2.将webmethod参数的标记准备为:
This is not a specific solution, a workaround only.
1. Keep the webmethod to accept string parameter.
2. Preparing Tagging for webmethod parameter as :
string parameters = string.Format("{0}[#sp#]{1}[#sp#]{2}[#sp#]{3}[#sp#]{4}[#sp#]{5}[#sp#]{6}[#sp#]{7}", s1, s2, s3, s4, s5, s6, s7, s8);
s1 s2 s3,s4..s8等都是
''8b563bdb-2b41-4169-97dc-dd15d46ffb6b''
兰吉特(Ranjit)
23
1988年3月23日
``B.Tech''
''Swapnil''
24
''1989年4月7日''
现在,在WebMethod中将它们拆分为必需的参数:
here s1 s2 s3, s4..s8 etc are the
''8b563bdb-2b41-4169-97dc-dd15d46ffb6b''
''Ranjit''
23
23-03-1988
''B.Tech''
''Swapnil''
24
''04-07-1989''
Now in the WebMethod split them to required parameters :
string[] sep = new string[] { "[#sp#]" };
string[] Temp = stringparam.Split(sep, StringSplitOptions.None);
s1 = Temp[0];
s2 = Temp[1];
...
s8 = Temp[7];
这篇关于如何在webservice的webmethod中传递数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!