我可以停止服务基准产生ArrayOfString的字符串,而不是[]? [英] Can I stop service reference generating ArrayOfString instead of string[]?

查看:210
本文介绍了我可以停止服务基准产生ArrayOfString的字符串,而不是[]?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有这样的签名的Web方法:

I have a web method with a signature like this:

public string[] ToUpper(string[] values)

我使用Visual Studio 2010中的添加服务引用生成对我的服务的引用。不幸的是,这个过程创建了一个名为ArrayOfString的代理类,并使用这种类型,而不是预期的'字符串[]'类型。生成的异步服务调用签名最终看起来是这样的:

I am using the 'Add Service reference' in Visual Studio 2010 to generate a reference to my service. Unfortunately, this process creates a proxy class called 'ArrayOfString' and uses this type instead of the expected 'string[]' type. The generated async service call signature ends up looking like this:

public void ToUpperAsync(Demo.ServiceReference.ArrayOfString values) { }
public void ToUpperAsync(Demo.ServiceReference.ArrayOfString values, object userState) { }

我有尝试了集合下拉配置服务参考表格上的所有选项,它似乎并没有发挥作用。

I have tried all the options of the 'Collection' drop down on the config service reference form and it doesn't seem the make a difference.

这是以前的工作,但对于某些原因突然停止工作,也许是从服务中删除另一个Web方法之后。

This was working previously, but for some reason it suddenly stopped working, perhaps after removing another web method from the service.

我如何生成的服务引用类使用string []类型,而不是生成ArrayOfString类型? 。任何帮助,将不胜感激。

How do I get the generated service reference class to use the string[] type instead of a generated ArrayOfString type? Any help on this would be greatly appreciated.

编辑:
作为@Oleg暗示,我使用ASMX Web服务。

As @Oleg suggests, I am using ASMX web services.

推荐答案

添加一个服务引用到ASMX风格的Web服务时,我可以重现你的问题。然而加入服务refernce到WCF服务或Web引用,以ASMX服务参数时是字符串[]类型。

I could reproduce your problem when adding a "Service reference" to an ASMX style web service. However when adding "Service refernce" to a WCF service or "Web reference" to an ASMX service argument was of type string[].

根据这一点,我认为你可以修复由Web引用取代服务引用你的问题。

According to this I think that you can fix your problem by replacing "Service reference" by "Web reference".

按高级...添加服务引用对话框按钮。

Press "Advanced..." button on "Add service reference dialog".

按添加Web引用...

Press "Add web reference..."

将服务URL,并添加Web引用

Insert service url and add web reference

这篇关于我可以停止服务基准产生ArrayOfString的字符串,而不是[]?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆