public virtual HelloWCFResponse HelloWCF(HelloWCF req)
        {
            // Create request header
            String action;

            action = "http://localhost/ServiceHelloWCF/IServiceHelloWCF/HelloWCF";
            WsWsaHeader header;

            header = new WsWsaHeader(action, null, EndpointAddress, m_version.AnonymousUri, null, null);
            WsMessage request = new WsMessage(header, req, WsPrefix.None);

            // Create request serializer
            HelloWCFDataContractSerializer reqDcs;

            reqDcs             = new HelloWCFDataContractSerializer("HelloWCF", "http://localhost/ServiceHelloWCF");
            request.Serializer = reqDcs;
            request.Method     = "HelloWCF";


            // Send service request
            m_requestChannel.Open();
            WsMessage response = m_requestChannel.Request(request);

            m_requestChannel.Close();

            // Process response
            HelloWCFResponseDataContractSerializer respDcs;

            respDcs = new HelloWCFResponseDataContractSerializer("HelloWCFResponse", "http://localhost/ServiceHelloWCF");
            HelloWCFResponse resp;

            resp = ((HelloWCFResponse)(respDcs.ReadObject(response.Reader)));
            return(resp);
        }
        public virtual HelloWCFResponse HelloWCF(HelloWCF req)
        {

            // Create request header
            String action;
            action = "http://localhost/ServiceHelloWCF/IServiceHelloWCF/HelloWCF";
            WsWsaHeader header;
            header = new WsWsaHeader(action, null, EndpointAddress, m_version.AnonymousUri, null, null);
            WsMessage request = new WsMessage(header, req, WsPrefix.None);

            // Create request serializer
            HelloWCFDataContractSerializer reqDcs;
            reqDcs = new HelloWCFDataContractSerializer("HelloWCF", "http://localhost/ServiceHelloWCF");
            request.Serializer = reqDcs;
            request.Method = "HelloWCF";


            // Send service request
            m_requestChannel.Open();
            WsMessage response = m_requestChannel.Request(request);
            m_requestChannel.Close();

            // Process response
            HelloWCFResponseDataContractSerializer respDcs;
            respDcs = new HelloWCFResponseDataContractSerializer("HelloWCFResponse", "http://localhost/ServiceHelloWCF");
            HelloWCFResponse resp;
            resp = ((HelloWCFResponse)(respDcs.ReadObject(response.Reader)));
            response.Reader.Dispose();
            response.Reader = null;
            
            return resp;
        }
        public HelloWCFResponse HelloWCF(HelloWCF req)
        {
            HelloWCFResponse resp = new HelloWCFResponse();

            resp.HelloWCFResult = "Hello " + req.name;

            return resp;
        }
        public HelloWCFResponse HelloWCF(HelloWCF req)
        {
            HelloWCFResponse resp = new HelloWCFResponse();

            resp.HelloWCFResult = "Hello " + req.name;

            return(resp);
        }
예제 #5
0
        public override void WriteObject(XmlWriter writer, object graph)
        {
            HelloWCF HelloWCFField = ((HelloWCF)(graph));

            if (WriteParentElement(writer, true, true, graph))
            {
                if (WriteChildElement(writer, "name", true, false, HelloWCFField.name))
                {
                    writer.WriteString(HelloWCFField.name);
                    writer.WriteEndElement();
                }
                writer.WriteEndElement();
            }
            return;
        }
예제 #6
0
 public override object ReadObject(XmlReader reader)
 {
     HelloWCF HelloWCFField = null;
     if (IsParentStartElement(reader, false, true))
     {
         HelloWCFField = new HelloWCF();
         reader.Read();
         if (IsChildStartElement(reader, "name", false, true))
         {
             reader.Read();
             HelloWCFField.name = reader.ReadString();
             reader.ReadEndElement();
         }
         reader.ReadEndElement();
     }
     return HelloWCFField;
 }
예제 #7
0
        public override object ReadObject(XmlReader reader)
        {
            HelloWCF HelloWCFField = null;

            if (IsParentStartElement(reader, false, true))
            {
                HelloWCFField = new HelloWCF();
                reader.Read();
                if (IsChildStartElement(reader, "name", true, false))
                {
                    reader.Read();
                    HelloWCFField.name = reader.ReadString();
                    reader.ReadEndElement();
                }
                reader.ReadEndElement();
            }
            return(HelloWCFField);
        }
        public void Run()
        {

            Uri remoteEp = new Uri("http://localhost:8001/ServiceHelloWCF");
            WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(remoteEp));

            /// ProtocolVersion11 can be used if the corresponding WCF desktop server application
            /// WcfServer uses wsHttpBinding instead of the custom binding "Soap11AddressingBinding"
            m_clientProxy = new ServiceHelloWCFClientProxy(binding, new ProtocolVersion11());

            m_clientProxy.IgnoreRequestFromThisIP = false;

            if (!Discover(m_clientProxy))
            {
                Debug.Print("Discovery failed, trying direct address");
                m_clientProxy.EndpointAddress = "http://localhost:8084/319D0A4D-2253-47DC-AC4A-C1951FF6667D";
            }

            HelloWCF req = new HelloWCF();
            req.name = "World";

            try
            {
                HelloWCFResponse resp = m_clientProxy.HelloWCF(req);

                Debug.Print("\n\n*****************");
                Debug.Print(resp.HelloWCFResult);
                Debug.Print("*****************\n\n");
            }
            catch (WsFaultException ex)
            {
                Debug.Print("DPWS Fault: " + ex.Message);
            }

            m_clientProxy.Dispose();
        }
        public void Run()
        {

            Uri remoteEp = new Uri("http://localhost:8084/ServiceHelloWCF.svc");
            WS2007HttpBinding binding = new WS2007HttpBinding(new HttpTransportBindingConfig(remoteEp));

            ProtocolVersion ver = new ProtocolVersion11();
            // To enable WSDiscoveryApril2005 and Soap12WSAddressingAugust2004
            //ProtocolVersion ver = new ProtocolVersion10();

            /// ProtocolVersion11 can be used if the corresponding WCF desktop server application
            /// WcfServer uses wsHttpBinding instead of the custom binding "Soap11AddressingBinding"
            m_clientProxy = new ServiceHelloWCFClientProxy(binding, ver);

            m_clientProxy.IgnoreRequestFromThisIP = false;

            if (!Discover(m_clientProxy))
            {
                Debug.Print("Discovery failed, trying direct address");
            }

            HelloWCF req = new HelloWCF();
            req.name = "World";

            try
            {
                HelloWCFResponse resp = m_clientProxy.HelloWCF(req);

                Debug.Print("\n\n*****************");
                Debug.Print(resp.HelloWCFResult);
                Debug.Print("*****************\n\n");
            }
            catch (WsFaultException ex)
            {
                Debug.Print("DPWS Fault: " + ex.Message);
            }
            finally
            {
                m_clientProxy.Dispose();
            }
        }