无法执行';获取';关于WCF服务
我有一个简单的WCF契约,它包含“GET”和“POST”操作。我在本地主机上运行该服务。我可以在浏览器中键入服务地址并查看服务响应值。当我尝试从C代码中执行同样的操作时,我得到了错误消息“没有端点侦听…”。但是,我可以从代码中调用服务上的“POST”方法 我错过了什么?下面是我的合同代码无法执行';获取';关于WCF服务,wcf,Wcf,我有一个简单的WCF契约,它包含“GET”和“POST”操作。我在本地主机上运行该服务。我可以在浏览器中键入服务地址并查看服务响应值。当我尝试从C代码中执行同样的操作时,我得到了错误消息“没有端点侦听…”。但是,我可以从代码中调用服务上的“POST”方法 我错过了什么?下面是我的合同代码 using System; using System.ServiceModel; using System.ServiceModel.Web; namespace WebServiceTest.Service
using System;
using System.ServiceModel;
using System.ServiceModel.Web;
namespace WebServiceTest.Services
{
[ServiceContract]
public interface ITestOne
{
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "GetGreeting/{text1}/{text2}")]
string HelloWorld(string text1, string text2);
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "Greet/{text1}")]
string HelloWorld2(string text1);
[OperationContract]
[WebInvoke(
Method="GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "Add/{value1}/{value2}")]
int Add(string value1, string value2);
[OperationContract]
[WebInvoke(Method = "POST",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped)]
String GetAllSpecies();
[OperationContract]
[WebInvoke(
Method = "GET",
ResponseFormat = WebMessageFormat.Json,
BodyStyle = WebMessageBodyStyle.Wrapped,
UriTemplate = "specie")]
String GetAllSpecies2();
}
}我找到了答案。问题在于,服务使用的是服务契约ITestOne,而客户端使用的是为ITestOne生成的代理客户端(通过MEX端点获得)。生成的代理不包含服务合约包含的[WebGet]属性。我找到了答案。问题在于,服务使用的是服务契约ITestOne,而客户端使用的是为ITestOne生成的代理客户端(通过MEX端点获得)。生成的代理不包含服务协定包含的[WebGet]属性