本文整理汇总了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();
}
}
}
}
示例2: Wrong
private void Wrong()
{
string data;
using (var client = new ServiceClient().GetProxy())
{
data = client.GetData(int.Parse(txtData.Text));
}
ltlData.Text = data;
}
示例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);
}
示例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);
}
}
示例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;
}
}
示例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;
}
示例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;
}
}
}
示例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();
}
示例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;
}
}