WCFTestClient HTTP 요청이 클라이언트 인증 체계 '익명'으로 인증되지 않은 것입니다.
하나의 WCF 서비스를 만들어 서버에 배포했습니다. 이 서비스를 탐색하면? wsdl URL로 긍정적 인 응답을받습니다. 이제 WCF 테스트 클라이언트를 통해 서비스를 테스트합니다. 메타 데이터를 보여줍니다. 그러나 서비스에서 메서드를 호출하면 예외가 표시됩니다. 여기에 스택 추적이 포함 된 오류 세부 정보가 있습니다.
HTTP 요청이 클라이언트 인증 체계 '익명'으로 인증되지 않음. 서버에서받은 인증 헤더는 'Negotiate, NTLM'입니다.
서버 스택 추적 :
에
System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication (HttpWebRequest를 요청, HttpWebResponse 클래스 응답 WebException이 responseException, HttpChannelFactory 공장)
HTTP 요청이 클라이언트 인증 체계 '익명'무단입니다. 서버에서받은 인증 헤더는 'Negotiate, NTLM'입니다.
서버 스택 추적 :
에서
System.ServiceModel.Channels.HttpChannelUtilities.ValidateAuthentication (HttpWebRequest를 요청, HttpWebResponse 클래스 응답 WebException이 responseException, HttpChannelFactory 공장)
클라이언트 바인딩 :
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_IServiceMagicService" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
bypassProxyOnLocal="false" transactionFlow="false" hostNameComparisonMode="StrongWildcard"
maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true"
allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<reliableSession ordered="true" inactivityTimeout="00:10:00"
enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None"
realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true"
establishSecurityContext="true" />
</security>
</binding>
</wsHttpBinding>
</bindings>
서버 바인딩 :
<bindings>
<wsHttpBinding>
<binding name="WSHttpBinding_SEOService" closeTimeout="00:10:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="999524288" maxReceivedMessageSize="655360000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="900000" maxArrayLength="900000" maxBytesPerRead="900000" maxNameTableCharCount="900000" />
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false" />
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm="" />
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true" />
</security>
</binding>
<binding name="WSHttpServiceMagicBinding" closeTimeout="00:10:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:10:00" bypassProxyOnLocal="true" transactionFlow="false" hostNameComparisonMode="StrongWildcard" maxBufferPoolSize="999524288" maxReceivedMessageSize="655360000" messageEncoding="Text" textEncoding="utf-8" useDefaultWebProxy="true" allowCookies="false">
<readerQuotas maxDepth="32" maxStringContentLength="900000" maxArrayLength="900000" maxBytesPerRead="900000" maxNameTableCharCount="900000"/>
<reliableSession ordered="true" inactivityTimeout="00:10:00" enabled="false"/>
<security mode="None">
<transport clientCredentialType="Windows" proxyCredentialType="None" realm=""/>
<message clientCredentialType="Windows" negotiateServiceCredential="true" establishSecurityContext="true"/>
</security>
</binding>
</wsHttpBinding>
</bindings>
고객의 고객 섹션 :
<client>
<endpoint address="http://hydwebd02.solutions.com/GeoService.Saveology.com/ServiceMagicService.svc"
binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_IServiceMagicService"
contract="IServiceMagicService" name="WSHttpBinding_IServiceMagicService" />
</client>
서버의 서비스 섹션 :
<services>
<service behaviorConfiguration="GeoService.Saveology.com.CityStateServiceProviderBehavior"
name="GeoService.Saveology.com.CityStateServiceProvider">
<endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpBinding_SEOService"
contract="SEO.Common.ServiceContract.ICityStateService" />
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration=""
contract="IMetadataExchange" />
</service>
<service behaviorConfiguration="GeoService.Saveology.com.ServiceMagicServiceProviderBehavior"
name="GeoService.Saveology.com.ServiceMagicServiceProvider">
<endpoint binding="wsHttpBinding" bindingConfiguration="WSHttpServiceMagicBinding"
contract="SEO.Common.ServiceContract.IServiceMagicService">
</endpoint>
<endpoint address="mex" binding="mexHttpBinding" bindingConfiguration="" contract="IMetadataExchange" />
</service>
</services>
내가 호출 한 서비스의 보안 구성을 제어 할 수 없었지만 동일한 오류가 발생했습니다. 다음과 같이 클라이언트를 수정할 수있었습니다.
구성에서 보안 모드를 설정하십시오.
<security mode="TransportCredentialOnly"> <transport clientCredentialType="Windows" proxyCredentialType="None" realm="" /> <message clientCredentialType="UserName" algorithmSuite="Default" /> </security>
코드에서 가장을 허용하도록 프록시 클래스를 설정합니다 (고객이라는 서비스에 대한 참조를 추가했습니다).
Customer_PortClient proxy = new Customer_PortClient(); proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
비슷한 문제가 있습니다.
proxy.ClientCredentials.Windows.AllowedImpersonationLevel =
System.Security.Principal.TokenImpersonationLevel.Impersonation;
내가 찾은이 오류에 대한 또 다른 가능한 해결책입니다. OP의 정확한 질문에 대답하지 않았을 수도 있지만이 오류 메시지를 우연히 발견 한 다른 사람들에게 도움이 될 수 있습니다.
다음 줄을 복제하기 위해 WebHttpBinding을 사용하여 코드로 클라이언트를 생성했습니다.
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" />
</security>
나는해야했다 :
var binding = new WebHttpBinding(WebHttpSecurityMode.TransportCredentialOnly);
binding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Windows;
binding.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Windows;
뿐만 아니라 설정 proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
나는 이것이 아직 답변되지 않은 것을 봅니다. 이것은 여기에서 정확한 인용문 입니다 .
WSHttpBinding은 SSP 계층에서 내부 협상을 시도하고 수행합니다. 이 작업이 성공하려면 VDir에 대해 IIS에서 익명을 허용해야합니다. 그러면 WCF는 기본적으로 창 자격 증명을 위해 SPNEGO에서 수행됩니다. IIS 계층에서 익명을 허용하는 것은 누구에게도 허용되지 않으며 WCF 스택으로 연기됩니다.
http://fczaja.blogspot.com/2009/10/http-request-is-unauthorized-with.html을 통해 이것을 찾았습니다.
비슷한 문제가 있었고 위에서 제안한 모든 것을 시도했습니다. 그런 다음 clientCreditialType을 Basic으로 변경하려고 시도했고 모든 것이 잘 작동했습니다.
<basicHttpBinding>
<binding name="BINDINGNAMEGOESHERE" >
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic"></transport>
</security>
</binding>
</basicHttpBinding>
이 작업을 수행하기 위해 내가해야 할 일은 다음과 같습니다. 이것은 다음을 의미합니다.
- 사용자 지정 UserNamePasswordValidator (Windows 계정, SQLServer 또는 ActiveDirectory 필요 없음-UserNamePasswordValidator는 사용자 이름 및 암호를 하드 코딩하거나 텍스트 파일, MySQL 등에서 읽을 수 있음).
- https
- IIS7
- .net 4.0
내 사이트는 DotNetPanel을 통해 관리됩니다. 가상 디렉터리에 대한 세 가지 보안 옵션이 있습니다.
- 익명 액세스 허용
- 기본 인증 활성화
- 통합 Windows 인증 사용
"익명 액세스 허용"만 필요합니다 (그 자체로는 충분하지 않음).
환경
proxy.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
내 경우에는 차이가 없었습니다.
그러나이 바인딩을 사용하면 효과가 있습니다.
<security mode="TransportWithMessageCredential">
<transport clientCredentialType="Windows" />
<message clientCredentialType="UserName" />
</security>
아래와 같이 클라이언트에 사용자 이름과 비밀번호를 입력하십시오.
client.ClientCredentials.UserName.UserName = @ "도메인 \ 사용자 이름"; client.ClientCredentials.UserName.Password = "암호";
Azure의 스테이징 환경에 외부 서비스를 호출하는 서비스를 배포 한 후 오늘도 동일한 오류가 발생했습니다. 로컬 서비스는 오류없이 외부 서비스를 호출했지만 배포 후에는 그렇지 않았습니다.
결국 외부 서비스에 IP 유효성 검사가있는 것으로 밝혀졌습니다. Azure의 새 환경에는 다른 IP가 있으며 거부되었습니다.
따라서 외부 서비스를 호출하는 동안이 오류가 발생하면
IP 제한 일 수 있습니다.
개발 시스템에서이 문제가 발생했습니다 (프로덕션은 정상적으로 작동합니다). 익명 액세스를 허용하고 내 이름과 암호를 자격 증명으로 사용하도록 IIS에서 내 구성을 수정합니다.
내가 확신하는 최선의 방법은 아니지만 테스트 목적으로 작동합니다.
'ProgramingTip' 카테고리의 다른 글
Excel 스프레드 시트 열을 SQL Server 데이터베이스로 가져 오기 (0) | 2020.11.24 |
---|---|
C ++에서 환경 변수에 액세스 (0) | 2020.11.24 |
Reflection을 사용하여 내부 클래스에 액세스하는 방법 (0) | 2020.11.24 |
WPF의 GroupBox는 하나의 요소 만 포함 할 수 있습니까? (0) | 2020.11.24 |
GCC에서 std = c99 플래그 설정 (0) | 2020.11.24 |