It is not usual (and hardish!) to hand-roll your own reqest like this, normally you generate a proxy client via a tool.
You can probably (definately if you have the webservice project available to you) right click the
client project and add a Web Reference, then point the wizard at the service you want to consume, this generated the client.
Failing that you can run a tool called wsdl.exe against the service, assuming it has a wsdl exposed. There is some help
here[
^].
Once you have the client calling the web method is as simple as creating an instance of the generated proxy client, calling the method on the instance then closing the proxy.
This is the best article I could find :
consuming data web asmx service[
^], you just have to ignore the WPF stuff. The code for your example woul look like
using (FooServiceClient proxy = new FooServiceClient())
{
string result = proxy.GetMyName("sam");
}
Where
FooServiceClient
is the client generated.