RadhikaChandra
New member
- Joined
- Apr 25, 2018
- Messages
- 4
- Programming Experience
- 1-3
I want to create a web service method which will taken xml string as input parameter and when I run the webservice I pass the xml string . The webmethod should store the xml string in a file. How can I do in C# using visual studio. please help
for example when I run the below code it works as I have my xml string in the code,
[WebMethod]
public string savexml( )
strConnectionString = new SqlConnection(constring);
try
{
strConnectionString.Open();
XmlDocument doc = new XmlDocument();
doc.LoadXml("<customer><cust> asdadsa </cust></customer>");
using (XmlTextWriter writer = new XmlTextWriter(@"Q:\data1.xml", null))
{
writer.Formatting = Formatting.Indented;
doc.PreserveWhitespace = true;
doc.Save(@"Q:\data1.xml");
}
strConnectionString.Close();
return "file created";
}
but if have to pass the string as parameter as below
public string savexml(string xmlstr )
and change the line in the above code as
doc.LoadXml("xmlstr");
it does not work
What to do?????
for example when I run the below code it works as I have my xml string in the code,
[WebMethod]
public string savexml( )
strConnectionString = new SqlConnection(constring);
try
{
strConnectionString.Open();
XmlDocument doc = new XmlDocument();
doc.LoadXml("<customer><cust> asdadsa </cust></customer>");
using (XmlTextWriter writer = new XmlTextWriter(@"Q:\data1.xml", null))
{
writer.Formatting = Formatting.Indented;
doc.PreserveWhitespace = true;
doc.Save(@"Q:\data1.xml");
}
strConnectionString.Close();
return "file created";
}
but if have to pass the string as parameter as below
public string savexml(string xmlstr )
and change the line in the above code as
doc.LoadXml("xmlstr");
it does not work
What to do?????