473,796 Members | 2,483 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

WebMethod returning an XmlDocument generating a compile error in the client.

I have a WebMethod as follows:

[WebMethod]
public XmlDocument OrderContract(X mlDocument doc)
{
return OrderBLL.OrderC ontract(doc);
}

However, the client is generating a compile error when the following lines
are used:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlDocument retxml = txn.OrderContra ctCert(xml);

However, this compiles clean:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlNode retxml = txn.OrderContra ctCert(xml);

I have no idea why the client is expecting an XmlNode.
Jun 21 '06 #1
8 2829


Thirsty Traveler wrote:

However, the client is generating a compile error when the following lines
are used:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlDocument retxml = txn.OrderContra ctCert(xml);

However, this compiles clean:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlNode retxml = txn.OrderContra ctCert(xml);

I have no idea why the client is expecting an XmlNode.


Does it work if you cast the result? E.g.
XmlDocument retxml = txn.OrderContra ctCert(xml) as XmlDocument;
if (retxml != null) {
// now use retxml here
}

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 21 '06 #2
IIRC the cast won't work; it returns a node, not a document.

If you need a document reference, then create a new XmlDocument and
call ImportNode on it to clone that node into the new document.
Alternatively, see what OwnerDocument (on the XmlNode) says.

Marc

Jun 21 '06 #3
I am still unclear on why it is returning a node rather than a document when
the webmethod specifies XmlDocument as the return type.

"Marc Gravell" <ma**********@g mail.com> wrote in message
news:11******** **************@ c74g2000cwc.goo glegroups.com.. .
IIRC the cast won't work; it returns a node, not a document.

If you need a document reference, then create a new XmlDocument and
call ImportNode on it to clone that node into the new document.
Alternatively, see what OwnerDocument (on the XmlNode) says.

Marc

Jun 21 '06 #4


Marc Gravell wrote:
IIRC the cast won't work; it returns a node, not a document.
XmlNode is an astract class, somehow an instance of a derived class
needs to be returned, and XmlDocument is a derived class. But you are
right that the cast to XmlDocument does not work, a test here shows that
NodeType gives Element node so you could cast to XmlElement but not
XmlDocument.
Alternatively, see what OwnerDocument (on the XmlNode) says.


The OwnerDocument of the node returned is an XmlDocument instance but in
my test here (with .NET 1.1) does not even contain the node returned.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 21 '06 #5


Thirsty Traveler wrote:
I am still unclear on why it is returning a node rather than a document when
the webmethod specifies XmlDocument as the return type.


Web services communicate using SOAP and it seems any XmlNode sub type is
simply serialized in the SOAP message so it is kind of hard to decide on
the client side what concrete type the XmlNode had.

--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 21 '06 #6
Try this:
OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlDocument retxml = (XmlDocument) txn.OrderContra ctCert(xml);

Does it work for you?

chanmm

"Thirsty Traveler" <nf*@nospam.com > wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
I have a WebMethod as follows:

[WebMethod]
public XmlDocument OrderContract(X mlDocument doc)
{
return OrderBLL.OrderC ontract(doc);
}

However, the client is generating a compile error when the following lines
are used:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlDocument retxml = txn.OrderContra ctCert(xml);

However, this compiles clean:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlNode retxml = txn.OrderContra ctCert(xml);

I have no idea why the client is expecting an XmlNode.

Jun 22 '06 #7
Unfortunately, that is one of the first things I tried and it did not work.

"chanmm" <ch*****@hotmai l.com> wrote in message
news:uq******** ******@TK2MSFTN GP02.phx.gbl...
Try this:
OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlDocument retxml = (XmlDocument) txn.OrderContra ctCert(xml);

Does it work for you?

chanmm

"Thirsty Traveler" <nf*@nospam.com > wrote in message
news:%2******** ********@TK2MSF TNGP04.phx.gbl. ..
I have a WebMethod as follows:

[WebMethod]
public XmlDocument OrderContract(X mlDocument doc)
{
return OrderBLL.OrderC ontract(doc);
}

However, the client is generating a compile error when the following
lines are used:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlDocument retxml = txn.OrderContra ctCert(xml);

However, this compiles clean:

OrderWS.Contrac tServices txn = new OrderWS.Contrac tServices ();
XmlNode retxml = txn.OrderContra ctCert(xml);

I have no idea why the client is expecting an XmlNode.


Jun 22 '06 #8


Thirsty Traveler wrote:
Unfortunately, that is one of the first things I tried and it did not work.


It seems (at least with .NET 1.1 from tests) that you get an XmlElement
instead of an XmlDocument so you could use e.g.
XmlNode retxml = txn.OrderContra ctCert(xml);
XmlDocument doc = retxml.OwnerDoc ument;
doc.AppendChild (retxml);
and then you can use doc as an XmlDocument.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Jun 22 '06 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
420
by: Lars Moastuen | last post by:
I'm currently writing a webservice. I've successfully written a service that gives me some XML data, but now I want to link a XLS-stylesheet to that data. The way I'm trying to do that is to create a webmethod that returns a XmlDataDocument, and use CreateProcessingInstruction() to add a "stylesheet-header"... Problem is that the headers I add using CreateProcessingInstruction() seems to be removed (?) when the data is transferred over the...
3
2663
by: sd | last post by:
Hello All, I aplogize if this has already been answered however I couldn't find anything related to this... I have bunch of webservices written in vb.net returning native data types, due to constraints of the client I need to return data that has been output escaped i.e. when a string response is returned back by the service it automatically converts & to amp; and the other reserved chracters, in this case I don't want the conversion to
7
4905
by: SQLScott | last post by:
I have a Web Service in which I am trying to pass an XMLDocument as a parameter to one of the methods. I would like to use the XMLTextReader to read the XML but I am getting the following error: Value of type System.xml.xmldocument cannot be converted to System.IO.textreader. I would think this is possible to do. Code snippet is below:
2
2845
by: Peter McEvoy | last post by:
Folks, I've been building a Webservice API for a contract that will be exposed to the internet at large. There are two endpoints, and each endpoint contains a number of webmethods. Every webmethod returns a returncode which indicates the level of success in performing the operation (as well as the actual results of the call in an "out" parameter) They have a requirement that when they want to perform maintenance on the backend system,...
4
4652
by: MattBell | last post by:
I've tried to search for an answer to this without much success, and I think it's probably a common thing to do: I have a web service I want to accept an XmlDocument as an argument which conforms to a specific XSD that is defined. Right now when I declare XmlDocument as my argument, it puts the old xml:any type in. How do I change that to reflect the XSD that I'm looking for? Thanks for any Help!
6
12494
by: rlcavebmg | last post by:
I am new to Web Services and .NET development, and I have a question. I am writing a service that will create a bitmap image and return it to the client. First, I wrote a method that looked like this: public System.Drawing.Bitmap CreateImage() {...} When I tried to create the web reference in my client program, I got an error message stating that the System.Drawing.Bitmap object could not be serialized because it does not have a...
5
3454
by: Ray Stevens | last post by:
I have a C# dataclass object that I would like to pass to a Web Service WebMethod, modify some strings, and return it to the caller but I am getting compiler errors in the client. I'm not an expert on Web Services and am wondering if what I am attempting is even doable? Even this simple test generates the error: From the Web Service:
2
13597
by: John Smith | last post by:
I'm writing webervice client using .Net 2.0. I have this class: public class MyWebService : SoapHttpClientProtocol { public XmlDocument validate(string url, XmlDocument xmlDocument) { this.Url = url;
3
2970
by: Khurram | last post by:
Hi, Firstly, I will apologise now if I have posted in the wrong discussion group. Please let me know if I have for future reference. Below is the code to a WebMethod that is querying an Access 2003 database, saving the results as a dataset and returning the dataset. public DataSet findAAPAssessment(string assessmentID) {
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10455
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10173
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7547
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6788
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5441
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4116
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3731
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.