![](/img/trans.png)
[英]How to configure a Windows Azure WCF Service Web Role to work with netTcpBinding?
[英]How to configure webHttp Binding while creating a WCF service in Azure?
我正在Azure中开发WCF WebRole服务,需要调用一种以JSON格式提供员工数据的方法。但是与普通的WCF Web服务不同,我不知道如何为WCF Webrole和我的代码配置“ Web.config”常规WCF服务的“ Web.config”如下:
<system.serviceModel>
<services>
<service name="empl.Service1" behaviorConfiguration="empl.Service1Behavior">
<!-- Service Endpoints -->
<endpoint address="" binding="webHttpBinding" contract="empl.IService1" behaviorConfiguration="web">
<!--
Upon deployment, the following identity element should be removed or replaced to reflect the
identity under which the deployed service runs. If removed, WCF will infer an appropriate identity
automatically.
-->
<identity>
<dns value="localhost"/>
</identity>
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange"/>
</service>
</services>
<behaviors>
<endpointBehaviors>
<behavior name="web">
<webHttp/>
</behavior>
</endpointBehaviors>
<serviceBehaviors>
<behavior name="empl.Service1Behavior">
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
WCF WebRole(Azure)的代码“ Web.config”如下
<system.serviceModel>
<behaviors>
<serviceBehaviors>
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<!-- To receive exception details in faults for debugging purposes, set the value below to true. Set to false before deployment to avoid disclosing exception information -->
<serviceDebug includeExceptionDetailInFaults="false"/>
</behavior>
</serviceBehaviors>
</behaviors>
<serviceHostingEnvironment multipleSiteBindingsEnabled="true" /></system.serviceModel>
现在,我需要获取URI访问“ http://localhost/Service1.svc/GetId”,该访问应以JSON数据响应。 但是对我来说,这表明“ HTTP400错误请求”。 帮帮我。
错误的请求可能是所发送的请求无效。 如果无法访问或发现您的服务,则可能是其他Http错误代码。 尝试对您的服务启用跟踪,以查看请求错误的原因。 要启用跟踪,请点击此链接
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.