2013-05-03 3 views
0

WCF 테스트 클라이언트를 실행하고 WCF 서비스를 로컬에서 디버깅 할 때 모든 것이 올바르게 작동합니다. 원격 서버의 IIS에 배포 한 다음 WCF 테스트 클라이언트로로드하려고하면 "개체의 인스턴스로 설정되지 않은 개체"오류가 발생합니다. 서비스에 try-catch를 추가했는데 오류가 "Method not allowed"으로 변경되었습니다.WCF 오류 - 메서드가 허용되지 않습니다.

나는 하루 종일이 오류를 읽고 있으며 대부분의 게시물은 JSON 또는 AJAX를 사용하여 WCF 클라이언트에 액세스하는 사람들과 관련이 있습니다. 나는 많은 제안 된 솔루션을 시도해 왔으며 대부분은 web.config에 대한 변경 사항이었습니다. 나는이 단계에서 테스트 클라이언트를 사용하여 간단히 액세스하고 있으며, 일단 입증 된 Winform 애플리케이션에 의해 소비 될 것입니다.

서비스에 공개 된 두 가지 방법 모두 신뢰가 설정되었지만 다른 도메인의 SQL 서버에 대한 연결을 만듭니다. 나는 이것이 문제의 일부가 될 수 있다고 생각하고있다.

내 서비스 인터페이스

[ServiceContract] 
public interface IMeterQueryService 
{ 
    [OperationContract] 
    List<Meter> FindMeter(string mprn); 

구현 서비스

[ServiceBehavior(InstanceContextMode = InstanceContextMode.PerSession)] 
public class MeterQueryService : IMeterQueryService 
{ 
    public List<Meter> FindMeter(string mprn) 
    { 
     using (var da = new DataAccess()) 
     { 

     var meters = da.GetMeter(mprn); 
     da.Dispose(); 
     return meters; 

     } 
    } 

응용 프로그램 구성 파일

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

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="true" /> 
    </system.web> 
    <connectionStrings> 
    <add name="Tims" connectionString="hidden" providerName="System.Data.SqlClient"/> 
    </connectionStrings> 
    <!-- When deploying the service library project, the content of the config file must be added to the host's 
    app.config file. System.Configuration does not support config files for libraries. --> 
    <system.serviceModel> 
    <services> 
     <service name="TimsAPI.MeterQueryService"> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, 
      set the values below to false 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="True" /> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    </system.serviceModel> 
</configuration> 

웹 설정 파일, 사이트는 WCF 서비스 라이브러리를 참조합니다.

<?xml version="1.0"?> 
<configuration> 

    <appSettings> 
    <add key="aspnet:UseTaskFriendlySynchronizationContext" value="true" /> 
    </appSettings> 
    <system.web> 
    <compilation debug="false" targetFramework="4.5" /> 
    <httpRuntime targetFramework="4.5"/> 
    </system.web> 
    <system.serviceModel> 
    <services> 
     <service name="TimsAPI.MeterQueryService"> 
     <endpoint address="http://easvr33:1000/" binding="basicHttpContextBinding" bindingConfiguration="" 
      contract="TimsAPI.IMeterQueryService" /> 
     <endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" 
      contract="IMetadataExchange" /> 
     <host> 
      <baseAddresses> 
      <add baseAddress="localhost" /> 
      </baseAddresses> 
     </host> 
     </service> 
    </services> 
    <behaviors> 
     <serviceBehaviors> 
     <behavior> 
      <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="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="true"/> 
     </behavior> 
     </serviceBehaviors> 
    </behaviors> 
    <protocolMapping> 
     <add binding="basicHttpsBinding" scheme="https" /> 
    </protocolMapping>  
    <serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="false" /> 
    </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"/> 
    </system.webServer> 

</configuration> 

업데이트 나는 WCF 서비스 웹 사이트와 WCF 서비스가 아닌 라이브러리를 다시하고 모두 작동합니다. 내 생각에 2 config 파일 사이에 이상한 것. 여전히 작동하지 않는 이유를 알고 싶지만 소스에 대한 완전한 액세스 권한이없는 사람을 진단하는 것이 어려울 수도 있음을 이해해야합니다.

+0

WCF 추적을 사용하여 잘못된 내용을 확인하십시오. – CodeCaster

+0

호스팅 웹 사이트 web.config에 연결 문자열이 표시되지 않습니다.서비스가 연결 문자열을 사용하여 DB에 액세스해야하는 경우 연결 문자열은 호스팅 응용 프로그램의 web.config에 있어야합니다. 이 서비스에서 사용하는 다른 구성 매개 변수도 동일합니다. –

+0

아, 뭔가있을 수 있습니다. 연결 문자열은 WCF 사이트에서 사용하는 서비스 라이브러리의 app.config에 있습니다. 사이트에서도 cs가 필요하다고 생각하지 않았습니다. 그걸 확인해볼거야. – James

답변

0

WCF 서비스가를 통해 호스팅 IIS 웹 사이트 서비스 app.config은 사용되지 않고 대신 hosing site의 web.config이로드됩니다. 서비스가 작동하는 데 필요한 모든 설정은 호스팅 사이트의 web.config에 복제되어야합니다.

+0

현상금을 신청할 때까지 잠깐 기다려야합니다. – James

0

SVC에 대한 서비스 제공에 문제가있을 수 있습니다. here :

1. 가상 디렉터리의 속성을 엽니 다.

2. 디렉토리 탭으로 이동.

3. 구성을 클릭하십시오. 4.Click 추가

...

5.Provide 다음 정보를

a.Executable : C : \ WINDOWS \ Microsoft.NET 프레임 워크 \ \ V2.0.50727 \

ASPNET_ISAPI.DLL b.Extension :

c.Verbs SVC는 : GET, HEAD, POST, DEBUG

+0

IIS로 웹 사이트로 배포했습니다. 웹 사이트 내의 애플리케이션 또는 VD에 있어야합니까? – James

관련 문제