Answered by:
Web service with Xml

Question
-
User1551896424 posted
Hi ,
I have to create web service which will take XML file as an parameter, process it and send XML file as an response.
Please Guide me as I am new to Web services.
What I tried Is,
WebService Function :
[WebMethod]
public System.Xml.XmlDocument Function_Name(System.Xml.XmlDocument RequestDoc)
{// Process RequestDoc here
// and created new XMl as follows
System.Xml.XmlDocument ResponseDoc = new System.Xml.XmlDocument();
// Geneted ResponseDoc file here
return ResponseDoc ;
}
WebService Call Function:
protected void Page_Load(object sender, EventArgs e)
{StringBuilder strXml = new StringBuilder();
strXml.Append("<Display>");
strXml.Append("<StoreCode>1234</StoreCode>");
strXml.Append("<TerminalID>02</TerminalID>");
strXml.Append("<TransDate>0123456789</TransDate>");
strXml.Append("<Vdtls>");
strXml.Append("<VID> VVD0000021</VID>");
strXml.Append("<VID> VVD0000022</VID>");
strXml.Append("<VID> BVD0003213</VID>");
strXml.Append("</Vdtls>");
strXml.Append("</Display>");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strXml.ToString());
WebService ServiceObj = new WebService();
System.Xml.XmlNode nd = ServiceObj.Function_Name(xmlDoc);}
On this above fucntion call geeting an Exception.
Please can any one help regarding this functionality in Web Services. IS it possible ?
Or please Guide to overcome this functionality.
Thanking U..
Thursday, May 23, 2013 8:24 AM
Answers
-
User-488622176 posted
what exception do you get?
For webservices it is better to use native system objects (string, int, double, bool, ...) or DTO's as input & output parameters, instead of complex objects such as XmlDocument.
Furthermore, I'm not seeing you use the function as a web service. Please read this in order to build & call the web service : http://msdn.microsoft.com/en-us/library/6h0yh8f9(v=vs.80).aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, May 29, 2013 7:24 AM
All replies
-
User-2001332922 posted
Web service is a add reference .dll in the main project then consumed as object like
webService1 ws=new webService1();
then ws.Function_name();
hint as you could go further
StringBuilder strXml = new StringBuilder();
strXml.Append("<Display>");
strXml.Append("<StoreCode>1234</StoreCode>");
strXml.Append("<TerminalID>02</TerminalID>");
strXml.Append("<TransDate>0123456789</TransDate>");
strXml.Append("<Vdtls>");
strXml.Append("<VID> VVD0000021</VID>");
strXml.Append("<VID> VVD0000022</VID>");
strXml.Append("<VID> BVD0003213</VID>");
strXml.Append("</Vdtls>");
strXml.Append("</Display>");
XmlDocument xmlDoc = new XmlDocument();
xmlDoc.LoadXml(strXml.ToString());
WebService ServiceObj = new WebService();
System.Xml.XmlNode nd = ServiceObj.Function_Name(xmlDoc);
remove and try the snippet as guided. also please come with either data or information one you consider is enough
Thursday, May 23, 2013 10:14 AM -
User1551896424 posted
Here I am upto what u guid. Geeting successfull call to a function of service.
I need an example to pass an XML file to service and there parse it and again send response in as XML Document.
Thank You..
Friday, May 24, 2013 1:57 AM -
User-2001332922 posted
Here I am upto what u guid. Geeting successfull call to a function of service.congratulation.
I need an example to pass an XML file to service and there parse it and again send response in as XML Document.May you find relevant to your requirement refer
http://forums.asp.net/t/1755909.aspx/1?can+a+web+service+return+an+html+formatted+file
Also try to access the web serivce at computer browser so that you get to know that the code is working. web service output is XML
you may need to read: WSDL and related document
Friday, May 24, 2013 9:04 AM -
User-488622176 posted
what exception do you get?
For webservices it is better to use native system objects (string, int, double, bool, ...) or DTO's as input & output parameters, instead of complex objects such as XmlDocument.
Furthermore, I'm not seeing you use the function as a web service. Please read this in order to build & call the web service : http://msdn.microsoft.com/en-us/library/6h0yh8f9(v=vs.80).aspx
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Wednesday, May 29, 2013 7:24 AM