Microsoft MVP성태의 닷넷 이야기
WCF 질문드립니다. [링크 복사], [링크+제목 복사]
조회: 11589
글쓴 사람
이카루스 (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]


비밀번호

댓글 작성자
 




... 46  47  48  49  50  51  52  53  54  55  56  57  [58]  59  60  ...
NoWriterDateCnt.TitleFile(s)
1180김형지11/6/201314538안녕하십니까. 프로그램이 실행되지 않아 여쭙고자 합니다ㅠ [1]파일 다운로드1
1179이민석11/4/201314096[긴급질문] [in,out] 배열을 C# 에서 C/C++ 로 넘기는 방법 - 두번째 이야기 관련 질문.. [6]파일 다운로드1
1178박진영11/1/201313686[급질문] IIS 하위 가상폴더 구성 문의 [4]
1177Jeon...10/28/201310569안녕하세요~ 어머니께 물어서 사이트를 찾아왔어요 [2]
1176김태훈10/25/201310339AxWebBrowser에 대해 질문드립니다. [1]
1175서경희10/20/201315339netscape 지원이 되지 않는다는 문구.. [2]파일 다운로드1
1174임동찬10/16/201314151프리징 현상에 대한 고민 [5]
1173김재영10/8/20139935인터페이스에 대해 기초적 질문이 있습니다. [2]파일 다운로드1
1172박진영10/2/201312834웹사이트 연결시 AJAX 어셈블리 오류 문의드립니다. [5]파일 다운로드1
1171링거8/30/201320787ClickOnce 업데이트 문제. [4]
1170임동찬8/28/201312113비동기적 이벤트 핸들링 방법 [2]
1167나종식8/20/201311221win7 에서 LSP 가 DNS Client 에 인젝션 안되는 문제 [6]
1165임동찬8/19/201310539오류 발생시 로깅 문제.. [3]
1164박철8/19/201311167모바일 게임서버를 작성 하려면 무엇부터 시작하여야 하나요? [2]
1163안연준8/2/201310649음... 안녕하세요 ^^ 윈도우즈 폼에 대해서 잠시 물어볼께요 [3]
1162박진영7/23/201391131개의 PC에서 동일사이트 접속제한을 어떻게 하죠? [1]
1161Ji Y...7/12/201311840안녕하세요? 음성인식 관련해서 질문있습니다, [2]
1160이상식7/12/201312220웹서비스 커넥션 풀 오류입니다. [6]
1159김덕성7/4/201320416C# 마샬링 관련 문의입니다 [3]
1157이상식6/26/201314078빌드시 오류인데 원인을 모르겠네요. [2]파일 다운로드1
1156정환나라6/20/201311249In-Process Side-By-Side 동작 원리는 어떻게 되는걸까요? [3]
1155MD워시퍼6/20/201310274안녕하세요. 한가지 궁금한 것이 있어서 문의를 드립니다. [1]
1154it 대...6/13/201313330무선 패킷 스니핑 프로그램 [1]
1153이상헌6/8/201310822죄송합니다;; 또다시 의문점이 생겨 질문드립니다. [1]
1152이상헌6/8/201310508넷두이노 플러스 펌웨어 다운로드가 안되네요;;; [1]
1151황기동6/5/201311307무선 패킷 전송관련 질문 [1]
... 46  47  48  49  50  51  52  53  54  55  56  57  [58]  59  60  ...