Click here to Skip to main content
16,005,316 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want to pass a string value as parameter in an XmlDocument using asp.net with c#. I am calling a web service dynamically and passing a request Xml as parameter(strReqXml) . strReqXml variable will contain Request Xml as string.

My code is as below:
string strReqXml = BuildReqXML(dt, ref UniqueRefno);


               XmlDocument soapEnvelopeXml = new XmlDocument();

               soapEnvelopeXml.LoadXml(@"<?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>
                       <ShipmentResponse  xmlns=""http://tempuri.org/"">
                       <parameter1>
                        tEST
                      </parameter1>
                       </ShipmentResponse>
                       </soap:Body>
                       </soap:Envelope>");


What I have tried:

string strReqXml = BuildReqXML(dt, ref UniqueRefno);


               XmlDocument soapEnvelopeXml = new XmlDocument();

               soapEnvelopeXml.LoadXml(@"<?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>
                       <ShipmentResponse  xmlns=""http://tempuri.org/"">
                       <parameter1>
                        tEST
                      </parameter1>
                       </ShipmentResponse>
                       </soap:Body>
                       </soap:Envelope>");
Posted
Updated 5-Oct-17 23:33pm

1 solution

Space before "xmlns" is missing if you fix that, it should work. Can you try..??

doc.LoadXml(@"<?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>
                        <ShipmentResponse  xmlns=""http://tempuri.org/"">
                        <parameter1>
                         tEST
                       </parameter1>
                        </ShipmentResponse>
                        </soap:Body>
                        </soap:Envelope>");
 
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