最新下载
热门教程
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
WebServices中ArrayList做参数为什么有问题
时间:2022-07-02 11:20:50 编辑:袖梨 来源:一聚教程网
我在WebService中写了一个方法,用ArrayList做参数,返回也是ArrayLsit
[WebMethod]
public ArrayList GetArrayList2(ArrayList arrayList)
{
return arrayList;
}
然后我在一个ASP.NET的客户端调用
private void Button1_Click(object sender, System.EventArgs e)
{
localhost.Service1 s = new TestWeb.localhost.Service1();
ArrayList al = new ArrayList();
al.Add("arrayList_1");
al.Add("arrayList_2");
//下面这句要出错,说al不能转变成object[]类型
ArrayList aa = s.GetArrayList2(al);
foreach(string str in aa)
{
Response.Write(str);
}
}
查看vs.net自动生成的Reference.cs文件,发现参数实际变了
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetArrayList2", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public object[] GetArrayList2(object[] arrayList) {
object[] results = this.Invoke("GetArrayList2", new object[] {
arrayList});
return ((object[])(results[0]));
}
这是为什么啦?
[WebMethod]
public ArrayList GetArrayList2(ArrayList arrayList)
{
return arrayList;
}
然后我在一个ASP.NET的客户端调用
private void Button1_Click(object sender, System.EventArgs e)
{
localhost.Service1 s = new TestWeb.localhost.Service1();
ArrayList al = new ArrayList();
al.Add("arrayList_1");
al.Add("arrayList_2");
//下面这句要出错,说al不能转变成object[]类型
ArrayList aa = s.GetArrayList2(al);
foreach(string str in aa)
{
Response.Write(str);
}
}
查看vs.net自动生成的Reference.cs文件,发现参数实际变了
///
[System.Web.Services.Protocols.SoapDocumentMethodAttribute("http://tempuri.org/GetArrayList2", RequestNamespace="http://tempuri.org/", ResponseNamespace="http://tempuri.org/", Use=System.Web.Services.Description.SoapBindingUse.Literal, ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
public object[] GetArrayList2(object[] arrayList) {
object[] results = this.Invoke("GetArrayList2", new object[] {
arrayList});
return ((object[])(results[0]));
}
这是为什么啦?
相关文章
- 上古卷轴4重制版法师加点攻略 07-02
- NOVA(NOVA币)能上涨吗 07-02
- Hyperliquid (HYPE) 价格预测:供应紧缩或将推动价格突破100美元大关 - 来自Brave New Coin 07-02
- 秘影曼德拉会说话的骷髅三大部件位置一览 07-02
- 绝区零花语未明之言第一天攻略 07-02
- 上古卷轴4重制版技能书位置一览 07-02