Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 18870
글쓴 사람
임동찬 (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)
5078꾸엉10/29/201815429C# 7.1 185~187p 질문입니다. [2]
5077윤현수10/29/201822419setup파일 설치 이후 실행이 안되는 현상 [11]
5074진우10/28/201815340C# 생성과 동시에 초기화 하는 코드 문의 [2]
5073돌고래10/27/201815235c# 공부 방향 질문 드립니다. [3]
5072엔벌잉10/24/201814941C# textbox, button질문입니다! [4]파일 다운로드1
5071엔벌잉10/23/201816358C#윈도우폼 질문입니다!! [2]
5070진우10/17/201816382Visual Studio 서비스팩과 업데이트 차이 문의 [2]
5069감자10/12/201817009빌드 구성을 재설정하는 방법이 있을까요? [1]파일 다운로드1
5068누오10/10/201815697ASP Core 2.0 에서 dll안에 있는 뷰 읽어들이는 방법? [1]
5067김정민10/5/201816025다른 윈도우가 깨지는 현상을 막을 수 있을까요 [3]
5066로니브10/4/201816691ASP.NET MVC에서 View 파일 숨기는법? 보안처리 하는법? 관련 질문.. [1]
5065키모10/1/201818373문자 질문입니다. [3]
5064로니브10/1/201817694클래스 라이브러리에서 .cshtml파일을 추가하는 방법은 없나요? [3]
5063진우9/28/201816432ADO.net 과 Entity Framework 차이 문의 [2]
5062테스트9/27/201816898C# import file 의 구조체 배열 선언 및 호출에 대해 문의. [3]
5061안녕하세요9/13/201817315c# 프로그래밍 관련 문의 [1]
5060임민재9/8/201816389c# install 파일 생성 시 문제가 발생하였습니다 [1]파일 다운로드1
50599/7/201815831Winform TextBox 포커스 유지하는 방법 질문 [파일첨부] [1]파일 다운로드1
50589/5/201820224Winform TextBox 포커스 유지하는 방법 질문 [3]
5056박종윤8/30/201818899c# dll을 C++에서 사용 시 event 호출 [4]파일 다운로드1
5055초보자8/29/201817688asp.net 에서 다른 서버의 iis를 stop하는 batch file을 실행시키는데 동작하지 않습니다. [5]
5054사도신8/29/201816261[wpf] textbox insert overite 모드시에 [4]파일 다운로드1
5053엿장수8/26/201815225directshow filter 에서의 IMediaSample 의 시간에대한질문입니다 [1]
5052오명현8/26/201815506Tcp소켓 실습 Exeption 도와주세요! [4]파일 다운로드1
5049오명현8/23/201815262책 477페이지 내용 중 이해가 안가는 부분이 있어 질문드립니다. [1]
5048오명현8/23/201814757포트 관련 질문 하나더 있습니다. [1]
... 31  32  [33]  34  35  36  37  38  39  40  41  42  43  44  45  ...