Microsoft MVP성태의 닷넷 이야기
WCF Service Reference [링크 복사], [링크+제목 복사],
조회: 19896
글쓴 사람
임동찬 (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)
3677초록색우산12/31/201522326HTTP 통신 - WebClient 이용시 한글깨짐 현상 발생 [2]
3676서정열12/31/201521975안녕하세요 WebService SoapExtensionImporter 에 대해서 질문드립니다. [3]
3675차가워12/30/201520729윈폼, 폼인폼 상황에서 하위컨트롤 포커스 문제 [1]
3673Sung...12/24/201522298UWP예외 발생 : 'System.Runtime.InteropServices.COMException'(mscorlib.ni.dll) 해결방법 [2]
3672Sung...12/23/201520450global::System.Diagnostics.Debugger.Break();가 노랗게 표시될시 [2]
3671이상준12/22/201525652한글 키보드 입력에 대해서 질문이 있습니다. [3]
3670Sung...12/18/201520540UWP 주기적으로 신호를 보내고 클라이언트에서 신호가 오면 받는 프로그램을 하려고 합니다. [5]
3669다비드12/18/201519815인터넷 임시파일 삭제 관련 질문. [1]
3668김치사발면12/16/201519156템플릿이 자꾸 초기화? 되버리네요 [1]
3667김치사발면12/15/201518684템플릿 설정 추가 질문 [1]파일 다운로드1
3666노태현12/15/201517905사용자별로 권한을 주고 볼 수 있는 데이터를 제한하려면 어떤 방법으로 접근하는게 좋을까요? [2]
3665김치사발면12/14/201521248C# 템플릿 설정이 이상해요ㅜㅜ [3]파일 다운로드1
3664KuLu12/10/201517819멀정하던 사이트 중 일부메뉴가 응답없음이 되어버립니다. [3]
3663Sung...12/10/201520057UWP 서버 프로그래밍 작업 중 [5]
3662Sung...12/9/201519486uwp앱에서 접속한 클라이언트 주소값을 받아서 표시하고 싶은데 어떤 메소드를 써야 할까요? [7]
3661김무진12/9/201519424Oracle 환경에서 데이터를 조회할때 한글이 ? 이렇게 표시가됩니다. [1]
3660질문자12/7/201521565OpenFileDialog 호출시 hang걸리는 문제 [4]
3659Sung...12/4/201521466UWP 앱에서 textBox로 클라에서 받은 값을 나타내고 싶은데 안되고 있습니다. [5]
3658강준12/3/201520108Visual Studio (Xamarin) vs Eclipse [2]
3656DEVY...12/1/201519952MasterPageFile 사용시 다국어 처리 질문입니다. [1]
3653DEVY...11/26/201522155ds:Signature 질문입니다. [7]
3654윤용한11/27/201522164    답변글 [답변]: ds:Signature 질문입니다. [3]
3657윤용한12/1/201523480    답변글 [답변]: ds:Signature 질문입니다. [1]
3651노태현11/20/201554657MariaDB - ASP.NET오류의 원인조차 못 찾고 있습니다.. [2]파일 다운로드2
3652노태현11/20/201521690    답변글 [답변]: MariaDB - ASP.NET오류의 원인조차 못 찾고 있습니다.. [3]
3649kokon11/17/201521148예제 파일 실행이 안 되네요 [5]
... 46  47  [48]  49  50  51  52  53  54  55  56  57  58  59  60  ...