Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12885
글쓴 사람
임동찬 (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)
5756흰털너부리11/25/20223499asp.net core web api에서 json 특정 property 무시하는 방법 문의 드립니다. System.Text.Json 사용중입니다. [1]
5755문정환11/24/20223821싱글스레드 프로그램도 컨텍스트 스위칭이 생길 수 있나요? [4]
5754초급11/24/20223667c# 소켓통신 [1]
5753흰털너부리11/24/20223480List와 ObservableCollection을 비교 해서 다른 값 추출 FirstOrDefault 객체 비교 [4]파일 다운로드1
5752푸헐11/15/20223622app.config 에 connectionStrings를 aspnet_regiis로 enctyption [4]
5751차가워11/8/20224421vs2022 preview net7 AOT 콘솔 실행 성능 [7]
5749차가워11/4/20223833전처리 지시문 #if DEBUG 배포시 실행 여부 [1]
5748김기헌11/3/20224172안녕하세요 선생님 싱글톤 패턴을 꼭 이렇게 사용해야 하나요? [6]
5747김기헌11/2/20223564안녕하세요 선생님 네트워크 관련 용어 중 IP 주소가 왜 논리적 주소라고 표현되는 건가요? [2]
5746물냉면이...11/2/20223750서로 다른 클래스에 있는 동일 함수의 일괄 호출 방법에 대해 궁금합니다. [3]
5745흰털너부리11/1/20224099.net core web api 사용 제한에 관한 질문 입니다. [2]
5744차가워10/31/20224482윈폼 Console.WriteLine(); 연산 문의 [1]
5743흰털너부리10/27/20223806reflection, static, override 질문입니다. [1]
5742차가워10/27/20223716하나의 socket에 여러 스레드가 접근 하는 경우 [1]
5741조호상10/27/20223948OpenCVSharp4 구현 가능 문의 [1]
5740혜성10/26/20224789Visual Studio 2022 C# 콘솔 프로그램 기본 코드 변경된 이유는 무엇인가요? [2]
5739슬픈단잠10/25/20223744조언 주신 방법으로 해봤으나, 여전히 어디가 문제인지 파악을 못했습니다. [2]
5738슬픈단잠10/24/20224142C# 마샬링 관련 질문입니다. [2]
5737감사합니...10/20/20224810찾은 어셈블리의 매니페스트 정의와 어셈블리 참조가 일치하지 않습니다. [8]파일 다운로드1
5736초보 개...10/19/20223794c# winforms 프로그램을 setup 파일로 배포 시, 설정 문의 [2]
5735농상10/17/20224455싱글톤 공부중 질문이 있습니다. [8]
5734mins10/14/20224198델파이 dll을 c#에서 사용하기 관련해서 포인트 관련이라 질문을 올립니다. [2]
5733김경환10/12/20224235선생님 질문하나만드리겠습니다. [1]
5732kss10/8/20224493c# socket.poll 버그인가요? [2]파일 다운로드1
5731kss10/8/20224058c# socket.poll 버그인가요? [3]
5730김재환10/7/20224601WPF에서 디스플레이 배율이 100%가 아닌 경우, Window의 포지션 정보가 부정확해지는 문제 [2]
1  2  3  4  5  6  7  [8]  9  10  11  12  13  14  15  ...