Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 18903
글쓴 사람
임동찬 (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)
555dev....1/25/2007174532005 WebBrowser내에서 팝업 처리 문제 관련 질문입니다.
561정성태1/29/200720312    답변글 [답변]: 2005 WebBrowser 내에서 팝업 처리 문제 관련 질문입니다.
554sky1/23/200716125<급질문> interop 를 사용함에 있어 [2]
557sky1/26/200713491    답변글 [답변]: <급질문> interop 를 사용함에 있어
553deve...1/15/200715493오류가 나는데 도저히 모르겠네여...좀 봐주세요... [3]파일 다운로드1
551sky1/23/200714573[급질문] vb6으로 만들어진 dll 를
552정성태1/10/200716244    답변글 [답변]: [급질문] vb6으로 만들어진 dll 를 [1]
546오택성1/2/200715049스마트클라이언트 DebugIEHost.log 좀 봐 주세요. [9]
545심현철12/28/200615133ClickOnce를 이용한 SmartClient의 설치 자동화 방법에 대해서 문의를 드립니다. [1]
53912/26/200614193COM+ 자동등록 하니 속도가 영...?
540정성태12/26/200616160    답변글 [답변]: COM+ 자동등록 하니 속도가 영...? [1]
538오택성12/26/200615267스마트클라이언트에서 그리드 컴포넌트 사용시 화면에 그리드가 올라오지 않네요~ [1]
537김현12/23/200615844스마트클라이언트 CAS배포문제와, ASP.NET에서 SmartClient로 DB인자 넘기는 문제 입니다. [3]
536오택성12/23/200613405스마트 클라이언트에서 A폼에서 B폼에 있는 그리드에 데이타를 담을려고 하는데요... [2]파일 다운로드1
541달봉이12/27/200615991    답변글 [답변]: 스마트 클라이언트에서 A폼에서 B폼에 있는 그리드에 데이타를 담을려고 하는데요...
535김태곤12/22/200619918ActiveX DLL( VB 6.0 )와 관련해 질문드립니다. [1]파일 다운로드1
534심현철12/21/200615266IE Embedded SmartClient관련 질문입니다. [1]
542달봉이12/27/200615564    답변글 [답변]: IE Embedded SmartClient관련 질문입니다.
543심현철12/27/200614536        답변글 [답변]: [답변]: IE Embedded SmartClient관련 질문입니다.
544달봉이12/28/200614245            답변글 [답변]: [답변]: [답변]: IE Embedded SmartClient관련 질문입니다.
53112/20/200616057업로드 시에 로컬의 파일을 페이지 submit 시에 같이 태워보낼 수 있을 까요?
532정성태12/20/200613546    답변글 [답변]: 업로드 시에 로컬의 파일을 페이지 submit 시에 같이 태워보낼 수 있을 까요? [1]
527심현철12/19/200616382VC++과 C# COM의 interop에서 디버깅을 하는 방법에 대해서 물어봅니다.
529정성태12/19/200617584    답변글 [답변]: VC++과 C# COM의 interop에서 디버깅을 하는 방법에 대해서 물어봅니다. [1]
526독불장군12/17/200613911아랫글 과련... [1]
525독불장군12/15/200614077일주일 공부하고 있는데 잘 안되네요 도와 주세요 스마트 클라이언트파일 다운로드1
... 76  77  [78]  79  80  81  82  83  84  85  86  87  88  89  90  ...