나는 HTTPS에있는 WCF 메서드를 연결하고 사용하는 방법이 있는데 .net 4에서 사용자 이름과 암호가 필요합니다.이제는 동일하지만 내부에서해야합니다. 2 나는 그것을 작동시킬 수없는 것 같습니다. 나는 아래의 오류를 계속하고있다. 누구든지 도와 줄 수 있습니까?.net 2에서 WCF 사용하기
오류가 { "기본 연결이 닫혔습니다. : 예기치 않은 오류가 수신에 발생했습니다"} 내부 예외 { "전송 연결에서 데이터를 읽을 수 없습니다 : 기존의 연결이 강제로 원격으로 폐쇄되었다 호스트 "}
닷넷 4 원본 코드 :.
WSHttpBinding myBinding = new WSHttpBinding();
myBinding.Security.Mode = SecurityMode.Transport;
myBinding.Security.Transport.ClientCredentialType = HttpClientCredentialType.Basic;
EndpointAddress ea = new EndpointAddress(wcfURL);
var web = new Gateway.GatewayClient(myBinding, ea);
// var web = new Gateway.GatewayClient();
XMLCrypto crypto = new XMLCrypto();
web.ClientCredentials.UserName.UserName = crypto.DecryptString(username);
web.ClientCredentials.UserName.Password = crypto.DecryptString(password);
web.Open();
web.Inbound("HOLog", message.Trim().Replace("\n", "").Replace(@"\\", ""));
web.Close();
닷넷이 코드
XMLCrypto crypto = new XMLCrypto();
url = "http://..../gateway/gateway.svc";
userName = crypto.DecryptString(userName);
password = crypto.DecryptString(password);
var web = new Gateway.Gateway();
var credentials = new NetworkCredential(userName, password);
CredentialCache credentialCache = new CredentialCache();
credentialCache.Add(new Uri(url), "Basic", credentials);
web.Credentials = credentials;
string returnMessage = web.Inbound("LSOA", " ");