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

... 76  77  78  [79]  80  81  82  83  84  85  86  87  88  89  90  ...
NoWriterDateCnt.TitleFile(s)
525독불장군12/15/200614117일주일 공부하고 있는데 잘 안되네요 도와 주세요 스마트 클라이언트파일 다운로드1
528정성태12/19/200614313    답변글 [답변]: 일주일 공부하고 있는데 잘 안되네요 도와 주세요 스마트 클라이언트
530독불장군12/20/200613945        답변글 [답변]: [답변]: 답변에 감사 드립니다.
523주낙현12/12/200613366healthMonitoring 구성섹션을 설정하는 방법 [1]
519이진형12/8/200613067스마트 클라이언트에서 부모 IE 컨트롤 하기
520정성태12/11/200613843    답변글 [답변]: 스마트 클라이언트에서 부모 IE 컨트롤 하기 [3]
517주낙현12/5/200613757Property 재정의가 가능한가요?? [1]
516양덕진11/29/200613371SSL인증서 질문? [1]
515경혜원11/27/200614808화면 캡춰 관련해서 문의 드립니다. [1]
513양덕진11/26/200617023SSL인증문제?
514양덕진11/27/200618837    답변글 [답변]: SSL인증문제? [1]
512윤창일11/24/200616233[ActiveX vs 가장기법] [1]
511방문자11/24/200615037스마트 클라이언트 질문입니다. [3]
509주낙현11/22/200616479스마트 클라이언트에서 WebBrowser 컨트롤사용? [4]
508임장현11/20/200615946서로다른 프로젝트간의 세션공유에 대해 질문드립니다.
510정성태11/22/200614370    답변글 [답변]: 서로다른 프로젝트 간의 세션 공유에 대해 질문드립니다.
504탑.11/10/200614996COM+ 구성 좀 봐주세요...
505정성태11/14/200614753    답변글 [답변]: COM+ 구성 좀 봐주세요...
506탑.11/15/200614102        답변글 [답변]: [답변]: COM+ 구성 좀 봐주세요... [2]
503sagi...11/10/200613971bho 폼 관련 질문입니다/ [1]
501안연준11/7/200614661(SmartClient) 프레임워크 1.1 과 2.0 은 호환이 안된다? [3]
507안연준11/17/200614360    답변글 [답변]: (SmartClient) 프레임워크 1.1 과 2.0 은 호환이 안된다? [1]
498쿠리마10/30/200614715Smart Client를 VC60 MFC Dialog 에서 사용하기
500정성태10/30/200616677    답변글 [답변]: Smart Client를 VC60 MFC Dialog 에서 사용하기 [3]
497이방은10/30/200616795질문 있습니다..ㅡ.ㅠ;
499정성태10/30/200616665    답변글 [답변]: 질문 있습니다..ㅡ.ㅠ; [2]
... 76  77  78  [79]  80  81  82  83  84  85  86  87  88  89  90  ...