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

... 31  32  33  34  35  36  37  38  39  40  41  [42]  43  44  45  ...
NoWriterDateCnt.TitleFile(s)
4838후배5/29/201719753PDF Reader 라이브러리.. [3]
4837KDP5/29/201719549c++ to C# 컨버팅 문의 [2]
4836popo5/26/201721860리플렉션 성능 관련 질문 드립니다. [2]
4835guest5/25/201718051wpf Canvas 질문드립니다. [1]
4834부탁드립...5/19/201719215익스체인지 서버 구동중 인증서를 받는 과정에서오류가 납니다 [1]
4833안종윤5/18/201719357winform을 Web Browser에 붙일 수 있는지요? [1]
4832guest5/17/201718089c# UDP socket예제 실행방법 [3]
4831guest5/15/201722195WPF .net 3.5에서 TextBox 한글 문제 [3]
4830초보자5/7/201725772프로그램 비정상 종료 메시지 창 없애는 방법 [4]
4829윤현수4/26/201725298System.Text.Encoding 질문 [1]
4828jaem...4/20/201719084시스템 종료시 block 함수 xp 지원가능한 방법 질문 [2]
4827ds4/13/201721035매서드 정의로 이동시 [메타데이터에서]에서 라고 나오는 것은 뭔가요? [1]
4826김솔지4/11/201718083CxImage 문자 출력 [1]
4825플메4/10/201717200덱스트 업로드 하는데 구성요소 서비스에 엑셀이 안뜨네요..ㅜㅜ [1]파일 다운로드1
4824김상경4/9/201717412win7에서 vb6.0을 이용해서 프로그램을 만들었습니다.(제가 만든건 아니고 옆 동료가 만들었습니다.) [1]파일 다운로드1
4823조상현3/28/201718063windows event log 에 대한 정보는 어디서 얻을 수 있을까요? [1]
4822부우3/24/201720625글수정이 안되어 다시올려드립니다ㅠ [12]파일 다운로드2
4821부우3/22/201735788파일이나 어셈블리 중 하나를 로드에러 좀 봐주세요 [9]파일 다운로드1
4820듀이3/20/201719191오차 없이 동시에 명령을 보내게 가능한가요? [2]파일 다운로드1
4819popo3/20/201720139C# sslstream 사용시 Cipher List 설정 [3]
4818부우3/16/201731400DllImport 사용시 진입점을 찾을수 없습니다 [2]
4817yun3/15/201719949서피스프로4의 HYPER-V로 윈도우7을 깔았는데... [1]
4816부우3/15/201721505C++ DLL함수 사용 질문드립니다 [10]
4815김지용3/14/201717607.net core linux 오류 [2]
4814김솔지3/13/201718514인쇄 시 , 출력화면을 이미지 파일로 저장하고 싶습니다. [1]파일 다운로드1
4813spow...3/8/201720459멀티 스레드 환경에서 처리하여야 할 목록을 효율적으로 사용하는 기법 질문 드립니다 [2]
... 31  32  33  34  35  36  37  38  39  40  41  [42]  43  44  45  ...