Click here to Skip to main content
15,896,111 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created one method Helloworld in Webservice.

C#
public string HelloWorld1()
       {
           return "Hello World testing.....";
       }

Now i want to call that method using webclient ..here i written some code..how i can call that method Here..i written client object

static void Main(string[] args)
{
WebClient client = new WebClient();
string request1 = "<soap:envelope\r\n>\r\n <soap:body xmlns:soap="#unknown"><helloworld1 xmlns="\" http:="" tempuri.org="" \""="">";
client.Headers.Add(HttpRequestHeader.ContentType, "text/xml");

client.Headers.Add("SOAPAction", "http://tempuri.org/HelloWorld1");

client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);

client.UploadStringAsync(new Uri("http://localhost:50377/Service1.asmx"),request1);

Console.WriteLine("Called UploadStringAsync");

Console.WriteLine("Press ENTER to close program");

Console.ReadLine();

}

static void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
{
Console.WriteLine("UploadStringCompleted: {0}", e.Result);
}
Posted
Updated 25-Sep-13 23:35pm
v4
Comments
♥…ЯҠ…♥ 26-Sep-13 5:19am    
Re paste the client code, it looks like junk
Member 10205754 26-Sep-13 5:26am    
ok

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900