Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사]
조회: 12829
글쓴 사람
임동찬 (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)
4966포플러3/30/20189550    답변글 [답변]: C# 응용프로그램 (Winform)에서 unhandledexception 발생시 프로그램이 죽는 현상 이외에 재부팅될 수도 있을까요? [1]
4961김민욱3/26/201810469레이더 뷰어의 구현 방법(이미지 확대 축소 관련) [2]
4960hurd...3/18/201810152OCX 관련한 질문을 드리고자 합니다. [1]
4959익명3/10/20189178교재 199page 델리게이트와 object를 이용한 범용 정렬 코드 [1]
4957멍멍이2/13/20189772System.Console - WriteLine함수의 제너릭 사용 [1]
4956김성대2/12/20189082asp.net 질문입니다. [1]
4955웅이2/12/20189620[삭제] WPF에서 list 속도 향상하는 방법이 있을까요?
4954초보자2/8/201811364FFT Library 사용 [1]
4950ASP열공2/5/20189108asp.net 과 C# 을 이용해서 홈페이지 만드는 질문입니다. [1]
4951ASP열공2/6/201810087    답변글 [답변]: asp.net 과 C# 을 이용해서 홈페이지 만드는 질문입니다. [1]
4952ASP열공2/7/20189222        답변글 [답변]: [답변]: asp.net 과 C# 을 이용해서 홈페이지 만드는 질문입니다. [1]
4953ASP열공2/7/20188755            답변글 [답변]: [답변]: [답변]: asp.net 과 C# 을 이용해서 홈페이지 만드는 질문입니다.
4949김성대1/31/201810465비동기 질문입니다. [3]파일 다운로드1
494880511/31/20189230C# 7.1책 보다가 질문드립니다 [1]
4947김성대1/30/201810485[삭제] 비동기 질문입니다. [2]파일 다운로드2
4946윤현수1/29/20189995비동기 TCP통신 데이터 문제 [4]파일 다운로드1
4945김성대1/26/20188529비동기 질문입니다. [1]파일 다운로드1
4944popo1/25/20187960[삭제] 스레드 안에서 Window Visibility 변경시 DialogResult 오류 질문
4943김성대1/22/20188943FromAsync 질문입니다. [1]
4942박현일1/19/201810534WPF 공부중 모르는 문법이 있어서요~^^; [2]
4941김성대1/18/20188792비동기예약어 실행오류관련입니다. [1]
4940plzh...1/10/20189723webbrowser2 를 이용한 sns 로그인 구현 관련 문의 [2]
4939이성일1/4/201811198ClickOnce 배포 후 업데이트 시 발생하는 오류에 대해 질문 드립니다. [2]
4938김성대1/3/20189284채팅 프로그램관련 질문입니다. [9]파일 다운로드1
4937Ques...1/3/201811620C# CPU 사용량 한계치 늘리는 방법 [2]
4936무개1/3/20188786책 내용 인용하는 것에 관한 질문이있습니다. [1]파일 다운로드1
... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...