C# 如何通过 GET 调用 ASMX Web 服务?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1208569/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-06 10:57:14  来源:igfitidea点击:

How to call an ASMX web service via GET?

c#asp.netweb-servicesasmx

提问by marcgg

I have a webservice defined here:

我在这里定义了一个网络服务:

/app/AutocompleteManager.asmx

/app/AutocompleteManager.asmx

[WebMethod]
public string AutocompleteComposers()
{
  return "hey, what's up";
}

I want to call it using the GET method with extra parameters.

我想使用带有额外参数的 GET 方法来调用它。

If I just go /app/AutocompleteManager.asmx?q=something, it won't work because I don't have the action specified.

如果我只是去/app/AutocompleteManager.asmx?q=something,它不会工作,因为我没有指定的动作。

If I go /app/AutocompleteManager.asmx/AutocompleteComposers?q=somethingit breaks.

如果我去/app/AutocompleteManager.asmx/AutocompleteComposers?q=something它坏了。

Any idea?

任何的想法?

采纳答案by Flory

Change your web.config like so:

像这样更改您的 web.config:

<system.web>
    ...
    <webServices>
        <protocols>
              <add name="HttpSoap"/> 
              <add name="HttpPost"/>
              <add name="HttpGet"/>
        </protocols>
    </webServices>
</system.web>

回答by Srikar Doddi

Get needs to enabled. Check that first.

获取需要启用。先检查一下。