Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12846
글쓴 사람
임동찬 (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)
4829윤현수4/26/201714688System.Text.Encoding 질문 [1]
4828jaem...4/20/201710917시스템 종료시 block 함수 xp 지원가능한 방법 질문 [2]
4827ds4/13/201712698매서드 정의로 이동시 [메타데이터에서]에서 라고 나오는 것은 뭔가요? [1]
4826김솔지4/11/201710066CxImage 문자 출력 [1]
4825플메4/10/201710456덱스트 업로드 하는데 구성요소 서비스에 엑셀이 안뜨네요..ㅜㅜ [1]파일 다운로드1
4824김상경4/9/20179844win7에서 vb6.0을 이용해서 프로그램을 만들었습니다.(제가 만든건 아니고 옆 동료가 만들었습니다.) [1]파일 다운로드1
4823조상현3/28/201710885windows event log 에 대한 정보는 어디서 얻을 수 있을까요? [1]
4822부우3/24/201712526글수정이 안되어 다시올려드립니다ㅠ [12]파일 다운로드2
4821부우3/22/201726165파일이나 어셈블리 중 하나를 로드에러 좀 봐주세요 [9]파일 다운로드1
4820듀이3/20/201710967오차 없이 동시에 명령을 보내게 가능한가요? [2]파일 다운로드1
4819popo3/20/201712298C# sslstream 사용시 Cipher List 설정 [3]
4818부우3/16/201721159DllImport 사용시 진입점을 찾을수 없습니다 [2]
4817yun3/15/201710511서피스프로4의 HYPER-V로 윈도우7을 깔았는데... [1]
4816부우3/15/201713241C++ DLL함수 사용 질문드립니다 [10]
4815김지용3/14/20179305.net core linux 오류 [2]
4814김솔지3/13/201710385인쇄 시 , 출력화면을 이미지 파일로 저장하고 싶습니다. [1]파일 다운로드1
4813spow...3/8/201711934멀티 스레드 환경에서 처리하여야 할 목록을 효율적으로 사용하는 기법 질문 드립니다 [2]
4812popo2/23/201711995.NET Window ClassName 변경 질문 드립니다. [1]
4809힘찬도약2/15/201715056C# 가상 시리얼 [4]
4808이길용2/9/201713789WCF 외부 접속 관련해서 질문드립니다ㅠ [1]
4807헬조선식...2/8/201720383WPF의 속도에 대해서 궁금합니다. [3]
4803헬조선식...2/7/201713800WPF로 메신져 메세지 박스 구현 문의 [2]
4802spow...2/6/201710841특정 범위의 값을 다른 값으로 치환하는 메소드를 만들어야 할 때 가장 빠른 방법은? [7]
4804spow...2/7/201710705    답변글 [답변]: 특정 범위의 값을 다른 값으로 치환하는 메소드를 만들어야 할 때 가장 빠른 방법은?
4805spow...2/7/201710382    답변글 [답변]: 특정 범위의 값을 다른 값으로 치환하는 메소드를 만들어야 할 때 가장 빠른 방법은? (글삭제가 안돼 재첨부합니다)파일 다운로드1
4801spow...2/3/201710267C#의 참조 동작관련하여 아이디어 문의 드립니다 [4]
... 31  32  33  34  35  36  37  38  39  40  [41]  42  43  44  45  ...