Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 19848
글쓴 사람
임동찬 (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)
5713김기헌8/17/202212801안녕하세요 rgb 계산 오차가 있는데 원인을 모르겠습니다.. [3]
5712하태8/17/202213417안녕하세요 background service에서 user32dll 접근 질문 드리겠습니다.! [2]
5711하태8/16/202212756안녕하세요! 윈도우즈 해상도 관련 질문 드립니다. [1]
5710장성욱8/12/202212646c# 시리얼 통신 관련 질문 [3]
5709초보8/12/202211611WPF 커맨드 관련 질문 [2]
5708민성8/11/202212430안녕하세요 c#에서 화면의 배율 및 레이아웃을 변경할려면 어떻게 해야 할까요? [2]파일 다운로드1
5707민성8/10/202212400WPF 엣지 컨트롤에서 화면이 안보이는 현상 [2]파일 다운로드1
5706종규8/7/202215204WPF 에서 SVG 아이콘 사용 방법 문의 [2]
5705김기헌8/6/202212780안녕하세요 선생님 싱글톤 패턴 간단 질문 [2]
5704따봉이8/4/202212649EventHandler 관련 [1]
5703조민준8/3/202211962안녕하세요 정적 멤버 초기화 관련 간단한 질문 [2]
5702석우8/3/202212188C# WPF Ribbon IsMinimized 프로퍼티 변경 감지 방법문의 [2]파일 다운로드1
5701김기헌8/1/202213167foreach 문으로 컬렉션을 열거할 때 궁금한 점 [2]
5699갓경섭7/29/202213775C# 프로그램 느려짐 현상 [2]
5698kss7/29/202214702ValueTask 질문입니다. [5]
5697스팸7/28/202215749윈도우서버 Port 고갈문제 (Event ID 4227, 4231) [3]파일 다운로드1
5696유석7/27/202215378닷넷 4.X 와 닷넷 6.0 버전 차이 [6]
5695초보코더7/26/202215899[WCF] EndpointNotFoundException 기본 연결이 닫혔습니다. 원격 서버에 연결할 수 없습니다. [1]
5693차가워7/22/202214477socket 종료 시 reveive수신부에서 에러 나는거 처리 문의 [5]
5692도비7/21/202214068Ubuntu LVM 확장 관련 [1]파일 다운로드1
5691따봉이7/21/202214817Task 비동기 UI 크로스 쓰레딩 Err 관련 [1]
5690훈이7/20/202212594wpf질문입니다 [2]
5689질문7/20/202212816비동기 함수를 사용하는 방법에 대한 질문입니다 [1]
5688김정현7/11/202211350소스 디버깅(F5)시 프로그램 켜지지 않고 디버깅 가능한 상태 [1]
5687규철7/6/202212140개발업무 문서 관리 방법 문의 [3]
5686권용완7/5/202211826Linq Entites 에서 string[]에 담긴 데이터를 제외하는 방법 문의 [3]
1  2  3  4  5  6  7  8  9  10  [11]  12  13  14  15  ...