WCF RESTFul服务 - 404端点未找到2服务
我有两个WCF服务Exchange1.svc和Exchange2.svc都设置为RESTful JSON consummables。 Exchange1.svc工作正常,但是当我尝试发布到Exchange2.svc时,我收到了找不到Endpoint消息。WCF RESTFul服务 - 404端点未找到2服务
我在做什么错?
我IExchange2接口:
[ServiceContract]
public interface IExchange2
{
[System.ServiceModel.OperationContract(Name = "InsertReading")]
[WebInvoke(UriTemplate = "/InsertReading?memberID={memberID}", Method = "POST", ResponseFormat = WebMessageFormat.Json)]
void InsertReading(string memberID);
}
我试图打的网址是:http://localhost:49701/Exchange2.svc/DiaInsertReading?memberID=6519548
我的配置是:
<system.serviceModel>
<behaviors>
<endpointBehaviors>
<behavior name="MyNamespace.Exchange1Behavior">
<webHttp/>
</behavior>
<behavior name="MyNamespace.Exchange2Behavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<services>
<service name="MyNamespace.Exchange1">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="MyNamespace.Exchange1Behavior" contract="MyNamespace.IExchange1" />
</service>
<service name="MyNamespace.Exchange2">
<endpoint address="" binding="webHttpBinding" behaviorConfiguration="MyNamespace.Exchange2Behavior" contract="MyNamespace.IExchange2" />
</service></services></system.serviceModel>
我已经编辑我的职务,因为答案没有帮助。由于您使用svc在IIS中托管,因此您无需在绑定中设置地址,正如我在之前的回答中所说的那样。 baseaddress将是您服务器的位置。例如:http://localhost:49701/Exchange2.svc
。如果你点击这个地址,你应该进入一个WCF服务网页。
由于您使用POST方法,您可以在请求正文中发送数据。如果您安装了提琴手,在作曲家中,如果这是您的服务地址,则可以将方法设置为http://localhost:49701/Exchange2.svc/InsertReading
。 在请求主体的主体中,您将{ memberID:"123" }
更改为您希望发送到服务的任何值。
或者你可以像地址发送数据:http://localhost:49701/Exchange2.svc/InsertReading?memberID=123
如果现在执行您的请求时,它应该返回一个响应200 OK。
太好了 - 我会试试看,看看现在是否能正常工作... – AshesToAshes 2012-04-09 10:02:00
它没有工作:(我仍然没有找到Endpoint – AshesToAshes 2012-04-09 10:44:32
感谢Bassetassen的更新 - 我也会尝试这个。 – AshesToAshes 2012-04-17 07:04:55
在的web.config文件指定您的端点
<service name="MyNamespace.Exchange2">
<endpoint address="Exchange2" binding="webHttpBinding" behaviorConfiguration="MyNamespace.Exchange2Behavior" contract="MyNamespace.IExchange2" />
然后,在您的网址添加此终点为:
http://localhost:49071/Exchange2/DiaInsertReading?memberID=6519548
我添加了端点作为Bassetassen的指示,但它仍然无法正常工作。 – AshesToAshes 2012-04-09 10:48:34
只是错过了我原来的帖子中更新的URL的一部分... – AshesToAshes 2012-04-09 10:50:20