Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12875
글쓴 사람
임동찬 (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)
51837/2/20197870.NET Compact Freamwork 컨트롤러 더블버퍼링 [1]
5182wpf ...7/2/20198059wpf 질문 드립니다. [1]파일 다운로드1
51817/1/20198512DataGridview Doublebuffer 에 대해서 질문드립니다. [2]
5180김대훈6/25/20198512배열과 반복문에서 질문드립니다 [2]
5177농상6/13/20199669멀티스레드 건의 [2]
5176이선호6/13/20199265안녕하세요. 닷넷 문제로 검색하다 알게되어 들어왔습니다. 현재 IIS 문제가 있어 질문드립니다. [1]
5175Chobo6/12/20199241WPF Ellipse 그리기! [3]
5174농상6/11/20198558ThreadPool 조인에 관해 [1]
5173전우치6/9/20198998공유 리소스에 대한 스레드 동기화 처리를 위해서 lock 이용 시 문의 [3]
5172김대훈6/7/20197810너무힘드네요 공부에 대한조언부탁드립니다 [2]
5171조남석6/4/20197506EX)11-2(treeview)에 대한 질문입니다. [3]
5170레리6/4/20198124Setup 프로젝트 레지스트리 설정 관련 질문입니다. [1]파일 다운로드1
5169농상6/3/20197900멀티스레드 파라미터 관련 [2]
5168익명유저5/30/20197186항상 정말 감사드립니다... [1]
5167WPF5/23/20198089질문드립니다. [1]
5165이대희5/22/20197237Visual Studio 설치 구성요소 문의 (C# 7.3 개정판 관련) [1]
5164레드5/21/20198756실행 과정과 실행파일 디버그 시 Icon변경 질문드립니다. [5]
5163이대희5/20/20197055시작하세요 C# 7.3 프로그래밍 책 도착했습니다. [1]
5162채홍윤5/14/20199869Mono Develop window 설치 [6]
5161정대영5/13/20197813VS 2013에서 C#6.0(.netFramwork 4.6.1) $ 디버깅 오류 [1]
5160초보개발자5/13/20198796wcf 관련 국내 서적 살만한 책이 있나요? [2]
5159sdh25/9/20198347VS 2010 버전에서 생성한 DLL을 VS 2017버전에서 실행 시 에러 [2]
5158sdh5/8/20197233Visual studio 2010 버전에서 생성한 Project를 Visual studio 2017버전에서 실행에러 [1]
5157김경훈5/8/201910221Task 만들때 넘겨주는 CancellationToken은 어디서 사용 되는 건가요? [4]
5156rysoo5/8/20198493yield return의 리턴 타입 질문 드립니다. [4]
5155세퉁5/7/201910400관리자 권한으로 실행 시 알림창(?) 없이 바로 실행 시킬 수 있는 방법이 있을까요?? [2]파일 다운로드1
... 16  17  18  19  20  21  22  23  24  25  26  27  [28]  29  30  ...