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

1  2  3  4  5  6  7  8  9  10  11  12  13  14  [15]  ...
NoWriterDateCnt.TitleFile(s)
5604LW2/9/202213574VISUAL STUDIO 2019 ==> 2020 설치시 오류가 생겨서 문의드립니다. [3]
5603김진명2/9/202214350C# 10.0 출간은 언제쯤 계획하고 계신가요? [1]
5602신갑영2/8/202213048윈폼에 대해서 질문 드립니다. [1]
5601김인태2/4/202212828setup project 관련 [7]
5600itkim2/3/202215714윈도우 서버 계정 패스워드 인증 문의 [5]
5599레드골드2/3/202216772c#으로 ms word 제어 가능할까요? [6]
5598jaew...2/2/202213391Dictionary는 참조형식인가요?? [1]
5597재원2/2/202214272c# 9.0에 대한 내용을 받을 수 있나요? [1]
5596kss1/26/202213506듀얼 모니터 환경에서 wpf 프로그램 크기 변경 [2]
5594mira...1/25/202212570안녕하세요 try~catch 와 SuspendLayout~ResumeLayout 간 호출 문의드립니다! [2]
5593C#스터디1/12/202214748TaskAwaiter 구현 질문 입니다. [1]
5591유지킴12/24/202113639outofmemory in 32bit [2]파일 다운로드1
5590kss12/23/202112802포인터 메모리 에러 [1]
5589초급12/22/202112612c# -> 라즈베리파이(db 접속)시 에러 발생 [7]
5588김지신12/21/202113286안녕하세요 String 변수 참조 주소 질문입니다. [2]
5587이완호12/17/202115285C# SharpDX 화면 캡쳐 관련해서 질문 드립니다. [1]
5586조미김12/16/202113685윈폼에서 메인 스레드와 UI 스레드의 차이점 질문드립니다 [4]
5585김준희12/16/202114652C# 윈폼 TCP/IP 데이터 연속으로 보낼때 [1]
5583난인간이다12/10/202112638.net 6 dynamic pgo 활성화 및 예상되는 문제 [1]
5582김준희12/9/202123213C# TCP/IP 통신시 연결 끊김 에러 [1]
5581김시준12/9/202114268닷넷에서 파일 delete 함수는 왜 비동기가 없는 것인가요? [2]
5580카짜프로...12/7/202116127패턴매칭 -튜퓰비교에 관한 오류사항과 궁금증 [1]파일 다운로드1
5579카짜프로...12/6/20211477111.12 메서드 중복정의에 대한 질문 [1]
5577감사합니...11/30/202114362visual studio 2015 update 3를 다운받을려고 하는데 x64/x86 차이점이 뭘까요? [2]
5576노홍구11/29/202114419C# 으로 USB 스캐너 프린터 리셋하기 입니다. [1]
5575베라11/23/202114027event handler 관련 문의 [2]
1  2  3  4  5  6  7  8  9  10  11  12  13  14  [15]  ...