외부 서비스에서 클라이언트 프록시를 구성하기 위해이 web.config 파일을 사용했습니다.이 서비스는 메시지 헤더에서 인증을 필요로했지만, web.config에서 잘 구성되었지만 코드에서이 구성으로 프록시를 만들려고합니다. 사용자와 암호가 동적으로 변경되도록 제안합니다.프로그래밍 방식으로 끝점 머리글 보안 WCF 추가
<cliente>
<endpoint address="https://wwwww.hhhahdhadhs.askadadasda" binding="basicHttpBinding" bindingConfiguration="MyConfiguration" contract="PROXY_ACSS_SERVICES.RegistoPrescricaoMedicamentos">
<headers>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>MyUser</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">87726655434</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
</endpoint>
</cliente>
<basicHttpBinding>
<binding name="PrescricaoMedicamentos" closeTimeout="00:01:00" openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard" maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536" messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered" useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384" maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="Transport">
<transport clientCredentialType="None" proxyCredentialType="None" realm="" />
<message clientCredentialType="Certificate" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
내 문제는 사용자 이름과 암호를 정의 헤더를 만드는 것입니다, 사전에
<headers>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>MyUser</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">87726655434</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
감사
편집
라디 Mrnka 나는 프록시 프로그램이 메시지가 나타납니다 만든 후
' 00 : 00 : 59.9829990 이후에 요청 채널에서 시간이 초과되었습니다. 에 대한 호출에 전달 된 제한 시간 값을 늘리십시오. 바인딩에서 SendTimeout 값을 요청하거나 늘리십시오. 이 작업에 할당 된 시간이 시간 초과의 일부일 수 있습니다. '
이
은 AddressHeader.CreateAddressHeader처럼 .. 코드에서 모든 메시지에 뭔가를 정적 헤더를 추가 가능한 경우 궁금내 프록시 구성
BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential);
binding.Name = "PrescricaoMedicamentos";
binding.CloseTimeout = new TimeSpan(0, 1, 0);
binding.OpenTimeout = new TimeSpan(0, 1, 0);
binding.ReceiveTimeout = new TimeSpan(0, 10, 0);
binding.SendTimeout = new TimeSpan(0, 1, 0);
binding.AllowCookies = false;
binding.BypassProxyOnLocal = false;
binding.HostNameComparisonMode = HostNameComparisonMode.StrongWildcard;
binding.MaxBufferSize = 65536;
binding.MaxBufferPoolSize = 524288;
binding.MaxReceivedMessageSize = 65536;
binding.MessageEncoding = WSMessageEncoding.Text;
binding.TextEncoding = System.Text.Encoding.UTF8;
binding.TransferMode = TransferMode.Buffered;
binding.UseDefaultWebProxy = true;
binding.ReaderQuotas = new XmlDictionaryReaderQuotas()
{
MaxDepth = 32,
MaxStringContentLength = 8192,
MaxArrayLength = 16384,
MaxBytesPerRead = 4096,
MaxNameTableCharCount = 16384
};
binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName;
return binding;
}입니다 ('인증 헤더') 이 헤더를 내 EndpointAddress 구성에 적용하십시오. 문자 접근 대체 이런 종류의 서비스가 올바르게 사용자 이름 토큰 프로파일 변화를 구현하는 경우 내 첫 번째 코드
<headers>
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
<wsse:UsernameToken>
<wsse:Username>myusername</wsse:Username>
<wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">mypass</wsse:Password>
</wsse:UsernameToken>
</wsse:Security>
</headers>
내 클라이언트 응용 프로그램에서이 예외가 발생하는 서비스에 연결하려고 시도했지만 제안을 사용했습니다. 보안 프로세서가 메시지에서 보안 헤더를 찾을 수 없습니다. 메시지가 보안되지 않은 오류이거나 통신 당사자간에 바인딩 불일치가 있기 때문일 수 있습니다. 이 서비스는 보안을 위해 구성되었으며 클라이언트가 보안을 사용하지 않는 경우 발생할 수 있습니다. ' 이걸로 나를 도울 수 있니? 감사합니다 – mastervv
[메시지 로깅] (http://msdn.microsoft.com/en-us/library/ms730064.aspx)을 켜고 서비스에서 반환되는 내용을 확인하십시오. 시간 소인이 없으면 오류 또는 메시지입니다. –