本文整理汇总了C#中ServiceClient.PutData方法的典型用法代码示例。如果您正苦于以下问题:C# ServiceClient.PutData方法的具体用法?C# ServiceClient.PutData怎么用?C# ServiceClient.PutData使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ServiceClient
的用法示例。
在下文中一共展示了ServiceClient.PutData方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}