【发布时间】:2013-09-24 18:36:51
【问题描述】:
我正在 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);
}
}
方法:
public string echoWithGet(string s ){
return "Get: "+s;
}
public string echoWithPost(string s){
return "Post: " + s;
}
【问题讨论】:
-
只是好奇...你试过了吗?
-
是的,如果通过“尝试”,您是指通过我建议的格式调用该方法。
-
您需要向我们展示您正在使用的服务器端配置!尤其是 binding 至关重要——你用的是哪一个??
-
@user2635032 你可以用喜欢你建议的格式做你想做的事,但不是完全你建议的格式;我提供的链接包含正确格式的示例。