Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 18881
글쓴 사람
임동찬 (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)
2559로손5/6/201518428    답변글 [답변]: VB6.0의 ActiveX(OCX) 와 .Net에서 만든 COM DLL의 차이점 ??
2557Guest4/24/201517099Serialize , DeSerialize 관련 질문입니다! [3]
1558민식짱4/23/201518396FFmpeg.exe 를 이용한 C# 동영상 인코더 예제를 보고 질문드립니다 [1]파일 다운로드1
1555김응규4/22/201522815WCF net.tcp 관련해서 질문 드립니다. [2]
1556김응규4/22/201520773    답변글 [답변]: WCF net.tcp 관련해서 질문 드립니다. [1]파일 다운로드1
1554(삭제)4/19/201520926안드로이드 에뮬레이터에서 특정 앱 구동불가할때! [2]
1552spow...4/18/201528003마이크로세컨드 단위의 Sleep이 필요한데 찾질 못하겠습니다. [5]
1553spow...4/18/201520281    답변글 [답변]: 마이크로세컨드 단위의 Sleep이 필요한데 찾질 못하겠습니다. [1]
1551인디언기...4/16/201519451iisnode에 대해서 글 올리셨던데 질문이 있습니다 [1]
1549김선아4/15/201519834.net framework 4.5와 c++ dll에 관한 질문입니다 [1]
1550김선아4/15/201518105    답변글 [답변]: .net framework 4.5와 c++ dll에 관한 질문입니다 [2]
1547문명식4/3/201520446IWebBrowser Key Event 관련 [2]
1545나종식3/25/201519374internet explorer dns cache flush [2]
1543이용원3/23/201518518hyper-v 질문드려요! [1]
1544이용원3/24/201518070    답변글 한가지만 더 여쭤볼게요! [1]
1541임기성3/20/201525324Microsoft.Office.Core dll관련 문제 [1]
1539펜플3/17/201518461asp.net 질문입니다. [1]
1540113/17/201518504    답변글 [답변]: asp.net 질문입니다. [1]
1538열공합시닷3/13/201519508중계서버 질문드립니다 [1]
1537김재영3/11/201521261asp.net의 빌드 유휴시간 이후의 리빌드 작업을 컨트롤 할 수 있습니까? [2]
1536솔솔3/9/201518928mac address얻으려고 하는데요.. [1]
1535Stud...3/4/201519133C#엔 MFC의 theApp 과 같은 기능을 하는것이 없나요? [3]
1534김동진3/4/201518878C#에서 BHO로 Windows Explorer에서의 동작이 가능할지요 [2]
1533김동현3/3/201519101컴파일 된 프로그램에 코드 삽입(?) 관련입니다. [1]
1532반가워요3/3/201522295C# 소켓연결에 packet송수신... [8]
1531강현수3/2/201521215C# com 등록 시 GUID 변경 관련 문의 [1]
... 46  47  48  49  50  51  [52]  53  54  55  56  57  58  59  60  ...