2013-05-30 2 views
0

Asp.net에서 WCF 서비스를 사용하고 싶습니다. Web site.i에 Refrence를 추가하면 Web.Config 파일을 업데이트하고 싶지 않습니다.코드에서 WCF 서비스 구성 설정 ASP.net의 배후

나는 뒤에

WSHttpBinding 
EndpointIdentity 
Uri 
ContractDescription 

손잡이 형태의 코드와 같은 코드 Behind.All 구성 속성에서 WCF 서비스를 처리 할.

답변

1

주소를 사용하여 끝점을 만들고 웹 서비스에서 지원하는 바인딩을 기반으로 바인딩을 만들면 프록시를 만들고 서비스를 소비하게됩니다.

// Specify an end point address of the service 
EndpointAddress endpointAdress = new EndpointAddress(serviceUrl); 

// Create the binding to be used by the service 
BasicHttpBinding binding1 = new BasicHttpBinding(); 

//customize the binding configurations like the ones below 
binding.SendTimeout = TimeSpan.FromMinutes(1); 
    binding.OpenTimeout = TimeSpan.FromMinutes(1); 
    binding.CloseTimeout = TimeSpan.FromMinutes(1); 
    binding.ReceiveTimeout = TimeSpan.FromMinutes(10); 

//create the client proxy using the specific endpoint and binding you have created 
YourServiceClient proxy = new YourServiceClient(binding1, endpointAddress); 

또는 당신이에 표시됩니다 일반적인 접근 방식 따르도록 ChannelFactory을 사용할 수있는 방법을-가이드 here