Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 19851
글쓴 사람
임동찬 (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)
5631김기헌3/24/202213163WPF 컨트롤의 그래픽 처리관련 질문드립니다 [2]파일 다운로드1
5630장성욱3/24/202213182로깅관련 질문입니다. [2]
5629감사합니...3/23/202213343함수에서 예외가 발생하면 try ~ catch처리기를 찾을 때 까지 상위 함수로 계속 올라가나요? [2]
5628홍길동3/23/202215083질문드립니다. [2]파일 다운로드1
5626연준혁3/21/202214149안녕하세요. [3]
5625jaew...3/18/202213829c# 8.0 도서를 구입한 사람입니다. [1]
5624초보자3/17/202213289람다 캡처 관련 문의 [2]
5623한예지 donator3/15/202212327인터프리터 원리가 궁금합니다. [4]
5622김민아3/8/202213021const와 readonly의 명확한 차이가 이게 맞나요? [2]
5621장성욱3/8/202213131c# 로그 관련 질문 [1]
5620김민아3/7/202212333안녕하세요 비관리 객체를 반환하는 메소드 호출 시 궁금한 점이 있어서 질문드립니다 [2]
5619팡팡이3/3/202214390RSA 문의드립니다. [3]
5618김기헌3/2/202212233안녕하세요 생성자 옆에 this 키워드를 붙여 생성자를 여러 개 호출 시 질문드립니다 [2]
5617Edun2/25/202213188ArgumentOutOrRangeException에러 발생 [2]파일 다운로드1
5616csha...2/24/202212407readonly struct로 선언된 구조체를 특정 클래스에서 멤버변수로 가지는 경우 [1]
5615장성욱2/22/202216325SetThreadAffinityMask를 이용한 쓰레드 지정하는 방법에 대해 궁금합니다. [4]
5614민우2/22/202216106SSL 통신 문의 [6]
5613김인태2/22/202213969서버와 PC 간의 어플리케이션 성능 차이 [1]
5612팬입니다2/20/202212205Kastrel 서버 관련 [1]
5611차가워2/19/202212718stopWatch 늘어짐 문의 [3]
5610차가워2/18/202212683Stopwatch 늘어짐 문제 [1]
5609cs린이2/15/202212140c# 함수의 호출 방식에 대해 궁금합니다! [2]
5608지호2/10/202213209시작하세요 C# 8.0 중 제네릭타입의 IEnumerable [3]파일 다운로드1
5607이로운2/10/202211682안녕하세요. 궁금한게 있어서 질문드립니다. [1]
5605강성봉2/10/202212776TCP PSH flag 패킷 수신 에러 [1]
5604LW2/9/202213573VISUAL STUDIO 2019 ==> 2020 설치시 오류가 생겨서 문의드립니다. [3]
1  2  3  4  5  6  7  8  9  10  11  12  13  [14]  15  ...