Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12865
글쓴 사람
임동찬 (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개의 소스 코드가 합쳐져서 결과물이 나오게 됩니다. ^^
정성태

... 16  17  18  19  20  21  22  23  24  25  26  [27]  28  29  30  ...
NoWriterDateCnt.TitleFile(s)
5219티지레몬9/9/20199677c# PCB 자동화 프로그램(윈도우 폼 위주로 작업) 제작 준비 [3]
5218민성9/9/20197709안녕하세요 WPF에서 xaml 안에 다른 xaml을 넣고 싶습니다. [1]파일 다운로드1
5216WPF9/8/20198803WPF에서 XAML Islands를 사용하여 Win2D를 사용하니 그래픽 품질이 저하됩니다. [2]파일 다운로드1
5215허송세월9/5/20198611중복실행 방지 관련 문의 [2]파일 다운로드1
5214Jang...9/4/20198242[DB 테이블의 데이터 변경에 대한 알림 처리] SQL-Server말고 MySQL은 불가능하겠죠? [1]
5213진우8/31/20197485c# 람다 변수 캡쳐 문의 [2]
5212심성보8/29/20199159Clipboard내 여러개의 이미지를 PictureBox로 불러오는 문제 [2]
5211최휘철8/24/20198340CLR20r3 관련된 윈도우 오류입니다. ㅠㅠ 도와주세요. / 아래글 관련하여 관련 파일 올려 드려요^^ [1]파일 다운로드1
5210최휘철8/23/201912239CLR20r3 관련된 윈도우 오류입니다. ㅠㅠ 도와주세요. [5]
5209세퉁8/21/20197874폰트 파일 속성 값을 가져오는 방법 질문 드립니다. [2]파일 다운로드1
5208홍길동8/19/20198705DebugDiag에서 .Net의 Stack Trace를 Windbg에서는 어떻게 볼 수 있나요? [3]
5207민성8/16/20197060네 소스 전체를 올리도록 하겠습니다. [2]파일 다운로드1
5206민성8/14/20197194전 재현 가능하다고 봤는데 다시올리도록 하겠습니다. [1]
5205miny...8/14/20198014안녕하세요 .WPF ListBox시 체크박스가 있는데 체크박스에서 체크가 되었는지 알수 있는 방법이 있을까요? [1]
5204영민8/8/201910795안녕하세요 디버깅시 콘솔창을 띠어서 볼수가 없나요? [7]
5202민성8/6/20197534WPF에서 <Application.Resources에 xaml에 있는 icon 값을 저장하고 xaml에 불러다 사용하고 싶은데요 [1]
5201김대훈8/3/20197136상속시 생성자에 대해 질문드립니다 [3]
5200농상7/30/20199833foreach로 데이터 변경 [2]
5190오리다람7/20/20197243질문드립니다. [3]
5189진우7/19/20197811C# 스레드풀 코어별 실행 문의 [2]
5188황태관7/19/20197002비주얼베이직 2019 실행 할때 마다.. [3]
5187플하7/19/20199819UWP 관련 궁금한 사항에 대해서 [1]
5186김대훈7/14/20198434박싱과 언박싱에 대해 [2]
5185농상7/13/20197307Nullable에 대해서 [1]
5184김대훈7/4/20197157저자님의 책을 다 본후에는 [2]
51837/2/20197870.NET Compact Freamwork 컨트롤러 더블버퍼링 [1]
... 16  17  18  19  20  21  22  23  24  25  26  [27]  28  29  30  ...