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

... 16  [17]  18  19  20  21  22  23  24  25  26  27  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
5513labe...6/11/20217272C# Winform 에서 Label에 동일한 Color를 넣었을 때 처리방법이 궁금합니다. [2]
55126/11/20218061xlwings 가 실행조차 되지 않습니다. ㅠㅠ [7]
5511Syong6/9/20216871User Control에 string array 속성 추가하는 방법 [4]
5510jay6/8/20215891string 문자열에 쌍따옴표(")를 넣고 싶습니다. [1]파일 다운로드1
5509한예지 donator6/3/20215824ExeccuteNonQuery 질문있습니다! [2]
5508최재남6/3/20216663마우스 이벤트 관련 질문 좀 드리겠습니다. [6]
5507한예6/2/20215847static과 스택오버플로우 질문있습니다. [5]파일 다운로드1
5506이창석6/1/20217273센서의 값을 받아서 PC를 통해 모니터링 하는 것을 만들고 있습니다. [1]
5505kss5/31/20215829.net5에서 소멸자가 어떻게 바뀐건가요? [1]
5503xing...5/24/20216217xingapinet 에 수정 요청 부탁 드립니다. [1]
5501한예지 donator5/23/20215974IProgress 사용법이 궁금합니다. [2]
5500한예ㅈ5/23/20217862비동기 코드 흐름 질문있습니다. [3]
5498곰장어5/21/20215715List에 static 변수를 추가했을때의 궁금증 [3]파일 다운로드1
5497지평선5/20/20216955윈도우 배율을 알 수 있을까요? [1]
5496cs린이5/20/20215596C# 8.0 질문입니다. [2]파일 다운로드6
5495Natie5/13/20215111객체를 생성과 동시에 초기화 하는 방법 [1]
5494지예예지5/13/20217393비동기 코드 흐름이 궁금합니다! [2]
5493xing...5/6/20215315xing api XQCSPAT00600 질문입니다 [4]파일 다운로드1
5492한예지 donator5/5/20215380FromCurrentSynchronizationContext 관련 코드 질문있습니다! [2]
5491조우성5/4/20219823WinForm과 WPF의 성능차이 비교한 자료가 있을까요? [4]
5490한예지 donator5/3/20216187UI 스레드의 Invoke 질문있습니다. [4]
5489저누4/28/20216772시작하세요 C# 9.0, 225페이지 구조체 관련 질문드립니다. [2]
5488종범4/27/20217033C# 비동기 함수 async, await 와 Task의 관계에 대해 질문 드립니다. [6]
5487진우4/27/20216385C# 엑셀 자동화 성능 향상 문의 [2]
5486지나가던...4/26/20215924닷넷 구현 코드 관련 질문 [2]
5485이재원4/17/20216294교재 315페이지 내용 질문 [3]
... 16  [17]  18  19  20  21  22  23  24  25  26  27  28  29  30  ...