Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 20831
글쓴 사람
임동찬 (dngchn.im at samsung.com)
홈페이지
첨부 파일
 

안녕하세요.
오랫만에 또 질문 있어 찾아왔습니다.
(늦었지만 새해 복 많이 받으세요.)

WCF 클라이언트를 만드는데요.
Service Reference에 서비스 참조를 하여
자동으로 프록시 코드를 생성해서 사용하려고 합니다.

프록시에 정의된 서비스의 클라이언트 생성자에 대해서 인데요.
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "4.0.0.0")]
    public partial class CalculatorServiceClient : System.ServiceModel.ClientBase<Microsoft.Samples.Discovery.ServiceReference1.ICalculatorService>, Microsoft.Samples.Discovery.ServiceReference1.ICalculatorService {

        public CalculatorServiceClient(System.ServiceModel.Description.ServiceEndpoint serviceEndpoint)
            : base(serviceEndpoint)
        {
        }
프록시에 위와 같이 생성자가 정의되고,
CalculatorServiceClient client = new CalculatorServiceClient(serviceEndpoint);
위와 같이 프록시 클라이언트를 생성해서 사용하고자 합니다.

그런데 프록시 코드를 생성해보면,
public CalculatorServiceClient() {
        }
        
        public CalculatorServiceClient(string endpointConfigurationName) :
                base(endpointConfigurationName) {
        }
        
        public CalculatorServiceClient(string endpointConfigurationName, string remoteAddress) :
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public CalculatorServiceClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress) :
                base(endpointConfigurationName, remoteAddress) {
        }
        
        public CalculatorServiceClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress) :
                base(binding, remoteAddress) {
        }

위와 같이 생성자의 파라미터가 endpoint가 아닌 string 타입의 endpointconfigurationname으로 만들어 지네요.

물론 자동 생성된 이후에 프록시 생성자를 System.ServiceModel.Description.ServiceEndpoint 타입으로 수동 편집 하면 되겠지만,
서비스 업데이트 할때마다 매번 해줘야 하게 되니, 뭔가 방법이 있을 듯 한데, 어떻게 하면 될까요?









[최초 등록일: ]
[최종 수정일: 2/11/2011]


비밀번호

댓글 작성자
 



2011-02-12 01시05분
그래서 ^^ partial 예약어가 빛을 발합니다. 위의 프록시 클래스가 생성되는 프로젝트에 임의의 cs 파일을 추가하고, 거기에

partial class CalculatorServiceClient
{
  public CalculatorServiceClient(System.ServiceModel.Description.ServiceEndpoint ...);
}
라고 코드를 넣어주시면 됩니다. 그럼, 프록시 업데이트는 그 나름대로 계속 진행될 것이고 위에 추가된 파일은 변경되지 않고 남게 되므로 빌드시 에 2개의 소스 코드가 합쳐져서 결과물이 나오게 됩니다. ^^
정성태

... 61  [62]  63  64  65  66  67  68  69  70  71  72  73  74  75  ...
NoWriterDateCnt.TitleFile(s)
1094고민남10/6/201220810NScreen 에 대해 어떻게 생각하십니까? [1]
1093이지수10/6/201220170vbs [1]
1092김성수9/20/201221239안녕하세요? MS Windows server 2008 R2 에서 IIS7 의 SSL 설정시에 에러 해결좀 도와주세요 [1]
1089한상욱9/13/201221238azure에 관한 질문입니다. [1]
1088김영대9/12/201223841DirectX.AudioVideoPlayBack 참조하여 wav 재생기를 제작하여 SmartClient 를 이용하여 aspx 페이지에 Embed 하는 과정의 질문 사항입니다. [2]
1087한우주9/10/201224519SSL 모든 웹페이지에 적용해야하나요? [2]
1086한우주9/4/201222084SSL 인증서 범용으로 사용하기 [3]
1085한우주9/4/201219860개발환경구성 18.3.1 에 대한 문의 [2]파일 다운로드1
1084김종하9/3/201220875team foundation express 2012에서 새 프로젝트 생성... [3]
1082김대경8/23/201219824windows2008 에서 ActiveX 사용 시 문제점. [3]
1091김대경9/20/201219858    답변글 [답변]: windows2008 에서 ActiveX 사용 시 문제점. [2]파일 다운로드1
1081Seon...8/20/201221844WCF 파일 업,다운로드 문제 [2]
1080배동선8/13/201221071정품 라이센스 인증 개발에 대해 조언을 구하고 싶습니다 [4]
1079송준호8/11/201218867basicHttpBinding stream 전송에 관하여 질문드립니다. [1]
1078Ho S...8/10/201217923윈도우폰 지도 구현에서 ㅠㅠㅠ 질문드립니다. [1]파일 다운로드1
1077한우주8/6/201220552웹서비스 호출 후 세션 유지하기 [1]
1076이성환8/2/201221284dynamic 변수 할당은 도대체 어디에???? [1]
1073pass...7/24/201220636c# 으로 만드는 음성인식/TTS 프로그램에 관련해서.. [3]
1072일반인7/23/201223376rss 만드는 방법 알려주실 수 있으신가요? [5]
1069임경훈7/20/201224809아래와 같은 오류후 IIS가 다운되는 현상이 발생합니다. [1]
1068신호철6/15/201222834ClassLibrary COM+ 등록 안되는 현상 [2]
1067김은주6/14/201233194소스세이프 사용시 pfx 파일 빌드 실패 [3]
1066너무초보6/3/201219490안녕하세요! 디렉토리 삭제 오류 질문 좀 드립니다. [4]
1065이성환5/23/201221444Assembly.LoadFrom Assembly.Load 의 차이점이 궁금합니다. [2]파일 다운로드1
1064푸우5/21/201220299GPU 디바이스 재시작시 WPF + .NET 3.5 기반 어플리케이션 UI 문제 [2]
1063발코더5/20/201220186귀신 곡할 상황 질문입니다. [3]
... 61  [62]  63  64  65  66  67  68  69  70  71  72  73  74  75  ...