Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12850
글쓴 사람
임동찬 (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)
5376영귤9/1/20206991nullable 타입간의 비교연산은 그냥 가능한 건가요? [1]
5375영귤8/30/20208470이벤트와 델리게이트의 차이가 궁금합니다. [2]
5374guest8/27/20209565시작하세요! C# 8.0 프로그래밍 책에 오타가 있습니다. [1]
5373agj8/26/20207775System.Single::ToString()함수의 IL코드를 보았는데 ldnull, throw가 전부입니다. 왜 이렇게 짧죠? [2]
5372민성8/24/20207777안녕하세요 WPF 웹브라우저 컨트롤에서 웹브라우저 자체를 엣지로 할 수가 있나요? [2]
5371서현준8/11/20206839Hyper-V 내부 네트워크 환경 중, VM 에서 인터넷 접속 [1]
5370독자8/11/20205855.net createobject 관련 질문입니다.. [4]
5369독자8/10/20206214c# 8.0 프로그래밍 책에 대한 질문 드립니다 [1]
5368guest8/10/20207494시작하세요! C# 8.0 프로그래밍 책에 오타가 있습니다. [1]
5367박순기8/8/20206407디버깅 시 반전되는 부분 글 색상이나 배경색을 변경하는 방법 [3]파일 다운로드1
5366간절함8/7/20207109하나의 솔루션에서, 32비트 프로젝트에서 다른 64비트 프로젝트 참조하는 방법 궁금합니다. [4]
5365영귤8/6/20206341TimeSpan 구할 때 시간대를 바꿔도 같은 값이 나오는 것 같습니다. [1]
5364박순기8/5/20206388visual studio의 menu bar font size 변경방법 문의 [2]파일 다운로드1
5363클락8/1/20207005c# 9.0 출간 준비 중이신가요? [2]
5361하태7/29/20206622안녕하세요! 바이너리데이터 파싱 질문 드리겠습니다!. [2]
5360진우7/28/20207518엑셀에서 발생하는 모든 이벤트를 감지 할수 있는지 궁금합니다. [6]파일 다운로드1
5358홍길동7/22/20206273개체에서 open 속성이나 매서드가 지원 되지 않읍니다.라고 오류창이 뜨는데. [1]
5357손동섭7/22/20206345책 예제코드... [3]
5355neska7/21/20206722안녕하세요 문의 드립니다 [1]
5354민성7/15/20208187안녕하세요 db연결 문자 보안 [2]
5353형성재7/14/20207252Visual Studio Setup Project에서 VC++2010재배포패키지설치 [4]
5352윤식7/10/20207219닷넷코어 빌드 시 runtimeconfig 파일을 없앨 수 있는지.. [4]
5351runr...7/2/20207093C# 에서 C++ dll 병렬 사용 [1]
5350홍성호6/29/20208713C++에서 정의된 구조체(공유메모리)를 C#으로 공유메모리에서 구조체 변환시 에러가 발생 합니다. [1]파일 다운로드1
5349jero...6/24/20206231logon credential provider 관련 문의드립니다. [1]
5348776/19/20205998시작하세요 C# 8.0프로그래밍 책에 대한 질문입니다. [8]
... 16  17  18  19  20  21  [22]  23  24  25  26  27  28  29  30  ...