Click here to Skip to main content
15,896,153 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Here am getting solution
XML
UploadStringCompleted: <?xml version="1.0" encoding="utf-8"?><soap:Envelope xmln
s: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>Hello Karthik
 mushyam</HelloWorldResult></HelloWorldResponse></soap:Body></soap:Envelope>


How can i get only Hello karthik as output from the called method
C#
static void Main(string[] args)
       {
           WebClient client = new WebClient();
           string request1 = "<soap:Envelope\r\n  xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'\r\n  xmlns:xsd='http://www.w3.org/2001/XMLSchema'\r\n  xmlns:soap='http://schemas.xmlsoap.org/soap/envelope/'>\r\n <soap:Body><HelloWorld xmlns=\"http://tempuri.org/\"><name>Karthik mushyam</name></HelloWorld></soap:Body></soap:Envelope>";
           client.Headers.Add(HttpRequestHeader.ContentType, "text/xml");
           client.Headers.Add("SOAPAction", "http://tempuri.org/HelloWorld");
           client.UploadStringCompleted += new UploadStringCompletedEventHandler(client_UploadStringCompleted);
           client.UploadStringAsync(new Uri("http://localhost:52375/MyFirstWebService/Service.asmx"), request1);
           Console.ReadLine();
       }
       static void client_UploadStringCompleted(object sender, UploadStringCompletedEventArgs e)
       {
           Console.WriteLine("UploadStringCompleted: {0}", e.Result);
       }
Posted
Updated 25-Sep-13 23:56pm
v2

1 solution

As the result is in XML, so parse it and find the HelloWorldResult node value.

Refer - Parsing XML in C#[^] for one example.
 
Share this answer
 
Comments
karthik mushyam 26-Sep-13 6:20am    
I dont have seperate xml file ,how can i load xml file in my program
Okay then use XmlDocument.LoadXml Method[^].

XmlDocument doc = new XmlDocument();
doc.LoadXml(yourStringResult);

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