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

... 31  [32]  33  34  35  36  37  38  39  40  41  42  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
5069감자10/12/20189029빌드 구성을 재설정하는 방법이 있을까요? [1]파일 다운로드1
5068누오10/10/20187801ASP Core 2.0 에서 dll안에 있는 뷰 읽어들이는 방법? [1]
5067김정민10/5/20187794다른 윈도우가 깨지는 현상을 막을 수 있을까요 [3]
5066로니브10/4/20188581ASP.NET MVC에서 View 파일 숨기는법? 보안처리 하는법? 관련 질문.. [1]
5065키모10/1/20189781문자 질문입니다. [3]
5064로니브10/1/20189124클래스 라이브러리에서 .cshtml파일을 추가하는 방법은 없나요? [3]
5063진우9/28/20188136ADO.net 과 Entity Framework 차이 문의 [2]
5062테스트9/27/20188679C# import file 의 구조체 배열 선언 및 호출에 대해 문의. [3]
5061안녕하세요9/13/20188667c# 프로그래밍 관련 문의 [1]
5060임민재9/8/20188135c# install 파일 생성 시 문제가 발생하였습니다 [1]파일 다운로드1
50599/7/20187835Winform TextBox 포커스 유지하는 방법 질문 [파일첨부] [1]파일 다운로드1
50589/5/201811248Winform TextBox 포커스 유지하는 방법 질문 [3]
5056박종윤8/30/201810582c# dll을 C++에서 사용 시 event 호출 [4]파일 다운로드1
5055초보자8/29/20189208asp.net 에서 다른 서버의 iis를 stop하는 batch file을 실행시키는데 동작하지 않습니다. [5]
5054사도신8/29/20187916[wpf] textbox insert overite 모드시에 [4]파일 다운로드1
5053엿장수8/26/20187288directshow filter 에서의 IMediaSample 의 시간에대한질문입니다 [1]
5052오명현8/26/20188174Tcp소켓 실습 Exeption 도와주세요! [4]파일 다운로드1
5049오명현8/23/20187541책 477페이지 내용 중 이해가 안가는 부분이 있어 질문드립니다. [1]
5048오명현8/23/20187232포트 관련 질문 하나더 있습니다. [1]
5047오명현8/22/20187905포트가 없을 경우를 가정한 내용에 대해 질문이 있습니다. 책468p. [1]
5046엿장수8/22/20187784다이렉트쇼 필터 추가하는데 [2]
5045임도진8/22/20188510c# opencv dll파일 로드 질문 [3]파일 다운로드1
5044엿장수8/20/20188205graphedit 에 등록되어있는 필터를 가져와서 사용하는방법을 알고싶습니다 [2]
5043hori...8/20/20187823Expression에 대한 책의 예제 관련하여 질문드립니다. [1]
5042황윤하8/20/20189546모드버스 TCP 관련 질문 [3]
5041david8/18/20189209.NET WebAPI 에서 Response 지연되는 이유 [3]
... 31  [32]  33  34  35  36  37  38  39  40  41  42  43  44  45  ...