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

... 46  47  48  [49]  50  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
3606guest9/20/201511069확장 클래스 네이밍 규칙은 어떻게 하시나요? [1]
3605spow...9/18/201510234익명형식을 다른 클래스의 인스턴스로 전달하고 싶습니다. [1]
3604popo9/11/201511408[C#] Singleton 을 사용하면서 궁금한점이 있어 질문 남깁니다. [2]
3603강준9/11/201510422xamarin 을 시작하려고 하는데 혹시 도움이 될만한 사이트나 정보 있으면 공유해 주세요~~ [1]
3602Mink...9/9/201511456aspx > 다른 확장자로 변경 후 디버깅 때문에 질문 드려 봅니다. [10]
3601edain9/8/201511646캐스팅...에 관해 궁금합니다. [5]
3600guest9/7/201514912C# 버전의 정의는 어떻게 구분하나요? [2]
3599김태훈9/4/201512566안녕하세요. C언어를 배우려고 하는 문과생입니다. [1]
3598미니8/29/2015131346.0은 전체소스? [1]
3597손성수8/28/201511659시작하세요 ! c# 프로그래밍 이책으로 배우고 있는데요 [2]
3596지나가는...8/26/201511218크로스플랫폼 [1]
3594guest8/25/201510886요즘 Windonws Form 기반 N Tier 어떻게 구성하나요?? [1]
3593개발자8/18/201513623현 시점에서 VS 버전은 뭐가 좋을까요? [8]
3592나그네8/15/201513011안녕하세요 질문이 있어서... [4]
3589spow...8/11/201514102Nancy + Razor 사용시 cshtml의 IntelliSense 및 참조 오류 [3]
3590spow...8/12/201513006    답변글 [질문]: (첨부 추가) [1]파일 다운로드1
3588재현8/8/201517791안녕하세요. C# 6.0 책을 보는 중에 의문이 생겨 질문드립니다. [4]
3587주문중8/4/201517815신간 출간 [7]
3586꿈꾸는개...7/29/201512793자바스크립트 checkbox 관련하여 ie10에서 호완이 안되는 부분이 있어 질문드립니다 [1]
3585유동근7/21/201511419TTS오류 [1]파일 다운로드1
3583노영우7/20/201511525iisnode 를 클래식 파이프라인 모드에서 호스팅하기 [2]
3582황희성7/17/201514405동영상 캡쳐에 관련해서 궁금하것이 있습니다. [6]파일 다운로드1
3581popo7/15/201511053[WPF] DependencyProperty에서 callback 처리시 문의 입니다. [1]
3580국왕님7/14/201511293어셈블리 서명 pfx 파일의 가져오기시 암호를 확인할 수 있을까요? [1]
3579고훈용7/13/201510718스마트클라이언트 윈도우8.1 실행오류 해결 방법 문의 [1]파일 다운로드1
3578이성환7/9/201513276WPF Multi Dispatcher 사용 시 hang 발생 [4]파일 다운로드1
... 46  47  48  [49]  50  51  52  53  54  55  56  57  58  59  60  ...