Why is the return value not XmlDocument ?

S

Shailendra Batham

hi gurus

I have a asp.net web services and in that i have a function which returns XmlDocument as the return value, when I test the service it works fine and I can see the XML.

When I try to call the XML from asp.net, it does not return XmlDocument and gives me this message

Cannot implicitly convert type 'System.Xml.XmlNode' to 'System.Xml.XmlDocument'

This is my code
XmlDocument xd = new XmlDocument();
xd = sdws.CreateSurvey(ValidXMLFile);

Am I missing something ?

thanks,
shailendra batham
 
S

Scott M.

We need to see the code that defines what "sdws.CreateSurvey(ValidXMLFile) is.

The error message indicates that you are trying to use an XML node (a piece of an XML document) in a place where an actual XMLDocument is required.
hi gurus

I have a asp.net web services and in that i have a function which returns XmlDocument as the return value, when I test the service it works fine and I can see the XML.

When I try to call the XML from asp.net, it does not return XmlDocument and gives me this message

Cannot implicitly convert type 'System.Xml.XmlNode' to 'System.Xml.XmlDocument'

This is my code
XmlDocument xd = new XmlDocument();
xd = sdws.CreateSurvey(ValidXMLFile);

Am I missing something ?

thanks,
shailendra batham
 
O

Oleg Tkachenko [MVP]

Shailendra said:
XmlDocument xd = new XmlDocument();
xd = sdws.CreateSurvey(ValidXMLFile);

XmlDocument implements XmlNode, which is abstract class. If
CreateSurvey() method does return XmlDocument, but as XmlNode, you nedd
only to cast it explicitly:

XmlDocument xd = (XmlDocument)sdws.CreateSurvey(ValidXMLFile);
 
D

Dan Rogers

Change your code to expect an XmlNode. On the service you may be returning
an XML document, but over the wire and thru the woods, it comes out on the
automatic proxy as an XmlNode. No loss... it was a partial document to the
client, and a full document to the service.

Hope that helps,

Dan Rogers
Microsoft Corporation
--------------------
From: "Shailendra Batham" <[email protected]>
Subject: Why is the return value not XmlDocument ?
Date: Tue, 19 Oct 2004 16:44:06 -0700
Lines: 70
MIME-Version: 1.0
Content-Type: multipart/alternative;
boundary="----=_NextPart_000_0006_01C4B5FA.D976F5C0"
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
Message-ID: <[email protected]>
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices,microsoft.public.dotnet
.framework.webservices,microsoft.public.dotnet.xml,microsoft.public.webservi
ces
NNTP-Posting-Host: mail.sitesystems.com 206.135.37.4
Path: cpmsftngxa10.phx.gbl!TK2MSFTFEED01.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP09
.phx.gbl
Xref: cpmsftngxa10.phx.gbl
microsoft.public.dotnet.framework.webservices:7056
microsoft.public.dotnet.xml:23632 microsoft.public.webservices:2472
microsoft.public.dotnet.framework.aspnet.webservices:26176
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

hi gurus
I have a asp.net web services and in that i have a function which returns
XmlDocument as the return value, when I test the service it works fine and
I can see the XML.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,230
Members
46,818
Latest member
Brigette36

Latest Threads

Top