Mani Pazhana
asked on
Passing XMLdocument to webservice method
Hello expert,
I have a webservice created using asp.net/C#. The method in the webservice takes one input parameter as type object.
From my asp.net web application , i am calling the web service and passing a XML document to the webmethod.
It is throwing a error.
Here is my web service code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls. WebParts;
using System.Web.UI.HtmlControls ;
using System.Xml;
namespace PCWebApplication
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
PCWebService.Service1 PCWS = new PCWebService.Service1();
XmlDocument doc = new XmlDocument();
doc.Load("C:\\Temp\\Test.x ml");
/// Call to web service:
object result;
result= (object) PCWS.ProcessXMLFile(doc);
Response.Write((string) result);
}
}
}
-------------------------- ---------- ---------- -----
Here is my calling code from asp.net web application:
protected void Page_Load(object sender, EventArgs e)
{
PCWebService.Service1 PCWS = new PCWebService.Service1();
XmlDocument doc = new XmlDocument();
doc.Load("C:\\Temp\\Test.x ml");
/// Call to web service:
object result;
result= (object) PCWS.ProcessXMLFile(doc);
Response.Write((string) result);
}
-------------------------- ---------- ---------- ---------- ----
Error Message: The type System.Xml.XmlDocument may not be used in this context.
any help?
I have a webservice created using asp.net/C#. The method in the webservice takes one input parameter as type object.
From my asp.net web application , i am calling the web service and passing a XML document to the webmethod.
It is throwing a error.
Here is my web service code:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.
using System.Web.UI.HtmlControls
using System.Xml;
namespace PCWebApplication
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
PCWebService.Service1 PCWS = new PCWebService.Service1();
XmlDocument doc = new XmlDocument();
doc.Load("C:\\Temp\\Test.x
/// Call to web service:
object result;
result= (object) PCWS.ProcessXMLFile(doc);
Response.Write((string) result);
}
}
}
--------------------------
Here is my calling code from asp.net web application:
protected void Page_Load(object sender, EventArgs e)
{
PCWebService.Service1 PCWS = new PCWebService.Service1();
XmlDocument doc = new XmlDocument();
doc.Load("C:\\Temp\\Test.x
/// Call to web service:
object result;
result= (object) PCWS.ProcessXMLFile(doc);
Response.Write((string) result);
}
--------------------------
Error Message: The type System.Xml.XmlDocument may not be used in this context.
any help?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks
ASKER
When you pass XML as string, is there a size limitation, if yes how much is the limit?
I don't think so. The only limitation would be the total max length. Currently the default max length is 4K. If you want to increase that amount you need to include a HTTPRuntime element in your web config:
http://msdn.microsoft.com/en-us/library/e1f13641%28VS.71%29.aspx
http://msdn.microsoft.com/en-us/library/e1f13641%28VS.71%29.aspx
ASKER
using System;
using System.Data;
using System.Web;
using System.Collections;
using System.Web.Services;
using System.Web.Services.Protoc
using System.ComponentModel;
using System.Xml;
using System.Text;
namespace PCWebService
{
/// <summary>
/// Summary description for Service1
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(Conform
[ToolboxItem(false)]
public class Service1 : System.Web.Services.WebSer
{
[WebMethod]
public string HelloWorld()
{
return "Hello World";
}
[WebMethod]
public string ProcessXMLFile(object doc)
{
/// process doc as a local variable
///
// Get the root node so we can explore its children
XmlDocument newxml = new XmlDocument();
newxml = (XmlDocument) doc;
string stroutput = newxml.DocumentElement.Fir
// Store all the values of the elements in a string
//string allMyChildren = nodRoot.InnerText;
return stroutput;
}
}
}