public virtual GetDataResponse GetData(GetData req)
        {

            // Create request header
            String action;
            action = "http://tempuri.org/IDataAccessService/GetData";
            WsWsaHeader header;
            header = new WsWsaHeader(action, null, EndpointAddress, m_version.AnonymousUri, null, null);
            WsMessage request = new WsMessage(header, req, WsPrefix.None);

            // Create request serializer
            GetDataDataContractSerializer reqDcs;
            reqDcs = new GetDataDataContractSerializer("GetData", "http://tempuri.org/");
            request.Serializer = reqDcs;
            request.Method = "GetData";


            // Indicate that this message will use Mtom encoding
            request.BodyParts = new WsMtomBodyParts();

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

            // Process response
            GetDataResponseDataContractSerializer respDcs;
            respDcs = new GetDataResponseDataContractSerializer("GetDataResponse", "http://tempuri.org/");
            respDcs.BodyParts = response.BodyParts;
            GetDataResponse resp;
            resp = ((GetDataResponse)(respDcs.ReadObject(response.Reader)));
            return resp;
        }
Esempio n. 2
0
 public override object ReadObject(XmlReader reader)
 {
     GetData GetDataField = null;
     if (IsParentStartElement(reader, false, true))
     {
         GetDataField = new GetData();
         reader.Read();
         if (IsChildStartElement(reader, "value", false, false))
         {
             reader.Read();
             GetDataField.value = XmlConvert.ToInt32(reader.ReadString());
             reader.ReadEndElement();
         }
         reader.ReadEndElement();
     }
     return GetDataField;
 }
        public virtual GetDataResponse GetData(GetData req)
        {
            // Create request header
            String action;

            action = "http://tempuri.org/IDataAccessService/GetData";
            WsWsaHeader header;

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

            // Create request serializer
            GetDataDataContractSerializer reqDcs;

            reqDcs             = new GetDataDataContractSerializer("GetData", "http://tempuri.org/");
            request.Serializer = reqDcs;
            request.Method     = "GetData";


            // Indicate that this message will use Mtom encoding
            request.BodyParts = new WsMtomBodyParts();

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

            m_requestChannel.Close();

            // Process response
            GetDataResponseDataContractSerializer respDcs;

            respDcs           = new GetDataResponseDataContractSerializer("GetDataResponse", "http://tempuri.org/");
            respDcs.BodyParts = response.BodyParts;
            GetDataResponse resp;

            resp = ((GetDataResponse)(respDcs.ReadObject(response.Reader)));
            response.Reader.Dispose();
            response.Reader = null;

            return(resp);
        }
Esempio n. 4
0
        private void TestMtomService()
        {
            try
            {
                WS2007HttpBinding binding = new WS2007HttpBinding(
                    new HttpTransportBindingConfig(new Uri("http://*****:*****@"A bedtime story is a traditional form of storytelling, where a story is told to a child at bedtime to prepare them for sleep.
Bedtime stories have many advantages, for parents/adults and children alike. The fixed routine of a bedtime story before sleeping has a relaxing effect, and the soothing voice of a person telling a story makes the child fall asleep more easily. The emotional aspect creates a bond between the storyteller and the listener, often a parent and child.
Bedtime stories can be read from a book, or rather, fictional stories made up by the storyteller. The stories are mostly rather short, between one and five minutes, and have a happy ending. A different form of bedtime reading is using longer stories, but dividing them up, thus creating cliffhangers. Children will look forward to their bedtime story, and a fixed routine is installed.
");
                m_proxy.SetData(req);

                GetData req2 = new GetData();
                // get bytes < 1000 to test Base64
                req2.value = 0;
                GetDataResponse resp = m_proxy.GetData(req2);
                Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp.GetDataResult.Data)));
                
                // to get data > 1000 bytes to test mtom
                req2.value = 1;
                resp = m_proxy.GetData(req2);
                Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp.GetDataResult.Data)));

                // to get data > 1000 (non-char) bytes to test mtom
                req2.value = 2;
                resp = m_proxy.GetData(req2);
                for (int i = 0; i < resp.GetDataResult.Data.Length; i++)
                {
                    if ((byte)i != resp.GetDataResult.Data[i])
                    {
                        Debug.Print("FAILURE!!!!! expected incrementing data byte values");
                        break;
                    }
                }

                SetNestedData req3 = new SetNestedData();
                req3.data = new schemas.datacontract.org.WcfMtomService.NestedClass();
                req3.data.MTData = new schemas.datacontract.org.WcfMtomService.MtomData();
                req3.data.MTData.Data = System.Text.UTF8Encoding.UTF8.GetBytes( @"A bedtime story is a traditional form of storytelling, where a story is told to a child at bedtime to prepare them for sleep." );
                req3.data.MyData = System.Text.UTF8Encoding.UTF8.GetBytes(@"Bedtime stories have many advantages, for parents/adults and children alike. The fixed routine of a bedtime story before sleeping has a relaxing effect, and the soothing voice of a person telling a story makes the child fall asleep more easily. The emotional aspect creates a bond between the storyteller and the listener, often a parent and child.");
                m_proxy.SetNestedData(req3);

                GetNestedData req4 = new GetNestedData();

                GetNestedDataResponse resp8 = m_proxy.GetNestedData(req4);
                Debug.Print(new string(System.Text.UTF8Encoding.UTF8.GetChars(resp8.GetNestedDataResult.MyData)));
                for (int i = 0; i < resp8.GetNestedDataResult.MTData.Data.Length; i++)
                {
                    if ((byte)i != resp8.GetNestedDataResult.MTData.Data[i])
                    {
                        Debug.Print("FAILURE!!!!! expected incrementing data byte values");
                        break;
                    }
                }


                SetFileInfo sfi = new SetFileInfo();

                sfi.files = new schemas.datacontract.org.WcfMtomService.ArrayOfFileInfo();

                sfi.files.FileInfo = new schemas.datacontract.org.WcfMtomService.FileInfo[2];

                sfi.files.FileInfo[0] = new schemas.datacontract.org.WcfMtomService.FileInfo();
                sfi.files.FileInfo[0].Name = "MyBook";
                sfi.files.FileInfo[0].Size = 340;
                sfi.files.FileInfo[1] = new schemas.datacontract.org.WcfMtomService.FileInfo();
                sfi.files.FileInfo[1].Name = "MyBook2";
                sfi.files.FileInfo[1].Size = 341;

                m_proxy.SetFileInfo(sfi);
            }
            catch (System.IO.IOException)
            {
                // Is the web service down???
                Debug.Print("Warning: could not connect to stocks web service");
            }
            finally
            {
                if (m_proxy != null) m_proxy.Dispose();
            }
        }