Answered by:
Webservices to send and Receive XML data.

Question
-
User49773934 posted
Hi,
I'm looking for examples to send and receive XML data using web services. Can someone please post relavant links or references for the above topic?
Thanks
Vidas
Friday, June 26, 2009 4:37 PM
Answers
-
User214117797 posted
Are you using WCF or pre .NET 2.0 asmx web services?
Here are some links for web services, some with WCF and others with ASMX
http://www.codeproject.com/KB/WCF/WCFWebService.aspx
http://weblogs.asp.net/dwahlin/archive/2007/02/03/video-creating-a-service-with-windows-communication-service-wcf.aspx
http://www.aspfree.com/c/a/ASP.NET/Developing-a-WCF-Service-Library-and-Hosting-it-as-WCF-Web-Service-Using-VS2K8/
http://msdn.microsoft.com/en-us/library/ms731082.aspx
ASMX
http://msdn.microsoft.com/en-us/library/ms972326.aspx
http://www.codeguru.com/csharp/csharp/cs_webservices/tutorials/article.php/c5477
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 26, 2009 5:44 PM -
User1071970124 posted
Just use a parameter of type XmlElement to receive arbitrary XML, or return XmlElement to return arbitrary XML.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 26, 2009 8:38 PM
All replies
-
User214117797 posted
Are you using WCF or pre .NET 2.0 asmx web services?
Here are some links for web services, some with WCF and others with ASMX
http://www.codeproject.com/KB/WCF/WCFWebService.aspx
http://weblogs.asp.net/dwahlin/archive/2007/02/03/video-creating-a-service-with-windows-communication-service-wcf.aspx
http://www.aspfree.com/c/a/ASP.NET/Developing-a-WCF-Service-Library-and-Hosting-it-as-WCF-Web-Service-Using-VS2K8/
http://msdn.microsoft.com/en-us/library/ms731082.aspx
ASMX
http://msdn.microsoft.com/en-us/library/ms972326.aspx
http://www.codeguru.com/csharp/csharp/cs_webservices/tutorials/article.php/c5477
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 26, 2009 5:44 PM -
User49773934 posted
Thanks Jimmy,
But, here I can see regular webservice examples. Can you please post if you know how to send and receive XML data/files using webservices in .Net 2.0?
Thanks
Vidas
Friday, June 26, 2009 6:07 PM -
User1071970124 posted
Just use a parameter of type XmlElement to receive arbitrary XML, or return XmlElement to return arbitrary XML.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Friday, June 26, 2009 8:38 PM -
User-455811767 posted
Hi try the following Code
Please write following Code in Service.asmx page.....
public static string GetXmlString(string strFile)
{
// Load the xml file into XmlDocument object.
XmlDocument xmlDoc = new XmlDocument();
try
{
xmlDoc.Load(strFile);
}
catch (XmlException e)
{
}
// Now create StringWriter object to get data from xml document.
StringWriter sw = new StringWriter();
XmlTextWriter xw = new XmlTextWriter(sw);
xmlDoc.WriteTo(xw);
return sw.ToString();
}
Add Webreference to your Aspx Page..
then write following code in Aspx Page and Call the method here
first create object for the Service class;
protected void Page_Load(object sender, EventArgs e)
{
Service1 ser=new service1();
string XmlData = GetXmlString(Server.MapPath("Capabilities.xml"));
DisplayXmlData(XmlData);
}public void DisplayXmlData(string s) //convert String into Xml File.
{
XmlDocument getxmlfromstring = new XmlDocument();
Response.ContentType = "text/xml";
getxmlfromstring.LoadXml(s);
getxmlfromstring.Save(MapPath("EmployeesNew.xml"));
FileInfo file = new FileInfo(Server.MapPath("EmployeesNew.xml")); // full file path on disk
Response.ClearContent(); // neded to clear previous (if any) written content
Response.AddHeader("Content-Disposition", "attachment; filename=" + file.Name);
Response.AddHeader("Content-Length", file.Length.ToString());
Response.ContentType = "text/xml"; //RFC 3023
//Response.TransmitFile(file.FullName);
Response.WriteFile(file.FullName);
Response.End();
}
you can Send Xml files like this..
Hope It Will Helpful .....
Monday, August 10, 2009 6:07 AM -
User1071970124 posted
This code is very bad, and demonstrates a lack of understanding of XML.
XML should never be treated as a string!
Monday, August 10, 2009 1:35 PM