我正在开发一个带有JSON行为的WCF服务,我希望将它们作为REST和SOAP公开。
[ServiceContract]
public interface ITicket
{
[WebGet]
[OperationContract]
Ticket[] GetAllTickets();
[WebGet(UriTemplate = "{value}")]
[OperationContract]
Ticket GetTicketById(int Id);
//[WebGet(UriTemplate = "{value}")]
[OperationContract]
Ticket[] GetTickets(string Ids);
[OperationContract ]
void AddTicket(Ticket ticket);
[OperationContract ]
void UpdateTicket(int Id);
}
我的配置设置为:
<service name="WCF_Rest_SOAP_JSON_Service.TicketService"
behaviorConfiguration="TicketServiceBehavior" >
<endpoint
address="soap"
behaviorConfiguration="SOAPEndPointBehavior"
binding="basicHttpBinding"
contract="WCF_Rest_SOAP_JSON_Service.ITicket"/>
<endpoint
address="rest"
behaviorConfiguration="RESTEndPointBehavior"
binding="webHttpBinding"
contract="WCF_Rest_SOAP_JSON_Service.ITicket"/>
</service>
<behaviors>
<serviceBehaviors>
<behavior name="TicketServiceBehavior">
<serviceMetadata httpGetEnabled="true" />
<serviceDebug includeExceptionDetailInFaults="true" />
</behavior>
</serviceBehaviors>
<endpointBehaviors>
<behavior name="SOAPEndPointBehavior">
<webHttp/>
</behavior>
<behavior name="RESTEndPointBehavior">
<webHttp/>
</behavior>
</endpointBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
我做的是:
现在我的问题是:
当我运行该服务时,我直接进入IIS直接列出,点击我的服务后,我收到以下错误:
“
http://localhost:3505/TicketService.svc/soap
”处的端点没有使用None MessageVersion进行绑定。 'System.ServiceModel.Description.WebHttpBehavior'仅适用于WebHttpBinding或类似绑定。**
我还运行了WCFTestClient.exe,在传递了这个url(http://localhost:3505/TicketService.svc
)之后,我收到了以下错误:
无法添加服务。可能无法访问服务元数据。确保您的服务正在运行并公开元数据。
任何想法如何解决这些1和2(我尝试了不同的堆栈溢出解决方案,但到目前为止都没有成功。