您好,非常感谢您的阅读。IIS 7.5中的REST/SOAP端点的WCF 4服务
我想获得一个服务托管在IIS 7.5,有多个端点公开。
我有一种感觉问题在于我的web.config,但我会在这里发布我的服务代码。没有接口文件,因为我使用WCF 4的新功能,也没有.svc文件。
根据我的理解,所有的路由都使用RouteTable功能在Global.asax.cs中处理。
无论如何,到代码/配置 -
[ServiceContract]
[AspNetCompatibilityRequirements(RequirementsMode = AspNetCompatibilityRequirementsMode.Allowed)]
[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerCall)]
// NOTE: If the service is renamed, remember to update the global.asax.cs file
public class Service1
{
// TODO: Implement the collection resource that will contain the SampleItem instances
[WebGet(UriTemplate = "HelloWorld")]
public string HelloWorld()
{
// TODO: Replace the current implementation to return a collection of SampleItem instances
return "Hello World!";
}
}
而现在,配置和我认为需要作出(我不知道如果我需要保持standardEndpoints阻塞的变化,但有或没有它,我仍然得到错误信息 -
<services>
<service name="AiSynthDocSvc.Service1" behaviorConfiguration="HttpGetMetadata">
<endpoint name="rest"
address=""
binding="webHttpBinding"
contract="AiSynthDocSvc.Service1"
behaviorConfiguration="REST" />
<endpoint name="soap"
address="soap"
binding="basicHttpBinding"
contract="AiSynthDocSvc.Service1" />
<endpoint name="mex"
address="mex"
binding="mexHttpBinding"
contract="IMetadataExchange" />
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="REST">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="HttpGetMetadata">
<serviceMetadata httpGetEnabled="true" />
</behavior>
</serviceBehaviors>
</behaviors>
<standardEndpoints>
<webHttpEndpoint>
<!--
Configure the WCF REST service base address via the global.asax.cs file and the default endpoint
via the attributes on the <standardEndpoint> element below
-->
<standardEndpoint name="" helpEnabled="true" automaticFormatSelectionEnabled="true"/>
</webHttpEndpoint>
</standardEndpoints>
的的Global.asax.cs文件被单独留在家中
再次我敢肯定它是与我的配置。 Ť当我尝试访问任何定义的端点时,他遇到的错误是 -
''处的端点没有与无消息版本的绑定。 'System.ServiceModel.Description.WebHttpBehavior'仅用于WebHttpBinding或类似的绑定。
任何人对此有任何意见?
感谢,
扎卡里·卡特
你用什么URL来访问你的服务? – 2011-04-13 15:49:45
另外:你说你没有* .svc文件 - 你的服务如何激活呢?您可能需要* .svc文件,或者您需要在配置文件中添加标签。 –
2011-04-13 15:50:51
该服务被部署到端口80上的默认网站,因此它只是 - http:// localhost/WebApp/ServiceName来访问它。另外,在没有.svc文件的情况下创建服务的功能是.NET 4.0中的一项新功能。不是击中svc文件,而是添加了一个新类,以将请求正确路由到相应的服务。 – 2011-04-13 16:58:59