小编jav*_*nja的帖子

从浏览器运行WCF方法

我在Visual Studio 2010中使用C#创建一个非常基本的WCF服务.我想知道是否可以通过键入以下内容直接从浏览器运行我的方法://localhost:49815/Service1.svc/methodName(parameterValue)

这是我的代码的本质.

接口:

using ...
namespace WcfService1{   
    [ServiceContract]
    public interface IService1{
        [OperationContract]
        [WebGet]
        string echoWithGet(string s);
        [OperationContract]
        [WebInvoke]
        string echoWithPost(string s);
    }
}
Run Code Online (Sandbox Code Playgroud)

方法:

 public string echoWithGet(string s ){
            return "Get: "+s;
        }

 public string echoWithPost(string s){
            return "Post: " + s;
        }
Run Code Online (Sandbox Code Playgroud)

c# wcf

30
推荐指数
2
解决办法
8万
查看次数

标签 统计

c# ×1

wcf ×1