Microsoft MVP성태의 닷넷 이야기
WCF 질문드립니다. [링크 복사], [링크+제목 복사],
조회: 11603
글쓴 사람
이카루스 (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)
3667김치사발면12/15/201510789템플릿 설정 추가 질문 [1]파일 다운로드1
3666노태현12/15/201510203사용자별로 권한을 주고 볼 수 있는 데이터를 제한하려면 어떤 방법으로 접근하는게 좋을까요? [2]
3665김치사발면12/14/201513295C# 템플릿 설정이 이상해요ㅜㅜ [3]파일 다운로드1
3664KuLu12/10/201510586멀정하던 사이트 중 일부메뉴가 응답없음이 되어버립니다. [3]
3663Sung...12/10/201511985UWP 서버 프로그래밍 작업 중 [5]
3662Sung...12/9/201511817uwp앱에서 접속한 클라이언트 주소값을 받아서 표시하고 싶은데 어떤 메소드를 써야 할까요? [7]
3661김무진12/9/201511177Oracle 환경에서 데이터를 조회할때 한글이 ? 이렇게 표시가됩니다. [1]
3660질문자12/7/201513110OpenFileDialog 호출시 hang걸리는 문제 [4]
3659Sung...12/4/201512743UWP 앱에서 textBox로 클라에서 받은 값을 나타내고 싶은데 안되고 있습니다. [5]
3658강준12/3/201511989Visual Studio (Xamarin) vs Eclipse [2]
3656DEVY...12/1/201510893MasterPageFile 사용시 다국어 처리 질문입니다. [1]
3653DEVY...11/26/201512345ds:Signature 질문입니다. [7]
3654윤용한11/27/201512098    답변글 [답변]: ds:Signature 질문입니다. [3]
3657윤용한12/1/201514366    답변글 [답변]: ds:Signature 질문입니다. [1]
3651노태현11/20/201545086MariaDB - ASP.NET오류의 원인조차 못 찾고 있습니다.. [2]파일 다운로드2
3652노태현11/20/201511957    답변글 [답변]: MariaDB - ASP.NET오류의 원인조차 못 찾고 있습니다.. [3]
3649kokon11/17/201512361예제 파일 실행이 안 되네요 [5]
3647Sang...11/15/201510855Part 3 목차? [5]
3646힘찬도약11/13/201515700c# mscorlib System.IO IOException [8]파일 다운로드2
3644힘찬도약11/11/201514836c# user.config파일 [2]
3645spow...11/13/201511826    답변글 [답변]: c# user.config파일 - Json.NET을 이용한 설정파일 처리 [1]파일 다운로드1
3643힘찬도약11/11/201513641C# 함수의 processing time과 재호출 [14]
3642.net11/10/201512316c# 으로 작성된 com+ 에 대한 문제입니다. [2]
3641힘참도약11/9/201512743c# log file 관련해서 질문드립니다. [5]
3638윤창선11/4/201513319사설IP가 부여된 무선라우터간 영상전송 관련 문의 [8]
3634Hyun...11/2/201510895c# 에서 webkit browser에서 webgl을 이용하는 사이트에 접속이 안됩니다. [1]
... 46  [47]  48  49  50  51  52  53  54  55  56  57  58  59  60  ...