Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 19870
글쓴 사람
임동찬 (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)
5466pr1/29/202114440c# winform load시 작업표시줄에 뜨지 않는 현상을 겪으신적이 있으신가요? [4]파일 다운로드1
5465영귤1/28/202114364두 번째 await 부터는 스레드 개수만 늘어나는 것이 아닌가요 [1]
5464민우1/26/202115941C# 빌드시 코드 치환되는걸 확인하는 방법 문의 [2]
5463한예지 donator1/24/202116666Parameters.AddWithValue 와 Parameters.Add 의 차이점이 궁금합니다. [2]
5462C#초보1/22/202116984사용자 정의 메시지 전달이 가능한가요? [2]
5461한예지 donator1/22/202115168AsEnumerable() 메서드 질문 있습니다! [2]
5459한예지 donator1/21/202114962typeof와 GetType의 차이점 질문있습니다. [2]
5458진우1/20/202116107C# DataTable 에 SQL 쿼리문을 실행하는 방법 문의 (LINQ 사용하지 않고) [6]
5456성민1/17/2021173859.0 출간 계획이 있으신가요? [2]
5455한예지 donator1/16/202115181교재 194페이지 콜백메서드 질문 있습니다! [5]
5454한예지 donator1/15/202113780교재 208쪽 질문....있습니다... [3]
5453안녕하세요1/15/202115729C# dll 파일을 C++에서 사용 시 memory leak 문제 [2]파일 다운로드1
5452예지1/15/202115240var를 사용할 수 없는 이유가 궁금합니다! [3]
5451예지1/14/202113209for문의 초기식에 대해 질문드립니다. [3]
5450예지1/13/202113720Action 델리게이트 사용법 질문있습니다! [2]
5449김성민1/13/202114884Winform UserControl 상속 vs 감싸기? [2]
5448서형주1/13/202114373안녕하세요~~ DataGridView에 데이터를 표시하는 동작방법이 궁금합니다. [2]
5447종범1/11/202115566[WPF/OpenCV] 이미지->영상 저장에 대해서 질문 드립니다!! [5]파일 다운로드1
5446민우1/11/202114008닷넷 런타임을 dll 파일로 포함시킬수 있나요? [2]
5445정도현1/8/202112821directShow RenderFile 관련 재질문드립니다 [5]파일 다운로드1
5444정도현1/8/202113071directShow RenderFile 관련 질문드립니다 [3]
5443윤영호1/7/202113738xml 파일에서 데이터를 가지고 와서 list에 넣는 것을 질문드리고 싶습니다. [1]파일 다운로드1
5442진우1/4/202113118DB연결 객체나 파일 등은 GC 에서 관리해주지 않는 이유가 궁금합니다. [2]
5441한예지 donator1/4/202114225DB 연결 방법 질문 있습니다. [1]
5440한예지 donator1/1/202114381추상클래스로와 new [4]
5439이상호12/31/202018103VC 프로젝트 에서 _main 함수에서 참조되는 확인할 수 없는 외부 기호 [4]파일 다운로드1
... 16  17  18  19  [20]  21  22  23  24  25  26  27  28  29  30  ...