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

1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
5842kr13/6/202312268publish 할 때 분석기 관련 dll 제외 [5]
5841guest3/3/202312619프로그램 판매 시 - Upgrade 버전 판매 [2]
5840joe3/2/202313555C# 클래스 라이브러리 수정 -> C++에서 참조시 함수 목록 갱신되지 않음. [4]파일 다운로드1
5839guest3/2/202313649윈도우 서비스 프로그램 - FORM 애플리케이션 감시서비스 [8]
5838랄랄라3/1/202311549event 사용 시 두 표현의 차이점이 있을까요? [1]
5837감사합니...2/28/202312446오라클 DB서버 접속관련 문의 드립니다.(Load Balancing, HA Events) [2]
5836박지범2/27/202311838static instance의 initialize 순서가 보장되나요? [6]
5835주민호2/25/202319887Windows Software Development Kit - 최신버전 1개 남기고 다 삭제하면 안되는지요? [10]파일 다운로드1
5834guest2/24/202311726Python IDE - 비주얼스튜디오 [3]
5833무지남2/23/202310980Async 메서드 그리고 나서 Bool 메서드 [5]
5832김지우2/21/202311712event와 delegate의 차이 , event를 써야하는 이유 [1]
5831이우람2/20/202313187ref 전역변수가 pinned가 될수 있나요? [2]
5830냉수마찰2/19/202312203C# GridView에 Column별 데이터 추가하는 방법에 대해 [1]
5829수박942/19/202314130키움 API를 윈폼과 WPF의 네임스페이스 없이 콘솔이나 WinUI3에서 사용할 수 있는 방법이 있나요? [2]파일 다운로드1
5828김재영2/19/202312438장기적으로는 this 구문을 안쓰는게 맞을까요? [2]
5827lee2/18/202314520파이썬 설치 오류 질문입니다 [1]
5826Syong2/14/202314326Socket 관련 Leak (OverlappedAsyncResult, OverlappedData) 관련 문의 [7]파일 다운로드1
5825박성원2/14/202313344Listview 컨트롤의 화면 전환 시 갱신 속도 [1]
5823검은콩2/13/202316807catch(Exception ex)의 line번호를 쉽게 알 수 없는지요? [7]
5822김지우2/11/202315779책을 보면서 sync, async 이해가 되지 않는 부분이 있습니다. [5]파일 다운로드2
5821검은콩2/9/202312392Async 신뢰성과 소켓데이터 [4]
5820차가워2/8/202312267다른 프로세스 실행 후 포커스 가져오기 [3]
5819취준생2/7/202312859WPF 관련 실무가 궁금합니다. [3]
5818윤길2/7/202312081ObservableCollection 에서 INotifyPropertyChanged 구현해야하나요? [2]
5817흰털너부리2/7/202311475배포 시 winform 실행 콘솔로그 보는 방법 [1]
5816흰털너부리2/6/202311925.net core json array validation 질문 드립니다. [1]
1  2  3  4  5  [6]  7  8  9  10  11  12  13  14  15  ...