Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12895
글쓴 사람
임동찬 (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)
5648주니어개...4/13/20223930컴파일된 코드를 원시코드로 바꾸려면 어떻게해야하나요? [1]파일 다운로드1
5647장성욱4/7/20223972코어지정 CPU사용률 관련 질문 [1]
5646서형주4/6/20223990List에 여러개의 class 객체를 만들어 넣을때, 객체의 method들도 같이 생성되어 메모리를 차지하나요? [1]
5645김인태4/6/20223639윈도우즈 서버의 AD 계정 생성 조건이 있을까요? [1]
5644ㅇㅇ4/6/20224388c# 프로그램을 이용하여 리눅스상에 파일 생성이 가능한가요? [1]
5643유필재4/5/20224263TCP클라이언트 연결 및 통신관련하여 문의드려요 [1]
5642차가워4/4/20224514UdpClient 패킷 수신 문의 [4]
5641장성욱4/4/20224931코어 할당 및 cpu 부하테스트 질문 [7]
5640icoo...4/4/20224465웹가든에서 메모리 동적 업데이트 방법 [1]
5639차가워4/4/20224356c++ 서버 c# 클라이언트 호환 문의 [1]
5638초급4/3/20224655c# sql server 연동 [1]
5637따봉이4/1/20224927Winform Form Load 후 자동 캡쳐관련 [1]파일 다운로드1
5636김철순3/31/20224909WPF에서 Richtext의 View 문의 [5]
5635guest3/30/20224939안정적인 pinning이 가능하네요. [3]파일 다운로드1
5633꿀주세요3/30/20224583선생님 마우스 클릭이벤트 질문이 있습니다. [4]
5632김현수3/30/20224919Remote Desktop으로 접속시 WPF UI 가 다시 그려지는 이벤트를 막을 수 없을까요? [3]
5631김기헌3/24/20224558WPF 컨트롤의 그래픽 처리관련 질문드립니다 [2]파일 다운로드1
5630장성욱3/24/20224378로깅관련 질문입니다. [2]
5629감사합니...3/23/20224633함수에서 예외가 발생하면 try ~ catch처리기를 찾을 때 까지 상위 함수로 계속 올라가나요? [2]
5628홍길동3/23/20225290질문드립니다. [2]파일 다운로드1
5626연준혁3/21/20224490안녕하세요. [3]
5625jaew...3/18/20225422c# 8.0 도서를 구입한 사람입니다. [1]
5624초보자3/17/20224391람다 캡처 관련 문의 [2]
5623한예지 donator3/15/20224764인터프리터 원리가 궁금합니다. [4]
5622김민아3/8/20224710const와 readonly의 명확한 차이가 이게 맞나요? [2]
5621장성욱3/8/20224515c# 로그 관련 질문 [1]
1  2  3  4  5  6  7  8  9  10  11  [12]  13  14  15  ...