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