Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 19473
글쓴 사람
임동찬 (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)
5383민성9/8/202017021안녕하세요 자주 도움을 주셔서 감사드립니다. WPF에서 크롬 브라우저 삽입에 대하여 [1]
5382정씨9/4/202016376[C#] 시리얼통신 수신된 데이터를 그리드뷰에 뿌르는데 일정 시간이 지나면 버벅 거리는 이유가 뭘까요?? [3]
5381질문 있...9/4/202015768웹으로 사용하는 c#과 응용프로그램으로 사용하는 c#이 많이 다른가요?? [2]
5380yeon9/3/202015955winform 의 datagridview는 바인딩이 안 되나요? [1]
5379guest9/2/202019782시작하세요! C# 8.0 프로그래밍 책에 오타가 있습니다. [3]
5378net9/2/202016179mes 응용프로그램을 .net 웹폼으로 만들기도 하나요? [2]
5377net9/2/202014391.net 사용한 웹폼으로 응용프로그램을 만들경우 [1]
5376영귤9/1/202015687nullable 타입간의 비교연산은 그냥 가능한 건가요? [1]
5375영귤8/30/202017573이벤트와 델리게이트의 차이가 궁금합니다. [2]
5374guest8/27/202020087시작하세요! C# 8.0 프로그래밍 책에 오타가 있습니다. [1]
5373agj8/26/202017245System.Single::ToString()함수의 IL코드를 보았는데 ldnull, throw가 전부입니다. 왜 이렇게 짧죠? [2]
5372민성8/24/202017343안녕하세요 WPF 웹브라우저 컨트롤에서 웹브라우저 자체를 엣지로 할 수가 있나요? [2]
5371서현준8/11/202015992Hyper-V 내부 네트워크 환경 중, VM 에서 인터넷 접속 [1]
5370독자8/11/202013904.net createobject 관련 질문입니다.. [4]
5369독자8/10/202013661c# 8.0 프로그래밍 책에 대한 질문 드립니다 [1]
5368guest8/10/202015997시작하세요! C# 8.0 프로그래밍 책에 오타가 있습니다. [1]
5367박순기8/8/202013933디버깅 시 반전되는 부분 글 색상이나 배경색을 변경하는 방법 [3]파일 다운로드1
5366간절함8/7/202014554하나의 솔루션에서, 32비트 프로젝트에서 다른 64비트 프로젝트 참조하는 방법 궁금합니다. [4]
5365영귤8/6/202014102TimeSpan 구할 때 시간대를 바꿔도 같은 값이 나오는 것 같습니다. [1]
5364박순기8/5/202014244visual studio의 menu bar font size 변경방법 문의 [2]파일 다운로드1
5363클락8/1/202015287c# 9.0 출간 준비 중이신가요? [2]
5361하태7/29/202014345안녕하세요! 바이너리데이터 파싱 질문 드리겠습니다!. [2]
5360진우7/28/202015606엑셀에서 발생하는 모든 이벤트를 감지 할수 있는지 궁금합니다. [6]파일 다운로드1
5358홍길동7/22/202014100개체에서 open 속성이나 매서드가 지원 되지 않읍니다.라고 오류창이 뜨는데. [1]
5357손동섭7/22/202014964책 예제코드... [3]
5355neska7/21/202014341안녕하세요 문의 드립니다 [1]
... 16  17  18  19  20  21  22  [23]  24  25  26  27  28  29  30  ...