当前位置: 首页>>代码示例>>C#>>正文


C# ServiceClient.GetData方法代码示例

本文整理汇总了C#中ServiceClient.GetData方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient.GetData方法的具体用法?C# ServiceClient.GetData怎么用?C# ServiceClient.GetData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ServiceClient的用法示例。


在下文中一共展示了ServiceClient.GetData方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WorkflowExtensionsBehaviorAddsExtension

        public void WorkflowExtensionsBehaviorAddsExtension()
        {
            WorkflowServiceTestHost host = null;

            // TODO: Test with multiple extensions
            // TODO: Test with bad config file entries
            var serviceEndpoint1 = ServiceTest.GetUniqueEndpointAddress();
            using (host = WorkflowServiceTestHost.Open("ServiceExtensionTest.xamlx", serviceEndpoint1))
            {
                try
                {
                    var proxy = new ServiceClient(ServiceTest.Pipe, serviceEndpoint1);
                    try
                    {
                        proxy.GetData(1);
                        proxy.Close();
                    }
                    catch (Exception)
                    {
                        proxy.Abort();
                        throw;
                    }
                }
                finally
                {
                    if (host != null)
                    {
                        host.Tracking.Trace();
                    }
                }
            }
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:32,代码来源:WorkflowExtensionsBehaviorTest.cs

示例2: Wrong

 private void Wrong()
 {
     string data;
     using (var client = new ServiceClient().GetProxy())
     {
         data = client.GetData(int.Parse(txtData.Text));
     }
     ltlData.Text = data;
 }
开发者ID:rmandvikar,项目名称:WcfServiceClientHelper,代码行数:9,代码来源:Default.aspx.cs

示例3: Main

        static void Main(string[] args)
        {
            ServiceClient c = new ServiceClient();

            foreach (OperationDescription opDesc in c.Endpoint.Contract.Operations)
            {
                ApplyDataContractSurrogate(opDesc);
            }

            ParentClass pc =  c.GetData(100);
        }
开发者ID:Kemyke,项目名称:WcfBinarySurrogate,代码行数:11,代码来源:Program.cs

示例4: ShouldInvokeAverageExtensionWithService

        public void ShouldInvokeAverageExtensionWithService()
        {
            const string Expected1 = "Stored 33, Average:33";
            const string Expected2 = "Stored 44, Average:38.5";
            const string Expected3 = "Stored 55, Average:44";

            // Reset the static collection
            AverageExtension.Reset();

            // Self-Host Service1.xamlx using Named Pipes
            var address = ServiceTest.GetUniqueEndpointAddress();
            using (WorkflowServiceTestHost.Open("Service1.xamlx", address))
            {
                string result1;
                string result2;
                string result3;

                // Use the generated proxy with named pipes
                var proxy = new ServiceClient(ServiceTest.Pipe, address);

                try
                {
                    result1 = proxy.GetData(33);
                    result2 = proxy.GetData(44);
                    result3 = proxy.GetData(55);
                    proxy.Close();
                }
                catch (Exception)
                {
                    proxy.Abort();
                    throw;
                }

                Assert.AreEqual(Expected1, result1);
                Assert.AreEqual(Expected2, result2);
                Assert.AreEqual(Expected3, result3);
            }
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:38,代码来源:GetAverageTest.cs

示例5: ButtonSubmit_Click

 protected void ButtonSubmit_Click(object sender, EventArgs e)
 {
     var proxy = new ServiceClient();
     try
     {
         var sampleResponse = proxy.GetData(TextBoxKey.Text);
         LabelValue.Text = sampleResponse.Data.Value;
         RadioButtonHit.Checked = sampleResponse.CacheHit;
         RadioButtonMiss.Checked = !sampleResponse.CacheHit;
         proxy.Close();
     }
     catch (Exception)
     {
         proxy.Abort();
         throw;
     }
 }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:17,代码来源:Default.aspx.cs

示例6: Correct

 private void Correct()
 {
     string data;
     bool success = false;
     ServiceClient client = null;
     try
     {
         client = new ServiceClient().GetProxy();
         data = client.GetData(int.Parse(txtData.Text));
         client.Close();
         success = true;
     }
     finally
     {
         if (!success && client != null)
         {
             client.Abort();
         }
     }
     ltlData.Text = data;
 }
开发者ID:rmandvikar,项目名称:WcfServiceClientHelper,代码行数:21,代码来源:Default.aspx.cs

示例7: BehaviorCanBeAddedViaConfig

        public void BehaviorCanBeAddedViaConfig()
        {
            // Arrange
            var serviceEndpoint = ServiceTest.GetUniqueEndpointAddress();
            using (WorkflowServiceTestHost.Open(Constants.DefaultServiceXamlx, serviceEndpoint))
            {
                var proxy = new ServiceClient(ServiceTest.Pipe, serviceEndpoint);
                try
                {
                    // Act
                    var result = proxy.GetData(123);
                    proxy.Close();

                    // Assert
                    Assert.AreEqual("123", result);
                }
                catch
                {
                    proxy.Abort();
                    throw;
                }
            }
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:23,代码来源:SilverlightFaultBehaviorTest.cs

示例8: Main

        static void Main(string[] args)
        {
            Console.WriteLine("Invoking service using SOAP client");
            using (ServiceClient proxy = new ServiceClient())
            {
                Console.WriteLine("Calling PutData with value 42");
                Console.WriteLine(proxy.PutData(42));
                Console.WriteLine("GetData returned: " + proxy.GetData());
            }

            Console.WriteLine("Invoking service using HTTP");
            Uri baseAddress = new Uri("http://localhost:33692/Service.svc/Http/");
            Console.WriteLine("Service help page is at: " + baseAddress.AbsoluteUri + "help");
            Console.WriteLine("");

            using (WebClient httpClient = new WebClient())
            {
                httpClient.BaseAddress = baseAddress.AbsoluteUri;
                httpClient.Headers[HttpRequestHeader.ContentType] = "application/xml";
                Console.WriteLine("Calling PutData with value 24");
                Console.WriteLine(httpClient.UploadString("PutData", "<int xmlns=\"http://schemas.microsoft.com/2003/10/Serialization/\">24</int>"));
                string xmlResponse = httpClient.DownloadString("GetData");
                using (StringReader stringReader = new StringReader(xmlResponse))
                {
                    using (XmlReader xmlReader = XmlReader.Create(stringReader))
                    {
                        string value = (string)new DataContractSerializer(typeof(string)).ReadObject(xmlReader);
                        Console.WriteLine("GetData returned: " + value);
                    }
                }
            }

            Console.WriteLine("");
            Console.WriteLine("Press any key to terminate");
            Console.ReadLine();
        }
开发者ID:tian1ll1,项目名称:WPF_Examples,代码行数:36,代码来源:Program.cs

示例9: LinkButtonTest_Click

        protected void LinkButtonTest_Click(object sender, EventArgs e)
        {
            var proxy = new ServiceClient();

            try
            {
                int num;

                if (!Int32.TryParse(TextBoxNum.Text, out num))
                {
                    LabelResult.Text = "Text cannot be converted to a number";
                }
                else
                {
                    LabelResult.Text = proxy.GetData(num);
                    proxy.Close();
                }
            }
            catch (Exception)
            {
                proxy.Abort();
                throw;
            }
        }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:24,代码来源:Default.aspx.cs


注:本文中的ServiceClient.GetData方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。