I have a web service with method and console application where I used the web service
[WebMethod]
public Foo HelloWorld(Foo foo)
{
    Foo foo2 = new Foo();
    foo2.Id = 10;
    foo2.Name = "roman";
    return foo2;
}
and application where I used this web method:
using (WebClient client = new WebClient())
{
    {
        //how to replace this block on a short line likes Foo result = webService.WebMethod(params)
        client.Headers.Add("SOAPAction","\"http://tempuri.org/HelloWorld\"");
        client.Headers.Add("Content-Type", "text/xml; charset=utf-8");
        string payload = @"<?xml version=""1.0"" encoding=""utf-8""?>
                           <soap:Envelope xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" 
                                          xmlns:xsd=""http://www.w3.org/2001/XMLSchema""
                                          xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">
                               <soap:Body>
                                   <HelloWorld xmlns=""http://tempuri.org/"">
                                       <foo>
                                           <Id>10</Id>
                                           <Name>23</Name>
                                       </foo>
                                   </HelloWorld>
                               </soap:Body>
                           </soap:Envelope>";
        var data = Encoding.UTF8.GetBytes(payload);
        var result = client.UploadData("http://localhost:22123/Service1.asmx", data);
        Console.WriteLine(Encoding.Default.GetString(result));
    }
}
The result is:
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <HelloWorldResponse xmlns="http://tempuri.org/">
            <HelloWorldResult>
                <Id>10</Id>
                <Name>roman</Name>
            </HelloWorldResult>
        </HelloWorldResponse>
    </soap:Body>
</soap:Envelope>
My problems:
- how to replace a lot of code lines on a small line?
- how to deserialize webResultby using Linq to XML or there is other way to do it?
 
     
    