Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 21149
글쓴 사람
임동찬 (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개의 소스 코드가 합쳐져서 결과물이 나오게 됩니다. ^^
정성태

... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...
NoWriterDateCnt.TitleFile(s)
5165이대희5/22/201916309Visual Studio 설치 구성요소 문의 (C# 7.3 개정판 관련) [1]
5164레드5/21/201919197실행 과정과 실행파일 디버그 시 Icon변경 질문드립니다. [5]
5163이대희5/20/201915864시작하세요 C# 7.3 프로그래밍 책 도착했습니다. [1]
5162채홍윤5/14/201920729Mono Develop window 설치 [6]
5161정대영5/13/201917269VS 2013에서 C#6.0(.netFramwork 4.6.1) $ 디버깅 오류 [1]
5160초보개발자5/13/201919309wcf 관련 국내 서적 살만한 책이 있나요? [2]
5159sdh25/9/201917327VS 2010 버전에서 생성한 DLL을 VS 2017버전에서 실행 시 에러 [2]
5158sdh5/8/201917530Visual studio 2010 버전에서 생성한 Project를 Visual studio 2017버전에서 실행에러 [1]
5157김경훈5/8/201920834Task 만들때 넘겨주는 CancellationToken은 어디서 사용 되는 건가요? [4]
5156rysoo5/8/201920126yield return의 리턴 타입 질문 드립니다. [4]
5155세퉁5/7/201922430관리자 권한으로 실행 시 알림창(?) 없이 바로 실행 시킬 수 있는 방법이 있을까요?? [2]파일 다운로드1
5154Soul...5/4/201916876NamedPipe 질문드립니다. [2]
5153개태5/4/201918286WCF RESTful Service에서 enum을 parameter로 쓰는방법 [2]
5152세퉁5/3/201919566인터넷 시간을 불러와 pc에 적용 시키고 싶습니다. [3]파일 다운로드1
5151이대희5/3/201916062C# 7.3으로 개정판 출간 계획이 있으신가요? [1]
5150김이현5/2/201919743C# 딕셔너리 생성에 대해 질문드립니다. [1]
5149민성5/1/201917135ftp 이미지 업로드중 [1]
5148wpf질문4/30/201917180특정 사이트를 wpf에서 popup을 항상 허용하게 할려면 어떻게 해야할까요? [5]
5147민성4/30/201915849wpf에서 작업관리자를 띠울려면 어떻게 해야 하나요? [1]
5146불파겐4/25/201915728하나의 필드를 여러 스레드에서 읽어갈 때 스레드 동기화를 하지 않으면 문제가 생길까요? [2]
5145e구름4/17/201919934Properties.Setting.Default값에 대해 질문드립니다. [2]
5144성태님 ...4/17/201916836질문하시기 전에 10000 페이지 오류 납니다. [1]
5143헌이4/16/201917814윈도우 작업표시줄에 프로그램 띄우기 [2]파일 다운로드1
5142cab2...4/9/201924351C#으로 만든 DLL 배포하기 [10]
5141하늘사랑4/5/201918896Axinterop 래퍼에 관해서 질문드립니다. [7]
5140게스트4/1/201917435안녕하세요. 초보 개발자입니다. SD리더기에서 SD카드를 꽂으면 발생하는 이벤트 문의 [2]
... 16  17  18  19  20  21  22  23  24  25  26  27  28  29  [30]  ...