I've created webservice using by code:
[WebMethod(Descr iption = "Echo Soap Request")]
public XmlDocument EchoSoapRequest (string input)
{
// Initialize soap request XML
XmlDocument xmlSoapRequest = new XmlDocument();
// Get raw request body
Stream receiveStream = HttpContext.Cur rent.Request.In putStream;
// Move to begining of input stream and read
receiveStream.P osition = 0;
System.Text.Enc oding encoding = System.Text.Enc oding.Unicode;
//BinaryWriter bw = new BinaryWriter(re ceiveStream, encoding);
using (StreamReader readStream = new StreamReader(re ceiveStream,Enc oding.UTF8))
{
// Load into XML documen
xmlSoapRequest. Load(readStream );
//xmlSoapRequest. Load(Configurat ionManager.AppS ettings["CatalogXMlRoot Path"] + readStream + ".xml");
}
// Return
return xmlSoapRequest;
}
}
But I got following error,if you have any error give me suggestion:
System.Xml.XmlE xception: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlT extReaderImpl.T hrow(Exception e)
at System.Xml.XmlT extReaderImpl.T hrow(String res, String arg)
at System.Xml.XmlT extReaderImpl.P arseRootLevelWh itespace()
at System.Xml.XmlT extReaderImpl.P arseDocumentCon tent()
at System.Xml.XmlT extReaderImpl.R ead()
at System.Xml.XmlL oader.Load(XmlD ocument doc, XmlReader reader, Boolean preserveWhitesp ace)
at System.Xml.XmlD ocument.Load(Xm lReader reader)
at System.Xml.XmlD ocument.Load(Te xtReader txtReader)
at GettingLists.ls ts.EchoSoapRequ est(String input) in E:\Practice\Sha repoint\Getting Lists\GettingLi sts\lsts.asmx.c s:line
[WebMethod(Descr iption = "Echo Soap Request")]
public XmlDocument EchoSoapRequest (string input)
{
// Initialize soap request XML
XmlDocument xmlSoapRequest = new XmlDocument();
// Get raw request body
Stream receiveStream = HttpContext.Cur rent.Request.In putStream;
// Move to begining of input stream and read
receiveStream.P osition = 0;
System.Text.Enc oding encoding = System.Text.Enc oding.Unicode;
//BinaryWriter bw = new BinaryWriter(re ceiveStream, encoding);
using (StreamReader readStream = new StreamReader(re ceiveStream,Enc oding.UTF8))
{
// Load into XML documen
xmlSoapRequest. Load(readStream );
//xmlSoapRequest. Load(Configurat ionManager.AppS ettings["CatalogXMlRoot Path"] + readStream + ".xml");
}
// Return
return xmlSoapRequest;
}
}
But I got following error,if you have any error give me suggestion:
System.Xml.XmlE xception: Data at the root level is invalid. Line 1, position 1.
at System.Xml.XmlT extReaderImpl.T hrow(Exception e)
at System.Xml.XmlT extReaderImpl.T hrow(String res, String arg)
at System.Xml.XmlT extReaderImpl.P arseRootLevelWh itespace()
at System.Xml.XmlT extReaderImpl.P arseDocumentCon tent()
at System.Xml.XmlT extReaderImpl.R ead()
at System.Xml.XmlL oader.Load(XmlD ocument doc, XmlReader reader, Boolean preserveWhitesp ace)
at System.Xml.XmlD ocument.Load(Xm lReader reader)
at System.Xml.XmlD ocument.Load(Te xtReader txtReader)
at GettingLists.ls ts.EchoSoapRequ est(String input) in E:\Practice\Sha repoint\Getting Lists\GettingLi sts\lsts.asmx.c s:line