Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사]
조회: 12800
글쓴 사람
임동찬 (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)
5102돌고래12/18/20189503자료구조와 알고리즘 도서 관련 질문입니다. [4]
5101세퉁12/17/20187842안녕하세요 wpf 공부중인데 질문있습니다. [4]파일 다운로드1
5100돌고래12/16/20187205도서 추천 부탁드립니다. [1]
5099WPF12/12/201810214안녕하세요. WPF에서 UWP Control을 참조하려고 합니다. [3]파일 다운로드1
5097sdh12/10/201811383[c#] 라이선스 파일 만들기 질문 드립니다. [3]
5096거북이12/3/20187121프로젝트 구성을 참고할 만한 자료가 있을까요? [1]
5095한대현11/21/20187850안녕하세요 c# 설치 파일 빌드중 오류가 생겨서 문의 드려요 [1]파일 다운로드2
5094하주형11/20/20187479안녕하세요 C# using 예약어관련 질문드립니다. [1]
5093Medi...11/19/201810874안녕하세요. wpf Mediaelement 질문 있습니다. [3]
5092하주형11/17/20187457안녕하세요 c# 7.1책 스택관련 질문드립니다. [2]
5091아짱11/15/20188440UWP 개발중 질문이 있습니다. [3]
5090황윤하11/15/201812180c# Socket Server에 접근할 수 있는 client 개수 제한 [5]
5089문성운11/14/20189822uwp에서 TcpListener를 사용할 수 없나요? [5]
5088안중언11/10/20187571TCP 소켓 [1]파일 다운로드1
5084김광흠11/9/20189259사운드 파일 "filename.wav" 와 같은 특정 파일이 실행되는것을 감시하고 싶습니다. [3]
5083거북이11/4/20189562타입의 범위를 넘어서는 연산의 개념을 모르겠습니다. [4]
5082꾸엉11/1/20187672BCL 타입을 모아둔 곳이 있나요? [2]
5081꾸엉10/31/20187803C# 7.1 235p 질문입니다. [3]
5080WPF초보10/30/20189334[WPF] IsManipulationEnabled속성 설정시 Click이벤트 문의 [1]
5079jhp10/30/20188941이 소스에 API후킹 소스를 추가하고 싶은데 어떻게 해야될지 모르겠어요. [4]
5078꾸엉10/29/20187292C# 7.1 185~187p 질문입니다. [2]
5077윤현수10/29/201813727setup파일 설치 이후 실행이 안되는 현상 [11]
5074진우10/28/20187378C# 생성과 동시에 초기화 하는 코드 문의 [2]
5073돌고래10/27/20187479c# 공부 방향 질문 드립니다. [3]
5072엔벌잉10/24/20187998C# textbox, button질문입니다! [4]파일 다운로드1
5071엔벌잉10/23/20188376C#윈도우폼 질문입니다!! [2]
... [31]  32  33  34  35  36  37  38  39  40  41  42  43  44  45  ...