WCF를 사용하여 고객의 SOAP 서비스에 대해 클라이언트를 작성하고 있습니다.CustomBinding을 통한 선점 인증?
우리는 인증을 얻으려고 많은 시도를 해왔습니다. 웹상의 임의의 녀석이 BasicHttpBinding이 필요한 보안 옵션을 지원하지 않았고 WsHttpBinding이 사용하고있는 SOAP 1.1을 지원하지 않았기 때문에 Custom Binding을 사용하게되었습니다.
그래서, 내가 무엇을 :
var message = this.constructMessagecollection);
if (message != null)
{
var ea = new EndpointAddress(this.webServiceUrl);
var binding = new CustomBinding();
binding.Elements.Add(new TextMessageEncodingBindingElement(
MessageVersion.Soap11, Encoding.UTF8));
binding.Elements.Add(new HttpsTransportBindingElement { AuthenticationScheme = System.Net.AuthenticationSchemes.Basic });
using (var client = new CustomersWebserviceClient(binding, ea))
{
if (!String.IsNullOrWhiteSpace(this.webServiceUsername) && !String.IsNullOrWhiteSpace(this.webServicePassword))
{
var credentials = client.ClientCredentials.UserName;
credentials.UserName = this.webServiceUsername;
credentials.Password = this.webServicePassword;
}
var result = client.ReceiveMessage(message);
log.writeLine(String.Format("Call to client.ReceiveMessage() returned {0}", result));
}
return true;
}
을 지금, 나는 내가 선제 인증을 내 클라이언트를 구성 할 수 있는지 물어 왔습니다. 나는 웹 브라우징을 한 적이 있었고 많이 찾지 못했습니다. 그리고 나는 내가 발견 한 것을 현재 코드에 통합하는 방법을 놓치고 있습니다.
시도 할 때 클라이언트 호출에 예외가 발생합니다. "통신 개체 인 System.ServiceModel.Channels.ServiceChannel은 오류 상태이므로 통신에 사용할 수 없습니다." 나는 내 자신의 헤더를 추가하지 않을 때 그 오류를 얻지 못한다. –
신경 쓰지 마라. ClientCredentials를 설정하는 대신 Basic 인증 헤더를 전달하고있었습니다. 둘 다 할 때, 그 오류가 사라집니다. –