2014-06-18 1 views
0

WCF Rest 웹 사이트를 만들고 있지만 web.config를 구성하는 방법을 알 수 없습니다. 온라인에서 몇 가지 예를보고 있지만 나머지는 모두 비 안정적입니다. WCF Rest로 작업 한 것은 처음이기 때문에 바인딩 이외의 구성에서 어떤 차이가 있는지 모르겠습니다.WCF Rest Service 용 web.config를 구성하는 방법은 무엇입니까?

IIS 서버에 WCF 사이트를 배포했으며 svc.myproj.com/AccountService.svc로 이동할 때 기본 WCF 페이지에 액세스 할 수 있습니다. 심지어 같은 URL을 사용하여 클라이언트를 생성하는 svcutil 사용할 수 있지만 내 클라이언트 응용 프로그램에서 해당 서비스에 연결하려고 할 때마다 끝점을 찾을 수 없습니다 예외가 발생합니다.

아이디어가 있으십니까?

여기 내 AccountService.svc입니다 :

[ServiceContract] 
public class AccountService { 

     [OperationContract] 
     public bool IsRegisteredUser(string emailOrUsername) 
     { 
      return this.GetUser(emailOrUsername) != null; 
     } 
} 

을 그리고 여기 내 Web.config의의 :

<?xml version="1.0" encoding="utf-8"?> 
<configuration> 
    <configSections> 

    <section name="entityFramework" type="System.Data.Entity.Internal.ConfigFile.EntityFrameworkSection, EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" requirePermission="false" /> 
    <!-- For more information on Entity Framework configuration, visit http://go.microsoft.com/fwlink/?LinkID=237468 --></configSections> 
    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5" /> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="MyProj.Services.AccountService" behaviorConfiguration="ServiceBehavior"> 
     <endpoint address="/AccountService.svc" behaviorConfiguration="MyProj.Services.AccountServiceAspNetAjaxBehavior" 
      binding="webHttpBinding" contract="MyProj.Services.AccountService" /> 
     </service> 
    </services> 
    <behaviors> 
     <endpointBehaviors> 
     <behavior name="MyProj.Services.AccountServiceAspNetAjaxBehavior"> 
      <enableWebScript /> 
     </behavior> 
     </endpointBehaviors> 
     <serviceBehaviors> 
     <behavior name="ServiceBehavior"> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" /> 
      <serviceDebug includeExceptionDetailInFaults="true" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping> 
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" 
     multipleSiteBindingsEnabled="true" /> 
    </system.serviceModel> 
    <system.webServer> 
    <modules runAllManagedModulesForAllRequests="true" /> 
    <!-- 
     To browse web app root directory during debugging, set the value below to true. 
     Set to false before deployment to avoid disclosing web app folder information. 
     --> 
    <directoryBrowse enabled="true" /> 
    <validation validateIntegratedModeConfiguration="false"/> 
    </system.webServer> 
    <entityFramework> 
    <defaultConnectionFactory type="System.Data.Entity.Infrastructure.LocalDbConnectionFactory, EntityFramework"> 
     <parameters> 
     <parameter value="v11.0" /> 
     </parameters> 
    </defaultConnectionFactory> 
    <providers> 
     <provider invariantName="System.Data.SqlClient" type="System.Data.Entity.SqlServer.SqlProviderServices, EntityFramework.SqlServer" /> 
    </providers> 
    </entityFramework> 
    <runtime> 
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1"> 
     <dependentAssembly> 
     <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" /> 
     <bindingRedirect oldVersion="0.0.0.0-6.0.0.0" newVersion="6.0.0.0" /> 
     </dependentAssembly> 
    </assemblyBinding> 
    </runtime> 
</configuration> 

감사합니다!

답변

0

대신 <enableWebScript /> 당신은, 덕분에 그 행동 태그 안에 할 수 있는지, 또한 그 시도 IsRegisteredUser

[OperationContract] 
[WebInvoke(UriTemplate = "/IsRegisteredUser", BodyStyle = WebMessageBodyStyle.Bare, Method = "POST", ResponseFormat = WebMessageFormat.Json)] 
public bool IsRegisteredUser(string emailOrUsername) 
{ 
    return this.GetUser(emailOrUsername) != null; 
} 
+0

의 장식을 나는 거있어 변화 시도 <webHttp/>를 사용하여 시도해 볼 수도 있습니다! – eestein

+0

고맙다, 고마워. – eestein

관련 문제