Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 19427
글쓴 사람
임동찬 (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)
5000레몬6/26/201819350안녕하세요 성태님 도움으로 C# 네이버 카페 스팸글 작성되면 삭제되는 프로그램을 만들었는데요..여쭤볼게 하나 있습니다. [3]
4999jt6/21/201815200검색어 입력, 엔터 > 페북 로그인창으로 이동합니다. [4]
4998개발희망6/11/201817577C# 형변환 질문있습니다! [1]
4997초보개발자6/5/201831599C++ dll C#에서 사용하는데 보호된 메모리 오류떠요 한번만 도와주세요ㅜ [1]파일 다운로드1
4996swc6/5/201817771현업에서 주로 사용하는 DB업데이트 방법 질문입니다. [1]파일 다운로드1
4993학생6/3/201815753질문 드립니다 [1]
4991최진안5/24/201816280Credential Provider 질문 [2]
4990heyg...5/21/201816508Sybase Adaptive Server Anywhere 6 버전에 대한 질문입니다. [9]
4989강한음5/18/201819547clickonce 배포 후 실행 무응답 [4]
4988C#7....5/17/201815111dynamic 키워드를 사용한 객체 핸들링에 대해서 여쭤보려고 합니다. [1]
4987포플러5/14/201817291닥터왓슨 로그 - c0000005 (액세스 위반) 분석 부탁드려도 될까요? [2]
4986익명5/14/201819261비주얼 스튜디오 wpf 프로젝트에서 어떻게 하면 exe파일과 실행에 필요한 파일들을 분리해서 정리해서 디렉토리로 묶을 수 있을까요? [4]
4985대구개발자5/7/201816759새로운 폴더만 "이름 없는 파일" 오류 [1]
4984안중언5/6/201817367교재 143page [1]
4983익명5/4/201827995(wpf) 다른 컴퓨터에서 사용하면 자꾸 ('CefSharp.Core.dll' 또는 여기에 종속되어 있는 파일이나 어셈블리 중 하나를 로드할 수 없습니다)라고 떠요.ㅠㅠ [5]
4982Soul...4/27/201817781MFC ActiveX 컨트롤 안에 있는 C# ActiveX 컨트롤 포인터 얻기 [4]
4981대전박4/25/201816439WPF IValueConverter 를 구현해서 StaticResource로 사용할때요 [1]
4980대전박4/23/201818006WPF OS버전 따라 Style 적용이 안되는 프로퍼티가 있을수 있나요? [2]
4979초보개발자4/18/201822785C# 프레임워크 버전이 다른 DLL끼리의 사용 [7]파일 다운로드1
4977Soul...4/17/201817435WebBrowser 컨트롤 Script 통신 문제 [3]
4976맹가이버4/14/201818490윈도우 서비스 프로그램에서 응용프로그램 호출하는 법 [1]
4975lemo...4/11/201818936안녕하세요 네이버로그인관련 질문드립니다. [2]
4973홍길동4/6/201816737ebook 출간 계획은 없으신가요? [2]
4978홍길동4/17/201816424    답변글 [답변]: ebook 출간 계획은 없으신가요?
4972dwkim4/3/201817088EasyHook 관련 질문 [4]
4968최홍준3/30/201816211Windows 7 Credential Provider Android와 연동 [1]
... 31  32  33  34  35  [36]  37  38  39  40  41  42  43  44  45  ...