Click here to Skip to main content
15,893,588 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
var client = new RestClient("URL");
        client.Timeout = -1;
        var request = new RestRequest(Method.POST);

        request.AddHeader("Authorization", "Basic Info");
        request.AddHeader("Cookie", "cookie info");
        var body = @"<soapenv:Envelope xmlns:soapenv=""URL"" xmlns:ws=""URL"">
                    <soapenv:Header/>            
                       <soapenv:Body>            
                           <ws:getOrdersRequest>            
                               <ws:numOrders>20</ws:numOrders>            
                            </ws:getOrdersRequest>            
                       </soapenv:Body>            
                    </soapenv:Envelope>";
        request.AddParameter("", body, ParameterType.RequestBody);
        IRestResponse response = client.Execute(request);

        if (response.StatusCode == HttpStatusCode.OK)
        {
            lblInfo.Text = response.Content;
            Response.Write(response.Content);
        }
        else
        {
            lblInfo.Text = (string.Format("{0}({1})", response.StatusDescription, 
            response.StatusCode));
        }


What I have tried:

I need to read the nodes, but the code takes the nodes out and displays all in string format.
Posted
Updated 27-Jul-22 8:43am
Comments
PIEBALDconsult 27-Jul-22 13:41pm    
Seems unlikely, maybe see what's what in the debugger?

1 solution

Hi

One option is that you can use XDocument class for reading nodes in the string.
Parse the string to XDocument, and use linq to xml. An example is shown below

string xmlstr = @"<?xml version='1.0'?><Products>
                                                    <Product>
                                                        <Name>Jeans</Name>
                                                        <Price>41.99</Price>
                                                    </Product>
                                                    <Product>
                                                        <Name>Socks</Name>
                                                        <Price>5.99</Price>
                                                    </Product>
                                                    <Product>
                                                        <Name>Shoes</Name>
                                                        <Price>62.49</Price>
                                                    </Product>
                                                </Products>";

            XDocument xmldoc = XDocument.Parse(xmlstr);

            var products = (from p in xmldoc.Descendants("Product")
                           select new
                           {
                               Name = p.Element("Name").Value,
                               Price = p.Element("Price").Value
                           }).ToList();


Hope this helps
 
Share this answer
 

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