I have a web service method that returns an XMLDocument. The signature is:
public XmlDocument GetPOs()
The following client code calls this method but it accepts an XMLNode
instead of an XMLDocument and my first question is why does this work?
XmlNode neNode;
neNode = myHFCService.Ge tPOs();
DataSet myds = new DataSet();
byte[] buf =
System.Text.ASC IIEncoding.ASCI I.GetBytes(neNo de.OuterXml);
System.IO.Memor yStream ms = new System.IO.Memor yStream(buf);
myds.ReadXml(ms );
gvOrders.DataSo urce = myds.Tables[0];
Secondly, why does the following client code get a type mismatch?
XmlDocument myXMLDoc = new XmlDocument();
myXMLDoc = myHFCService.Ge tPOs();
The service is returning a type of XMLDocument but it comes back as XMLNode.
Those are different types.
Thanks,
Gary 5 3882
GaryDean wrote:
I have a web service method that returns an XMLDocument. The signature is:
public XmlDocument GetPOs()
The following client code calls this method but it accepts an XMLNode
instead of an XMLDocument and my first question is why does this work?
XmlNode neNode;
neNode = myHFCService.Ge tPOs();
DataSet myds = new DataSet();
byte[] buf =
System.Text.ASC IIEncoding.ASCI I.GetBytes(neNo de.OuterXml);
System.IO.Memor yStream ms = new System.IO.Memor yStream(buf);
myds.ReadXml(ms );
gvOrders.DataSo urce = myds.Tables[0];
Secondly, why does the following client code get a type mismatch?
XmlDocument myXMLDoc = new XmlDocument();
myXMLDoc = myHFCService.Ge tPOs();
XmlNode is the base class for all those specialized classes like
XmlElement or XmlDocument. When you get a piece of XML markup in the
SOAP response I think it is difficult to distinguish whether e.g
<element>conten t</element>
is the result of serializing an XmlDocument instance or an XmlElement
instance so you get an XmlNode as the common subclass.
--
Martin Honnen --- MVP XML http://JavaScript.FAQTs.com/
Hi Gary,
Thanks for Martin's reply.
Yes, as Martin said.
XmlDocument is derived from XmlNode. When XmlDocument objects are passed as
parameters to Web Service methods, or are returned from Web Service
methods, they are marshaled as XmlNode objects. This behavior is by design.
We suggest you may use XmlDocument API to load data from XMLNode.
For example:
XmlDocument myXMLDoc = new XmlDocument();
myXMLDoc.LoadXm l(myHFCService. GetPOs().OuterX ml);
For more information, you can reference the following KB. http://support.microsoft.com/kb/330600/en-us
Please feel free to let me know if there is anything unclear. I'm glad to
assist you.
Hope this helps.
Sincerely,
Wen Yuan
Hi Gary,
I just want to check whether your issue has been resolved.
Please feel free to update here if it still persists. I'm glad to assist
you.
Have a great day,
Sincerely,
Wen Yuan
Wen Yuan,
sorry for so long to get back to you but I got busy on something else...
Yes your response and the associate docs explain this behavior.
thanks very much for the help!
--
Regards,
Gary Blakely
""WenYuan Wang"" <v-******@online.m icrosoft.comwro te in message
news:5l******** ******@TK2MSFTN GHUB02.phx.gbl. ..
Hi Gary,
I just want to check whether your issue has been resolved.
Please feel free to update here if it still persists. I'm glad to assist
you.
Have a great day,
Sincerely,
Wen Yuan
Hi Gary,
Thanks for your response.
I'm glad to assist you.:)
Have a great day,
Sincerely,
Wen Yuan This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Ian Williamson |
last post by:
Greetings,
I have seen this question posted a few times, but the
answers have not helped me.
I have used the program xsd.exe to generate several c#
classes from a client provided xsd template. I now wish
take a sizeable amount of data and create an xml file
based on these classes. My intent is to use xmldocument
to build up the xml and then stream it to a file. My
|
by: Mahesh Devjibhai Dhola |
last post by:
Hi All,
I want to make a custom class in c#, which extends System.Xml.XmlNode class
of BCL.
Now in custom class, I have implement abstract methods of XmlNode class
also. Now when I am trying to run the class it gives an error that
"System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level".
This error comes because XmlNode has not any public constructor. I found
XmlNode has two constructor but both are private or friend...
|
by: Siu |
last post by:
Hi,
I've loaded an XmlDocument from a file XML: this file has many similar
XmlNode and it is difficult to select them by using SelectSingleNode of the
object XmlDocument.
I've this question: is it possible to identify each XmlNode of the
XmlDocument by using an inner key or something like that ?
I precise that I 'm not allowed to change the file XML, therefore I can't
add any key element or attribute in each node.
|
by: Paul |
last post by:
Here I have the definition of an XmlNode which is a property (PayPreference)
on my Customer class containing an enum describing how the customer will
pay.
<PayPerference xsi:type="a4:Customer+CustomerPayOptions"
xmlns:a4="http://schemas.microsoft.com/clr/nsassem/OsfDomain.Resources.Stage/OsfDomain%2C%20Version%3D1.0.0.1%2C%20Culture%3Dneutral%2C%20PublicKeyToken%3Dnull">cash</PayPerference>
I now want to add this XmlNode to a different...
|
by: Mahesh Devjibhai Dhola |
last post by:
Hi All,
I want to make a custom class in c#, which extends System.Xml.XmlNode class
of BCL.
Now in custom class, I have implement abstract methods of XmlNode class
also. Now when I am trying to run the class it gives an error that
"System.Xml.XmlNode.XmlNode() is inaccessible due to its protection level".
This error comes because XmlNode has not any public constructor. I found
XmlNode has two constructor but both are private or friend...
| |
by: jens Jensen |
last post by:
Hello,
I have built a client of a websevrice. I call a webmethod that takes an
Xmldocument object and returns an Xmldocument object.
When i add a refernce to this webservice on the client, then the input
output types of my webmethod generated in the proxy class are changed to
XmlNode. This mean, I get XmlNode as input argument instead of XmlDocument
and the same for the return type.
I'm using Vsual Studio 2005.
|
by: jens Jensen |
last post by:
Hello,
I have built a client of a websevrice. I call a webmethod that takes an
Xmldocument object and returns an Xmldocument object.
When i add a refernce to this webservice on the client, then the input
output types of my webmethod generated in the proxy class are changed to
XmlNode. This mean, I get XmlNode as input argument instead of XmlDocument
and the same for the return type.
I'm using Vsual Studio 2005.
|
by: Earl |
last post by:
In VB.Net, the following declaration builds and executes with no exceptions:
Dim XMLDoc As New XmlDocument
Dim Node As XmlNode
But in C#, the following (equivalent?!) returns the build error "XMLNode
does not exist in the current context.":
XmlDocument XMLDoc = new XmlDocument();
XmlNode Node = XMLNode;
|
by: Andrus |
last post by:
How to remove whole Xmlnode so that outer tags are also removed ?
To reproduce, run the code.
Observed result:
<Query>
<DataSourceName>DS1</DataSourceName>
<QueryParameters>
</QueryParameters>
|
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...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
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...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
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,...
|
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...
|
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...
|
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();...
| |
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...
| |