C# 同一服务上的Soap和Rest返回Soap端点的状态404/未找到端点
我试图为同一个服务配置两个端点,一个用于rest,即webHttpBinding,另一个用于soap,即wsHttpBinding。但是,当我访问soap服务时,它没有找到端点 这是我的界面 ITicketService.csC# 同一服务上的Soap和Rest返回Soap端点的状态404/未找到端点,c#,wcf,rest,soap,wcf-binding,C#,Wcf,Rest,Soap,Wcf Binding,我试图为同一个服务配置两个端点,一个用于rest,即webHttpBinding,另一个用于soap,即wsHttpBinding。但是,当我访问soap服务时,它没有找到端点 这是我的界面 ITicketService.cs [ServiceContract] public interface ITicketService { [OperationContract] [WebInvoke(Method = "POST", RequestFormat = WebMessageF
[ServiceContract]
public interface ITicketService
{
[OperationContract]
[WebInvoke(Method = "POST", RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/tickets")]
void AddTicket(Ticket ticket);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/tickets")]
IQueryable<Ticket> GetAllTickets();
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/tickets/{id}")]
Ticket GetTicketById(string id);
[OperationContract]
[WebInvoke(Method = "GET",
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Wrapped, UriTemplate = "/tickets/show_many?ids={ids}")]
IQueryable<Ticket> GetSeveralTicketsById(string ids);
[OperationContract]
[WebInvoke(Method = "PUT", RequestFormat = WebMessageFormat.Json,
ResponseFormat = WebMessageFormat.Json, BodyStyle = WebMessageBodyStyle.Bare, UriTemplate = "/tickets/{ticket_id}")]
void UpdateTicket(Ticket ticket, string ticket_id);
}
这是售票服务费
<%@ ServiceHost Language="C#" Debug="true" Service="TicketSupportSystem.Rest.Service.TicketService"
Factory="System.ServiceModel.Activation.WebServiceHostFactory" CodeBehind="TicketService.svc.cs" %>
下面是我的实际服务实现
public class TicketService : ITicketService
{
TicketManager _ticketManager = new TicketManager();
public void AddTicket(Ticket ticket)
{
_ticketManager.InsertTicket(ticket);
}
public IQueryable<Ticket> GetAllTickets()
{
return _ticketManager.GetAllTickets();
}
public Ticket GetTicketById(string id)
{
int ticketId = Convert.ToInt16(id);
return _ticketManager.GetTicketById(ticketId);
}
public IQueryable<Ticket> GetSeveralTicketsById(string ids)
{
var idList = ids.Split(',');
List<Ticket> tickets = new List<Ticket>();
foreach (var item in idList)
{
tickets.Add(GetTicketById(item));
}
return tickets.AsQueryable();
}
public void UpdateTicket(Ticket ticket, string ticket_id)
{
int ticketId = Convert.ToInt16(ticket_id);
ticket.Id = ticketId;
_ticketManager.UpdateTicket(ticket);
}
}
这是我的服务配置web.config
<system.serviceModel>
<bindings>
<wsHttpBinding>
<!-- or WsHttpBinding -->
<binding name="wsHttpBinding" >
<security mode="Transport">
<transport clientCredentialType="Ntlm" proxyCredentialType="Ntlm" />
</security>
</binding>
</wsHttpBinding>
</bindings>
<services>
<service name="TicketSupportSystem.Rest.Service.ITicketService" behaviorConfiguration="ServiceBehaviour">
<endpoint name="restTicketService" address="web" binding="webHttpBinding" contract="TicketSupportSystem.Rest.Service.ITicketService" behaviorConfiguration="web">
</endpoint>
<endpoint name="soapTicketService" address="soap" binding="wsHttpBinding" contract="TicketSupportSystem.Rest.Service.ITicketService" >
</endpoint>
</service>
<service name="TicketSupportSystem.Rest.Service.ITicketCommentService" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="TicketSupportSystem.Rest.Service.ITicketCommentService" behaviorConfiguration="web">
</endpoint>
<endpoint address="" binding="wsHttpBinding" contract="TicketSupportSystem.Rest.Service.ITicketCommentService" >
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
<service name="TicketSupportSystem.Rest.Service.IUserIdentityService" behaviorConfiguration="ServiceBehaviour">
<endpoint address="" binding="webHttpBinding" contract="TicketSupportSystem.Rest.Service.IUserIdentityService" behaviorConfiguration="web">
</endpoint>
<endpoint address="" binding="wsHttpBinding" contract="TicketSupportSystem.Rest.Service.IUserIdentityService" >
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<enableWebScript/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="ServiceBehaviour">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
当我转到url时,它会为rest端点提供正确的数据
及
当我转到url时,它会告诉我找不到端点
因此无法为soap服务创建代理
提前感谢您抽出时间来回顾我的问题。嗨,我终于找到了问题,也不敢相信这个愚蠢的错误
<service name="TicketSupportSystem.Rest.Service.ITicketService" behaviorConfiguration="ServiceBehaviour">
<endpoint name="restTicketService" address="web" binding="webHttpBinding" contract="TicketSupportSystem.Rest.Service.ITicketService" behaviorConfiguration="web">
</endpoint>
<endpoint name="soapTicketService" address="soap" binding="wsHttpBinding" contract="TicketSupportSystem.Rest.Service.ITicketService" >
</endpoint>
用于运行REST with SOAP服务的工厂内服务标记。我认为问题可能在于.svc文件中的标记。System.ServiceModel.Activation.WebServiceHostFactory用于RESTful WCF,我不知道它是否支持SOAP。你试过改用System.ServiceModel.Activation.ServiceHostFactory吗?@Tim是的,如果我删除System.ServiceModel.Activation.WebServiceHostFactory,那么它对SOAP工作正常,但在Rest中停止工作。现在我将尝试使用System.ServiceModel.Activation.ServiceHostFactory对其进行更改。谢谢您的帮助。@Tim我确实尝试过System.ServiceModel.Activation.ServiceHostFactory,但它只适用于soap,而REST停止工作。“你们知道有哪家工厂既生产肥皂又生产休息用品吗?”蒂姆:我发现了这个问题。见我下面的答复。谢谢你抽出时间。
System.ServiceModel.Activation.WebServiceHostFactory