2017-03-26 4 views
-1

Windows 클라이언트가 사용하고 사용할 HTTP wcf 서비스를 만들었습니다. 내가 HTTP를 사용할 때까지 나는 아무런 문제도 없었다. 이제 고객이 사이트를 HTTPS로 변경하려고합니다. 따라서 개발 목적으로 IIS express 인증서를 사용하고 서비스를 설정했습니다. 이제 iisexpress 자체 서명 인증서로 IIS에서 서비스가 실행 중입니다. 브라우저 및 wcf 테스트 클라이언트 도구를 통해 새로운 https 서비스를 검색 할 수 있습니다.http에서 https로 변경 한 후 클라이언트에서 메서드를 호출하면 WCF 서비스에서 오류를 반환합니다. "ContractFilter EndpointDispatcher에서 일치하지 않습니다."

하지만 내 Windows 응용 프로그램에서 새 https wcf 서비스로 메소드를 호출 해 봅니다. 내 서비스 인스턴스가 만들어집니다 만 메소드를 호출하는 동안 나는 오류 다음 얻을 : 내 바인딩 설정 (설정 3 HTTPS 모드 설정 (2)는 HTTP 모드에서 사용에서 사용되는) 서비스에서

System.ServiceModel.ActionNotSupportedException was unhandled by user code HResult=-2146233087 Message=The message with Action ' http://schemas.xmlsoap.org/ws/2005/02/rm/CreateSequence ' cannot be processed at the receiver, due to a ContractFilter mismatch at the EndpointDispatcher. This may be because of either a contract mismatch (mismatched Actions between sender and receiver) or a binding/security mismatch between the sender and the receiver. Check that sender and receiver have the same contract and the same binding (including security requirements, e.g. Message, Transport, None).

가 같다 다음 : 클라이언트에서

<bindings> 
    <wsHttpBinding> 
    <binding name="wsHttpBinding_IPGPService"> 
     <!--config test 1 - start --> 
     <!--<security mode="None"> 
     <transport clientCredentialType="None" /> 
     <message establishSecurityContext="false" /> 
     </security>--> 
     <!--config test 1 - end --> 
     <!--config test 2 - start --> 
     <!--<security mode="None" /> 
      <reliableSession enabled="true" />--> 
     <!--config test 2 - end --> 
     <!--config test 3 - start --> 
     <!--<security mode="Transport">    
     <transport clientCredentialType="None" proxyCredentialType="None"/> 
     <message clientCredentialType="Certificate" algorithmSuite="Default" /> 
     </security>--> 
     <security mode="Transport">    
     <transport clientCredentialType="None"/> 
     </security> 
     <!--config test 3 - end --> 
    </binding> 
    </wsHttpBinding> 
</bindings> 

<services> 
    <service name="PGPService.PGPService"> 
    <endpoint address="" binding="wsHttpBinding" contract="PGPService.IPGPService" bindingConfiguration="wsHttpBinding_IPGPService" /> 
    <endpoint address="mex" binding="mexHttpsBinding" contract="IMetadataExchange" />  
    </service>  
</services> 



    <serviceBehaviors> 
    <behavior> 
     <!-- To avoid disclosing metadata information, set the values below to false before deployment --> 
     <!--<serviceMetadata httpGetEnabled="true" httpsGetEnabled="true"/> --> 
     <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="false"/>--> 
     <!--test config - start--> 
     <serviceDebug includeExceptionDetailInFaults="True" /> 
     <!--test config - end--> 
    </behavior> 
    </serviceBehaviors> 
</behaviors> 
<protocolMapping> 
    <add binding="basicHttpsBinding" scheme="https" /> 
</protocolMapping>  
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" /> 

우리는 서비스 인스턴스를 생성하는 사용자 정의 바인딩을 사용. 서비스를 추가 한 후

     url = "https://localhost:550/TestService/TestService.svc"; 
        customBinding = new CustomBinding(); 
        customBinding.Elements.Add(new ReliableSessionBindingElement()); 
        customBinding.Elements.Add(new HttpsTransportBindingElement()); 
        EndpointAddress endpointAdress = new EndpointAddress(url); 
        pgpServiceClientInstance = new PGPServiceClient(customBinding, endpointAdress); 
        pgpServiceClientInstance.ClientCredentials.ClientCertificate.SetCertificate(
         StoreLocation.CurrentUser, 
         StoreName.Root, 
         X509FindType.FindByThumbprint, 
         ‎"03815c894b62dcf2d17336ade2d9ca61ddb7f92c"); 

다음과 같이 내 Windows 응용 프로그램에 생성의 app.config은 참조 :

 <bindings> 
     <wsHttpBinding> 
      <binding name="WSHttpBinding_IPGPService"> 
       <security mode="Transport"> 
        <transport clientCredentialType="None" /> 
       </security> 
      </binding> 
     </wsHttpBinding> 
    </bindings> 
    <client> 
     <endpoint address="https://localhost:550/TestService/TestService.svc" 
      binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IPGPService" 
      contract="PGPServiceReference.IPGPService" name="WSHttpBinding_IPGPService" /> 
    </client> 

그래서 지금은 내 서비스 인스턴스가 성공적으로 만들어지고 볼 수 있습니다. 메소드를 호출 할 때 오류가 발생합니다.

서비스 종료시 https로 이동하기 전후에 코드가 변경되지 않았습니다. 그것은 동일한 서비스 코드입니다. 그것은 http에서 완벽하게 작동했지만 https에서는 깨졌습니다.

wcf 서비스 https를 만든 후 서비스 참조를 완전히 제거하고 새로 추가했습니다. IIS Express 자체 서명 인증서가 이미 설치되어 있으며 시스템에서 사용할 수 있습니다. 서비스와 클라이언트 모두 현재 개발 중이므로 동일한 시스템에서 실행 중임

구성 문제가 있다고 의심됩니다.하지만 경험이 부족하여 알아낼 수 없었습니다.

+0

"HTTPS를 사용하여 IIS에서 사이트에 바인딩을 추가 했습니까?"라는 질문에 대한 답변을 받았습니다 (의견이 있어야 함). 좋은 질문 인 것처럼 들리므로 댓글에 답하십시오. 답변은 당연히 삭제 될 것입니다. – halfer

+0

HTTPS를 사용하여 IIS의 사이트에 바인딩을 추가 했습니까? – Parag

+0

예 바인딩이 https를 지원하도록 IIS에 추가되었습니다. 내 문제는 코드 현명하고 바인딩을 관련이 있었다. 아래 답변 포함 –

답변

0

실제로 서비스 인스턴스화 중에 문제를 일으키는 추가 바인딩이있었습니다. 인스턴스화 부분에서 아래 줄에 주석을 달아 정렬했습니다.

url = "https://localhost:550/TestService/TestService.svc"; 
       customBinding = new CustomBinding(); 
       //customBinding.Elements.Add(new ReliableSessionBindingElement()); 
       customBinding.Elements.Add(new HttpsTransportBindingElement()); 

전체 서비스 및 클라이언트를 개발하는 데 도움이되었습니다. 위와 같은 문제가 해결되었습니다.

내가 wcf 서비스에 초보자 인 이래로 차선을 내려 가면 나는 직면하고 해결 한 다음과 같은 문제에 직면했다. 충분한 권한을 가진 서비스 또는 관리자 계정으로 별도의 응용 프로그램 풀을 추가 : 내 오류

  1. 에 직면하는 경우 나 같은 어려움을 겪고 누군가가 내 서비스가 문제가 폴더를 수정에 접속 한 다음 단계 아래에 사용할 수 있습니다.

  2. 기존 코드에 wcf 세션을 추가하려면. 수정 : 전송 보안과 함께 wshttpbinding을 사용했기 때문에 문제가 발생합니다.그런 다음 몇 가지 자료와 코드를 탐색 한 후 개발을 진행하려면 reliablesession 및 httpstransport를 사용하여 custombinding으로 설정을 변경해야합니다. 그래서 내 설정은 대략 또한 보안의 기본 지원을 위해 신뢰할 수있는 세션 태그의 모든 값의 실제 purpose.No의 필요성을 이해하고 httpsTransport 후 서비스 인스턴스의 선 위에 주석 처리

    <customBinding abc of wcf> 
        <reliableSession/> 
        <httpsTransport/> 
    <\customBinding> 
    

으로 그리고 나타납니다.

이렇게하면 두 번째 문제가 해결되었습니다.

  1. 그러나 지금 wcf 클라이언트 테스트 도구에서 wsdl 가져 오기 오류가 발생하여 해결하기 위해 노력하고 있습니다. svcutil 프록시 생성 옵션 또는 unrefked 어셈블리 옵션으로 서비스 refrence를 추가 doesnt 작동하는 것 같습니다. 또한 클라이언트에 내 서비스 refrence를 새로 추가하더라도 app.config 파일에 아무런 구성도 생성되지 않고 놀랍게도 ..... 위에서 언급 한 옵션은 전문가의 아이디어를 찾는 데 도움이되지 않습니다 ..... 수정 : ??? Expolring .... 이것을 읽는 영혼은 대답/제안을주기를 원합니다.