Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 12870
글쓴 사람
임동찬 (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)
1526황상대1/26/201513155C# 마샬링 관련 질문이 있습니다. [1]
1525Ji-y...1/19/201511759시작하세요 C# 프로그래밍 도서에 관한 질문입니다. [1]
1523임종복12/31/201419144windows 2008 r2에서 ms-sql 2008 서버사용시 tls문제점 [3]
1524임종복1/4/201514072    답변글 [답변]: windows 2008 r2에서 ms-sql 2008 서버사용시 tls문제점 [2]
1521윤대욱12/19/201411629C++ 에서 서버와 클라이언트를 나누어서 구조체 전달에 대해서 궁금합니다. [1]파일 다운로드1
152012/10/201411961datetime관련해서요 [1]
1516aTo12/1/201411435wpf 배포관련. [3]
1514얄미운제리11/17/201412702[C# Mono]Mono Chart 개발 문의드립니다. [1]
1355미나리나물11/13/201410244RDP 접속 방식 질문드리고 싶습니다. [1]
1353송용국11/10/20149399TeamFoundationServer 에 소스를 Target서버로 옮기는(내려주는) 방법 있나요? [1]
1351blue...11/7/201414214c# webbrowser 모바일환경 접속 [1]
1350에메11/7/201413685WCF namedpipe 퍼블리싱 충돌 문제 [3]파일 다운로드1
1349Chun...11/6/201418515Microsoft. Net Framework 액세스 거부 오류...... [2]
1348김준석11/6/201414360 Mini dump 기록 안되는 현상 [2]파일 다운로드1
1346개미11/5/201428756https페이지에서 http서버에 있는 이미지 파일 호출시 보안 오류 [8]
1345장구니11/4/201412273AWS 인스턴스를 만들었는데 [1]
1343h11/2/201412171안녕하세요 [1]
1342왕초보11/1/201417199C#에서의 함수포인터 [13]
1347왕초보11/5/201412364    답변글 [답변]: C#에서의 함수포인터 [1]
1341영택10/29/201413145MFC Amazon S3 사용관련하여 질문드립니다. [2]
1344영택11/4/20149904    답변글 [답변]: MFC Amazon S3 사용관련하여 질문드립니다. [2]
1340감사합니다10/28/201414304c# wpf shdocvw internet explorer를 윈도우프레임으로 집어 넣을 수 있는지 궁금합니다. [3]파일 다운로드1
1338헬프미10/28/201415246tcp 소켓의 SYN_RECV 상태에 대하여 질문있습니다. [3]
1336이소정10/27/201410766filestream seek에 대해 질문있습니다. [1]
1337이소정10/28/201410749    답변글 [답변]: filestream seek에 대해 질문있습니다.파일 다운로드1
1339이소정10/28/201413637        답변글 [답변]: [답변]: filestream seek에 대해 질문있습니다. [2]파일 다운로드2
... 46  47  48  49  50  51  [52]  53  54  55  56  57  58  59  60  ...