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

... 61  62  63  64  65  66  67  68  69  70  71  72  73  74  [75]  ...
NoWriterDateCnt.TitleFile(s)
674황태욱7/5/200716469utf-8 환경에서 파라미터 값에 한글이 있을 경우 깨지는 현상이.. [1]
672땡초7/4/200715698Remoting 객체를 호출하는 순간 Timer 의 Elapsed 이벤트가 멈추는 현상 [2]
670조성택7/3/200715086.Net에서 Timer클래스.. [1]
667홍석헌6/29/200714336[c#] 윈도우 활성화에 관한 질문
669정성태6/30/200714658    답변글 [답변]: [c#] 윈도우 활성화에 관한 질문
666오야6/25/200713389System.Transactions 에서 트랜잭션 실패를 체크하는 방법 [1]
665김성태6/20/200713035안녕하세요^^
668정성태6/30/200714287    답변글 [답변]: 안녕하세요^^
663모름이6/19/200712614Microsoft.Framework 에서 OLE DB 사용하려면.. [1]
664모름이6/20/200713592    답변글 [추가질문]: 다른 OLE DB 를 사용하려면..
662조성택6/13/200714164C#에서 string클래스.. [1]
660신동열6/11/200715357ClickOnce 업데이트시 이전 버젼 제거오류 [1]
659한귀순6/11/200716622윈폼 프로그램 및 디자인. [2]
661한귀순6/12/200714115    답변글 [추가질문]: 윈폼 프로그램 및 디자인. [3]
657정해봉6/8/200724896요청 시간 초과 오류 [2]
655이방은5/28/200715169성태님 UML 도구 뭐 쓰십니까??? [1]
654임정훈5/23/200714036카드스페이스 관련질문
658정성태6/9/200714733    답변글 [답변]: 카드스페이스 관련질문 [1]
653사다수스5/22/200735609아래한글(HwpCtrl) ocx 메모리 릭 문제입니다. [4]파일 다운로드1
645송원석5/15/200716922ASP 의 ByVal 과 ByRef 특성
646정성태5/15/200716650    답변글 [답변]: ASP 의 ByVal 과 ByRef 특성
647송원석5/16/200717041        답변글 [답변]: [답변]: ASP 의 ByVal 과 ByRef 특성 [1]
648정성태5/16/200715808            답변글 [답변]: [답변]: [답변]: ASP의 ByVal과 ByRef 특성 [1]
649장윤태5/16/200714837                답변글 [답변]: [답변]: [답변]: [답변]: ASP 의 ByVal 과 ByRef 특성
650정성태5/16/200713022                    답변글 [답변]: [답변]: [답변]: [답변]: [답변]: ASP의 ByVal과 ByRef 특성 [2]
643해운대끓...5/15/200712433Singleton 패턴 테스트중 하나의 윈폼만 열기 오류파일 다운로드1
... 61  62  63  64  65  66  67  68  69  70  71  72  73  74  [75]  ...