Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 17846
글쓴 사람
임동찬 (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)
321셈토2/18/200610818SPOOL --> EMF --> TEXTOUT [1]
320정보문2/18/200610611파일의 최대 크기2 [1]
318정보문2/18/200611756파일의 최대 크기
319정성태2/18/200611774    답변글 [답변]: 파일의 최대 크기 [1]
317narc...2/17/200610895[IE embeded SmartClient]에서 닷넷 리모팅 프록시 사용시 처음 2분간 딜레이현상이 발생합니다. [1]
322narc...2/20/200611717    답변글 [답변]: 다시한번 부탁드리겠습니다..
316이경찬2/15/200613129MSDN 매거진 정기구독 신청은 어디서 할수있나요? [1]
315정준명2/15/200616570[DxFramework Lite] 분산 트랜잭션에 참여하는 동안 오류가 발생했습니다. [2]
314이윤희2/14/200610784엑셀변환시....그림을 넣을려면. [1]
313장강현2/14/200610944SmartClient 디버그 문제 [1]
312정보문2/13/200611031방법2006 [1]
309정보문2/10/200612155edit & continue [3]
308김용국2/11/200610639스마트클라이언트 관련질문 [ Client 에서 WebPage의 JavaScript 호출방법이 있을까요? 있다고는 한것 같은데..부탁드림^^
310정성태2/11/200610139    답변글 [답변]: 스마트클라이언트 관련질문 [ Client 에서 WebPage의 JavaScript 호출방법이 있을까요? 있다고는 한것 같은데..부탁드림^^
307narc...2/10/200611857IE Embeded 스마트클라이언트는 UserControl만 가능한가요? [2]
305정보문2/10/200611999웹 컨트롤
306정성태2/10/200611653    답변글 [답변]: 웹 컨트롤
303정보문2/10/200612534회원가입성공을 기념으로 질문 한 가지 던집니다.
304정성태2/10/200610929    답변글 [답변]: 회원가입성공을 기념으로 질문 한 가지 던집니다.
302김성2/7/200612093C#이나 VB.NET 으로 만든 것을 SETUP 해서 배포하려고 하는데요.. [1]
301참깨2/3/200616329개체가 이 속성 또는 메소드를 지원하지 않습니다. [1]
300김종욱2/2/200610723안녕하세요 [2]
299꼬부기1/19/20069997스마트클라이언트 관련 질문입니다... [2]
298정말초짜1/12/200610239smart client 질문입니다. [1]
296우승우1/4/20069893스마트클라이언트에서 COM+를 이용한 데이터 가져 오기..
297정성태1/4/200611838    답변글 [답변]: 스마트클라이언트에서 COM+를 이용한 데이터 가져 오기.. [2]
... 76  77  78  79  80  81  82  83  84  85  [86]  87  88  89  90  ...