Microsoft MVP성태의 닷넷 이야기
WCF 질문드립니다. [링크 복사], [링크+제목 복사],
조회: 11635
글쓴 사람
이카루스 (iccaruss2 at hotmail.com)
홈페이지
첨부 파일
 

 WCF를 사용하여 SOAP 바디에 XML을 기술하여 메시지를 주고받고 있습니다..

 

원격 호출이 아닌 문서전송으로 모두 해결해야 합니다.

 

클라이언트가 전송을하고, 그에대한 응답메시지를 받게됩니다.

 

메시지를 보내서 재대로 메시지가 왔는지 출력을 해보았을때 메시지는 잘 오는걸 확인했습니다만.. SOAP 바디에 있는 XML을 파싱하는

 

방법을 모르겠군요.. 단기간내에 완벽히 이해를 못하고 오픈소스를 사용해서인지.. 잘 이해도 안가고 큰일입니다;;

 

일단 제가 짠 소스입니다.

 

 

 

 

[클라이언트]

 

 

    [ServiceContract]

    [XmlSerializerFormat]

    public interface IServiceDescription

    {

       [OperationContract(Action = "http://www.example.org/oceanwatch/ServiceDescriptionRequest", IsOneWay = true)]

        void ServDesc(ServDescReq request);

    }

 

    [MessageContract(IsWrapped=false)]

    public class ServDescReq

    {

        [MessageBodyMember]

        public ServDesc ServDesc;

        public ServDescReq() { }

        public ServDescReq(ServDesc report) { ServDesc = report; }

    }

 

    [XmlSchemaProvider(null, IsAny = true)]

    public class ServDesc : IXmlSerializable

    {

        string _namespace = "http://www.w3c.org/ssdl/ServiceDescriptionResponse";

 

        public ServDesc() { }

 

        public System.Xml.Schema.XmlSchema GetSchema()

        {

            return null;

        }

        public void ReadXml(XmlReader reader)

       {

            throw new Exception("The method or operation is not implemented.");

        }

        public void WriteXml(XmlWriter writer)

        {

            // SOAP 바디에 들어갈 XML, 상황에 따라서 더 복잡한 문서가 들어갈 수도 있습니다.

            writer.WriteStartElement("ssdl", "SSDL", _namespace);

            writer.WriteStartElement("Request", _namespace);

            writer.WriteStartElement("ssdl", "RequestDescription", _namespace);

            writer.WriteEndElement();

            writer.WriteEndElement();

        }

    }

 

위의 소스로 메시지를 생성하구요...

 

          using (ChannelFactory<IServiceDescription> channelNotification = new ChannelFactory<IServiceDescription>("Connect"))

            {

                channelNotification.Open();

                IServiceDescription manager = channelNotification.CreateChannel();

                ServDescReq request = new ServDescReq(new ServDesc());

 

                Console.ForegroundColor = ConsoleColor.Cyan;

                Console.WriteLine("EventSource에 보낼 ServiceDescription 요청(XML 문서)은 다음과 같습니다.");

                Console.ForegroundColor = ConsoleColor.White;

                Util.ShowMe(request);

                Console.ForegroundColor = ConsoleColor.Cyan;

                Console.WriteLine();

                Console.WriteLine();

                Console.WriteLine("EventSource에 보낼 ServiceDescription 요청(SOAP 문서)은 다음과 같습니다.");

                manager.ServDesc(request);

                Console.ResetColor();

                channelNotification.Close();

            }

위와 같이 서버에 메시지를 전송합니다.

 

 

 

 

 

 

 

 

 

[서버]

 

 

    [ServiceContract]

    [XmlSerializerFormat]

    public interface IServiceDescriptionRequest

    {

        [OperationContract(Action = "http://www.example.org/oceanwatch/ServiceDescriptionRequest", IsOneWay = true)]

        void ServDesc2(Message request);

    }

    public class ServiceDescriptionRequest : IServiceDescriptionRequest

    {

        public void ServDesc2(Message request)

        {

            Console.ForegroundColor = ConsoleColor.Cyan;

            Console.WriteLine("Subscriber에서 보낸 서비스 기술 요청(XML 원문)은 다음과 같습니다.");

            Console.ForegroundColor = ConsoleColor.White;

            Console.WriteLine(request);

            Console.WriteLine();

            Console.ForegroundColor = ConsoleColor.Cyan;

            Console.WriteLine("ServiceDescriptionResponse를 보냅니다. - Press any key to continue");

            Console.ResetColor();

        }

    }

위는 클라이언트의 메시지를 받는 인터페이스 이고요..

 

 

 

                using (ServiceHost serviceHost = new ServiceHost(typeof(ServiceDescriptionRequest)))

                {

                    Console.ForegroundColor = ConsoleColor.Cyan;

                    Console.WriteLine("Waiting Connect...");

                    Console.ResetColor();

                    serviceHost.Open();

                    Console.ReadLine();

                    serviceHost.Close();

                }

 

다음과 같이 호스트를 생성해서 클라이언트의 메시지를 받습니다.

 

 

일단 위 소스로 전송된 메시지를 찍어보면 보낸되로 출력되는것으로보아 작동은 잘 하고있는거 같은대요..

받은 Message 를 어떻게해야 파싱할 수 있는지요...








[최초 등록일: ]
[최종 수정일: 10/10/2007]


비밀번호

댓글 작성자
 




1  2  3  4  5  6  7  8  [9]  10  11  12  13  14  15  ...
NoWriterDateCnt.TitleFile(s)
5730김재환10/7/20224651WPF에서 디스플레이 배율이 100%가 아닌 경우, Window의 포지션 정보가 부정확해지는 문제 [2]
5729김기헌10/2/20224322안녕하세요 선생님 뮤텍스 관련 질문 드립니다 [2]
5728김경환9/29/20224384그리드뷰관련마지막질문하나드리겠습니다선생님 [5]파일 다운로드1
5727김경환9/26/20224290c# 윈폼 tcp/ip 기반 데이터그리드뷰질문하나드리겟습니다 [3]
5726양승조 donator9/22/20225025C# dll 과 C++ 간 배열 전달. SafeArray [10]파일 다운로드1
5725김기헌9/21/20223895안녕하세요 선생님 윈폼 컨트롤 Dispose 관련 질문드립니다 [2]
5724감사합니...9/19/20223923스레드와 스레드 안전한 객체 사용관련 문의드립니다. [5]
5723드리렁9/13/20223850Pinned Object에 대해서 질문이 있습니다. [2]
5722김인태9/8/20224017대화상자에서 alt + tab 후킹 작업 [1]
5721우종9/7/20224188C++ DLL 과 C# 연동 문의 [2]
5720한예지 donator9/6/20223869학습 방법 질문 있습니다. [7]
5719김경한9/6/20224203안녕하세요 질문하나만드리겠습니다...! [10]
5718김민아9/2/20224261안녕하세요 생성자 호출 시 초기화 순서 질문드립니다 [2]
5716iili...8/26/20224424WinDbg 커널 디버깅에서의 thread freeze [2]
5715에릭8/19/20224855WMI 쿼리 결과값이 Windows Service와 Console 출력에서 상이한 이유가 있을까요? [9]파일 다운로드1
5714허니빠8/18/20224886.net6 hint path 를 프로젝트 단위로 지정할 수 있는 방법을 알고싶습니다 [8]
5713김기헌8/17/20224815안녕하세요 rgb 계산 오차가 있는데 원인을 모르겠습니다.. [3]
5712하태8/17/20224282안녕하세요 background service에서 user32dll 접근 질문 드리겠습니다.! [2]
5711하태8/16/20223780안녕하세요! 윈도우즈 해상도 관련 질문 드립니다. [1]
5710장성욱8/12/20223997c# 시리얼 통신 관련 질문 [3]
5709초보8/12/20223803WPF 커맨드 관련 질문 [2]
5708민성8/11/20224072안녕하세요 c#에서 화면의 배율 및 레이아웃을 변경할려면 어떻게 해야 할까요? [2]파일 다운로드1
5707민성8/10/20223717WPF 엣지 컨트롤에서 화면이 안보이는 현상 [2]파일 다운로드1
5706종규8/7/20226169WPF 에서 SVG 아이콘 사용 방법 문의 [2]
5705김기헌8/6/20224846안녕하세요 선생님 싱글톤 패턴 간단 질문 [2]
5704따봉이8/4/20224731EventHandler 관련 [1]
1  2  3  4  5  6  7  8  [9]  10  11  12  13  14  15  ...