0
我正在Azure中开发一个WCF WebRole服务,并且需要调用一种为JSON格式提供员工数据的方法。但与普通的WCF Web服务不同,我不知道如何为WCF Webrole配置“Web.config”,以及我的代码的 “web.config” 正常WCF服务如下:如何在Azure中创建WCF服务时配置webHttp绑定?
<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(天青)代码的 “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坏请求”。帮帮我。
你从哪里调用? “本地主机”是指你的本地主机,呃主机;如果您想调用您的Azure服务,则需要替换您分配给它的主机名。 – 2012-01-04 15:48:36
嗨,我只在本地主机中调用此服务。而我仅使用Compute Emulator而不使用Azure订阅。 – 2012-01-05 05:54:25