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

... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...
NoWriterDateCnt.TitleFile(s)
3634Hyun...11/2/201510909c# 에서 webkit browser에서 webgl을 이용하는 사이트에 접속이 안됩니다. [1]
3633힘찬도약10/31/201511562mysql insert where not exists [6]
3632힘찬도약10/27/201512212C# Lock 관련해서 질문드립니다. [6]
3655iwc11/30/201510345    답변글 [답변]: C# Lock 관련해서 질문드립니다.
3631강준10/26/201513185iis 8.5 preload 기능에 대해 질문이 있습니다. [9]
3630김정훈10/25/201511590몬티홀 게임 관련 질문 [1]
3629pooq10/23/201512102리플렉션 관련해서 질문 입니다. [3]
3628최영민10/22/201511065스마트 클라이언트 로딩속도 문의입니다. [3]
3627양주호10/22/201510861C#으로 컨버팅 하려고 하는데요... [1]
3626조성진10/21/201512014책보고 첫번째 예제부터 문제가 생기네요 ^^; [4]파일 다운로드1
3623Bere...10/19/201512037질문이라기 보단... [2]
3625Bere...10/20/201511545    답변글 [답변]: 질문이라기 보단... [2]파일 다운로드1
3621힘찬도약10/18/201511642[C# 6.0]multi threading과 ui control [9]
3624힘찬도약10/19/201511532    답변글 [답변]: [C# 6.0]multi threading과 ui control [6]파일 다운로드1
3620popo10/13/201510484WPF의 datagrid, listview 컨트롤 관련 질문 입니다. [1]
3619링크의 ...10/12/201514996OCX 로드 관련 질문입니다. [5]파일 다운로드1
3616수요일밥...10/7/201515356몇 가지 오류 (2) [6]
3615김응규10/7/201510726다시한번 질문 드립니다. (이번엔 자세하게 기술했습니다.) [1]
3614김응규10/6/20159594안녕하세요. wcf net.tcp 관련 질문 하나만 올려요~~ [4]
3613강준10/5/201514401IIS Application Pool 시작/중단 에 대한 이벤트 로그는 어디에 남나요??? [2]
3612심심한일...10/4/201516360몇 가지 오류 [4]
3611나그네9/30/201510725안녕하세요 답글을 이제 보았습니다. [3]
3608기차니9/21/201511509컬럼이 많은 데이터그리드에서 정렬 할 때 속도가 느립니다. [3]
3609기차니9/22/201511615    답변글 [답변]: 컬럼이 많은 데이터그리드에서 정렬 할 때 속도가 느립니다. [1]파일 다운로드1
3610기차니9/23/201512480        답변글 [답변]: [답변]: 컬럼이 많은 데이터그리드에서 정렬 할 때 속도가 느립니다. [5]파일 다운로드1
3606guest9/20/201511069확장 클래스 네이밍 규칙은 어떻게 하시나요? [1]
... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...