【发布时间】:2016-02-06 00:27:49
【问题描述】:
我试图在同一个 SVC 文件下有两个合同,但它不起作用。当我在 IE 中打开 SVC 文件时,我收到错误消息“端点错误”。 如果我从客户端调用合同的方法,它不会影响服务。 服务器托管在 IIS 上。
请告诉我这里发生了什么。
在同一个 SVC 文件或 Web 服务下是否可以有一个 wsHttpBinding 和一个 webHttpBinding?它们将托管在 IIS 上。
SVC 文件
<%@ ServiceHost Language="C#" Debug="true" Service="S1.ServiceDual6" CodeBehind="ServiceDual6.cs" Factory="System.ServiceModel.Activation.WebServiceHostFactory" %>
合同
{
[InspectorBehavior]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
public class ServiceDual6 : IServiceREST, IServiceREST2
{
public string RestInDual_Contract(Message mm)
{
return "";
}
public string RestInDual_Contract2(Message mm)
{
return "";
}
}
}
namespace S1
{
[ServiceContract]
public interface IServiceREST
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
string RestInDual_Contract(Message mm);
}
[ServiceContract]
public interface IServiceREST2
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Xml, ResponseFormat = WebMessageFormat.Xml)]
string RestInDual_Contract2(Message mm);
}
}
Web.config
<service name="S1.ServiceDual6" behaviorConfiguration="s1bhrWithHttpEnabled">
<host>
<baseAddresses>
<add baseAddress="http://localhost/S2/Service6.svc"/>
</baseAddresses>
</host>
<endpoint address="" binding="webHttpBinding" contract="S1.IServiceREST" behaviorConfiguration="s1bhr">
</endpoint>
<endpoint address="" binding="webHttpBinding" contract="S1.IServiceREST2" behaviorConfiguration="s1bhr">
</endpoint>
</service>
【问题讨论】:
标签: wcf wcf-binding wcf-rest