找不到端点 – WCF Web服务
我为我的WCF服务创建了2个端点。
它与basicHttpBinding
一起工作正常,但会导致webHttpBinding
错误。
错误=未找到端点。
运营合同定义
[OperationContract] [WebInvoke(Method = "POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)] VINDescription CallADSWebMethod(string vin, string styleID);
web.config
:
请建议我如何解决这个问题?
我根据这个创建了一个类似的服务:
[ServiceContract] public interface IService { [OperationContract] [WebInvoke(UriTemplate="/CallADSWebMethod", Method="POST", BodyStyle = WebMessageBodyStyle.WrappedRequest, ResponseFormat = WebMessageFormat.Json)] string CallADSWebMethod(string vin, string styleID); }
我添加的重要内容是UriTemplate部分,它告诉服务调用应该是什么样子。 然后,我将此服务实现为:
public class Service : IService { public string CallADSWebMethod(string vin, string styleID) { return vin + styleID; } }
在我的web.config中我有以下内容:
然后我创建了一个看起来像这样的简单页面,使用jQuery调用此服务:
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm1.aspx.cs" Inherits="WebApplication1.WebForm1" %>
这会产生一个带有文本的警报。 希望这可以给予som指导。