2012-01-04 2 views
0

Azure에서 WCF WebRole 서비스를 개발 중이며 직원 데이터를 JSON 형식으로 제공하는 메서드를 호출해야합니다. 그러나 일반적인 WCF 웹 서비스와 달리 WCF Webrole에 대한 "Web.config"를 구성하는 방법을 알지 못합니다. 일반 WCF 서비스에 대한 내 코드 "의 Web.config"는 다음과 같습니다 : 지금은 필요Azure에서 WCF 서비스를 만드는 동안 webHttp Binding을 구성하는 방법은 무엇입니까?

<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> 

을 따를

<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은" URI 액세스 "http : //localhost/Service1.svc/GetId"를 가져와 JSON 데이터로 응답해야합니다. 하지만 나에게 그것은 "HTTP400 Bad Request"를 보여주고있다. 도와주세요.

+0

어디에서 호출 하시겠습니까? "localhost"는 로컬, 어, 호스트를 나타냅니다. Azure 서비스를 호출하려면 할당 한 호스트 이름을 대체해야합니다. –

+0

안녕하세요, 저는이 서비스를 로컬 호스트에서만 호출하고 있습니다. 그리고 Compute Emulator 만 사용하고 Azure Subscription을 사용하지 않습니다. –

답변

0

잘못된 요청은 전송 된 요청이 유효하지 않을 수 있습니다. 서비스에 액세스 할 수 없거나 다른 Http 오류 코드를 발견했을 수 있습니다. 서비스에 대한 추적을 사용하여 잘못된 요청의 원인을 확인하십시오. 추적을 사용하려면 다음을 수행하십시오. link

관련 문제