Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 18826
글쓴 사람
임동찬 (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)
5187플하7/19/201918251UWP 관련 궁금한 사항에 대해서 [1]
5186김대훈7/14/201916907박싱과 언박싱에 대해 [2]
5185농상7/13/201915228Nullable에 대해서 [1]
5184김대훈7/4/201914902저자님의 책을 다 본후에는 [2]
51837/2/201916235.NET Compact Freamwork 컨트롤러 더블버퍼링 [1]
5182wpf ...7/2/201915782wpf 질문 드립니다. [1]파일 다운로드1
51817/1/201917271DataGridview Doublebuffer 에 대해서 질문드립니다. [2]
5180김대훈6/25/201916836배열과 반복문에서 질문드립니다 [2]
5177농상6/13/201919491멀티스레드 건의 [2]
5176이선호6/13/201916819안녕하세요. 닷넷 문제로 검색하다 알게되어 들어왔습니다. 현재 IIS 문제가 있어 질문드립니다. [1]
5175Chobo6/12/201916712WPF Ellipse 그리기! [3]
5174농상6/11/201916263ThreadPool 조인에 관해 [1]
5173전우치6/9/201917118공유 리소스에 대한 스레드 동기화 처리를 위해서 lock 이용 시 문의 [3]
5172김대훈6/7/201915857너무힘드네요 공부에 대한조언부탁드립니다 [2]
5171조남석6/4/201915166EX)11-2(treeview)에 대한 질문입니다. [3]
5170레리6/4/201916104Setup 프로젝트 레지스트리 설정 관련 질문입니다. [1]파일 다운로드1
5169농상6/3/201915811멀티스레드 파라미터 관련 [2]
5168익명유저5/30/201915187항상 정말 감사드립니다... [1]
5167WPF5/23/201916024질문드립니다. [1]
5165이대희5/22/201914606Visual Studio 설치 구성요소 문의 (C# 7.3 개정판 관련) [1]
5164레드5/21/201917100실행 과정과 실행파일 디버그 시 Icon변경 질문드립니다. [5]
5163이대희5/20/201914440시작하세요 C# 7.3 프로그래밍 책 도착했습니다. [1]
5162채홍윤5/14/201918457Mono Develop window 설치 [6]
5161정대영5/13/201915180VS 2013에서 C#6.0(.netFramwork 4.6.1) $ 디버깅 오류 [1]
5160초보개발자5/13/201916950wcf 관련 국내 서적 살만한 책이 있나요? [2]
5159sdh25/9/201915659VS 2010 버전에서 생성한 DLL을 VS 2017버전에서 실행 시 에러 [2]
... 16  17  18  19  20  21  22  23  24  25  26  27  28  [29]  30  ...