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.xmld ocument cannot be converted to
System.IO.textr eader.
I would think this is possible to do.
Code snippet is below:
-------------------------------------------------------
Public Function ChangeAddress(B yVal xml As
XmlDocument) As Boolean
Try
Dim xtr As New XmlTextReader(x ml)
-------------------------------------------------------
Any and all help is greatfully appreciated.
--
Thanks,
Scott 7 4906
Hi Scott
You could do this (code follows), but I'm not sure why you would want to...?
Essentially, the XmlDocument, (xml in your method) is an in memory tree of
your XML data - the code below serializes the tree to a string, then reads it
in again...it's kind of wasteful. If you want to access content of the
document, then use methods like SelectNodes, GetElementsByTa gName, and so on
to read through the data in memory...
Nigel
Code:
Public Function ChangeAddress(B yVal xml As XmlDocument)
Dim sr As New IO.StringReader (xml.OuterXml)
Dim t As New Xml.XmlTextRead er(sr)
While t.Read
MessageBox.Show (t.Name)
End While
End Function
"SQLScott" wrote: 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.xmld ocument cannot be converted to System.IO.textr eader.
I would think this is possible to do.
Code snippet is below:
------------------------------------------------------- Public Function ChangeAddress(B yVal xml As XmlDocument) As Boolean
Try
Dim xtr As New XmlTextReader(x ml)
-------------------------------------------------------
Any and all help is greatfully appreciated.
-- Thanks,
Scott
Thanks Nigel, I appreciate the response.
You state "why would you want to?". Is there a better of doing what I am
tryign to accomplish? Should I not be passing an XMLDocument?
Scott
"Nigel Armstrong" wrote: Hi Scott
You could do this (code follows), but I'm not sure why you would want to...?
Essentially, the XmlDocument, (xml in your method) is an in memory tree of your XML data - the code below serializes the tree to a string, then reads it in again...it's kind of wasteful. If you want to access content of the document, then use methods like SelectNodes, GetElementsByTa gName, and so on to read through the data in memory...
Nigel Code: Public Function ChangeAddress(B yVal xml As XmlDocument) Dim sr As New IO.StringReader (xml.OuterXml) Dim t As New Xml.XmlTextRead er(sr) While t.Read MessageBox.Show (t.Name) End While End Function
"SQLScott" wrote:
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.xmld ocument cannot be converted to System.IO.textr eader.
I would think this is possible to do.
Code snippet is below:
------------------------------------------------------- Public Function ChangeAddress(B yVal xml As XmlDocument) As Boolean
Try
Dim xtr As New XmlTextReader(x ml)
-------------------------------------------------------
Any and all help is greatfully appreciated.
-- Thanks,
Scott
Hi Scott
I don't have a problem with you passing an XmlDocument via a Web service!
It's just that with your XmlDocument parameter on your Web service method,
you already have a programmatic interface to your XML data - there's no need
to reparse it with the XmlTextReader.. .so as I mentioned in my previous post,
you can use GetElementsByTa gName(), SelectNodes() and so on to get access to
the data, you don't need to reparse.
Nigel Armstrong
"SQLScott" wrote: Thanks Nigel, I appreciate the response.
You state "why would you want to?". Is there a better of doing what I am tryign to accomplish? Should I not be passing an XMLDocument?
Scott
"Nigel Armstrong" wrote:
Hi Scott
You could do this (code follows), but I'm not sure why you would want to...?
Essentially, the XmlDocument, (xml in your method) is an in memory tree of your XML data - the code below serializes the tree to a string, then reads it in again...it's kind of wasteful. If you want to access content of the document, then use methods like SelectNodes, GetElementsByTa gName, and so on to read through the data in memory...
Nigel Code: Public Function ChangeAddress(B yVal xml As XmlDocument) Dim sr As New IO.StringReader (xml.OuterXml) Dim t As New Xml.XmlTextRead er(sr) While t.Read MessageBox.Show (t.Name) End While End Function
"SQLScott" wrote:
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.xmld ocument cannot be converted to System.IO.textr eader.
I would think this is possible to do.
Code snippet is below:
------------------------------------------------------- Public Function ChangeAddress(B yVal xml As XmlDocument) As Boolean
Try
Dim xtr As New XmlTextReader(x ml)
-------------------------------------------------------
Any and all help is greatfully appreciated.
-- Thanks,
Scott
Ah, ok, i'm with you now. It makes sense now that I have gone back to
re-read your original answer. Sorry for the confusion.
Scott
"Nigel Armstrong" wrote: Hi Scott
I don't have a problem with you passing an XmlDocument via a Web service! It's just that with your XmlDocument parameter on your Web service method, you already have a programmatic interface to your XML data - there's no need to reparse it with the XmlTextReader.. .so as I mentioned in my previous post, you can use GetElementsByTa gName(), SelectNodes() and so on to get access to the data, you don't need to reparse.
Nigel Armstrong
"SQLScott" wrote:
Thanks Nigel, I appreciate the response.
You state "why would you want to?". Is there a better of doing what I am tryign to accomplish? Should I not be passing an XMLDocument?
Scott
"Nigel Armstrong" wrote:
Hi Scott
You could do this (code follows), but I'm not sure why you would want to...?
Essentially, the XmlDocument, (xml in your method) is an in memory tree of your XML data - the code below serializes the tree to a string, then reads it in again...it's kind of wasteful. If you want to access content of the document, then use methods like SelectNodes, GetElementsByTa gName, and so on to read through the data in memory...
Nigel Code: Public Function ChangeAddress(B yVal xml As XmlDocument) Dim sr As New IO.StringReader (xml.OuterXml) Dim t As New Xml.XmlTextRead er(sr) While t.Read MessageBox.Show (t.Name) End While End Function
"SQLScott" wrote:
> 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.xmld ocument cannot be converted to > System.IO.textr eader. > > I would think this is possible to do. > > Code snippet is below: > > ------------------------------------------------------- > Public Function ChangeAddress(B yVal xml As > XmlDocument) As Boolean > > Try > > Dim xtr As New XmlTextReader(x ml) > > ------------------------------------------------------- > > Any and all help is greatfully appreciated. > > -- > Thanks, > > Scott
Nigel, quick question. When I write the code to call the method adn pass it
an XMLDocument, the intellisense displays the parameter as:
system.xml.xmln ode
IN other words, bReturn = ws.CallMethod(x ml as system.xml.xmln ode)
Even though the parameter on the method is ByVal xml as XMLDocument.
I am at a loss. Any ideas why? Many thanks for your help on this.
"Nigel Armstrong" wrote: Hi Scott
I don't have a problem with you passing an XmlDocument via a Web service! It's just that with your XmlDocument parameter on your Web service method, you already have a programmatic interface to your XML data - there's no need to reparse it with the XmlTextReader.. .so as I mentioned in my previous post, you can use GetElementsByTa gName(), SelectNodes() and so on to get access to the data, you don't need to reparse.
Nigel Armstrong
"SQLScott" wrote:
Thanks Nigel, I appreciate the response.
You state "why would you want to?". Is there a better of doing what I am tryign to accomplish? Should I not be passing an XMLDocument?
Scott
"Nigel Armstrong" wrote:
Hi Scott
You could do this (code follows), but I'm not sure why you would want to...?
Essentially, the XmlDocument, (xml in your method) is an in memory tree of your XML data - the code below serializes the tree to a string, then reads it in again...it's kind of wasteful. If you want to access content of the document, then use methods like SelectNodes, GetElementsByTa gName, and so on to read through the data in memory...
Nigel Code: Public Function ChangeAddress(B yVal xml As XmlDocument) Dim sr As New IO.StringReader (xml.OuterXml) Dim t As New Xml.XmlTextRead er(sr) While t.Read MessageBox.Show (t.Name) End While End Function
"SQLScott" wrote:
> 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.xmld ocument cannot be converted to > System.IO.textr eader. > > I would think this is possible to do. > > Code snippet is below: > > ------------------------------------------------------- > Public Function ChangeAddress(B yVal xml As > XmlDocument) As Boolean > > Try > > Dim xtr As New XmlTextReader(x ml) > > ------------------------------------------------------- > > Any and all help is greatfully appreciated. > > -- > Thanks, > > Scott
Scott
In practice it won't matter! The node that you get is actually a
System.Xml.XmlE lement - this code illustrates:
Dim s As New localhost.XmlSe rvice
Dim n As System.Xml.XmlN ode = s.HelloWorld
MessageBox.Show (n.NodeType & " " & n.OuterXml)
What do you need to do with the returned data??
HTH
Nigel
"SQLScott" wrote: Nigel, quick question. When I write the code to call the method adn pass it an XMLDocument, the intellisense displays the parameter as:
system.xml.xmln ode
IN other words, bReturn = ws.CallMethod(x ml as system.xml.xmln ode)
Even though the parameter on the method is ByVal xml as XMLDocument.
I am at a loss. Any ideas why? Many thanks for your help on this.
"Nigel Armstrong" wrote:
Hi Scott
I don't have a problem with you passing an XmlDocument via a Web service! It's just that with your XmlDocument parameter on your Web service method, you already have a programmatic interface to your XML data - there's no need to reparse it with the XmlTextReader.. .so as I mentioned in my previous post, you can use GetElementsByTa gName(), SelectNodes() and so on to get access to the data, you don't need to reparse.
Nigel Armstrong
"SQLScott" wrote:
Thanks Nigel, I appreciate the response.
You state "why would you want to?". Is there a better of doing what I am tryign to accomplish? Should I not be passing an XMLDocument?
Scott
"Nigel Armstrong" wrote:
> Hi Scott > > You could do this (code follows), but I'm not sure why you would want to...? > > Essentially, the XmlDocument, (xml in your method) is an in memory tree of > your XML data - the code below serializes the tree to a string, then reads it > in again...it's kind of wasteful. If you want to access content of the > document, then use methods like SelectNodes, GetElementsByTa gName, and so on > to read through the data in memory... > > Nigel > Code: > Public Function ChangeAddress(B yVal xml As XmlDocument) > Dim sr As New IO.StringReader (xml.OuterXml) > Dim t As New Xml.XmlTextRead er(sr) > While t.Read > MessageBox.Show (t.Name) > End While > End Function > > "SQLScott" wrote: > > > 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.xmld ocument cannot be converted to > > System.IO.textr eader. > > > > I would think this is possible to do. > > > > Code snippet is below: > > > > ------------------------------------------------------- > > Public Function ChangeAddress(B yVal xml As > > XmlDocument) As Boolean > > > > Try > > > > Dim xtr As New XmlTextReader(x ml) > > > > ------------------------------------------------------- > > > > Any and all help is greatfully appreciated. > > > > -- > > Thanks, > > > > Scott
That is completely correct.
If you are working with Web services, you need to think about the contract
(WSDL) that is the basis for clients consuming your Web service. ASP.NET
makes working with WSDL both easy and makes this hard by automatically
generating WSDL for you based on XML Serialization and various attributes in
your code. Easy because often you don't have to do anything to make the
right (or a reasonable) thing happen. Hard because you still have to think
about the WSDL that ASP.NET is generating, since that is all the client
sees.
It is important to note that Web services have *nothing* to do with objects
and object-orientation. Web services pass XML data, not objects, not types.
Both System.Xml.XmlN ode and System.Xml.XmlD ocument serialize down in your
Web service message to an arbritrary, unconstrained XML element, represented
in the WSDL as the XSD type <xs:any/>. Later, when you add a Web reference
to a project, Visual Studio takes the WSDL for the Web service and creates
proxy classes for the types represented in the WSDL. In other words, the
proxy classes map XML data into classes. When a proxy classes are generated
for a WSDL document, <xs:any/> maps to XmlNode.
Consider your Web service from the perspective of clients that consume your
Web service using different platforms, languages or vendors, say a J2EE
client on a Sun or IBM system. They can consume an XML element (<xs:any/>)
in your SOAP message, but that don't know anything about .NET Framework
classes like XmlNode or XmlDocument. So you have to see beyond the
ASP.NET-ism of thinking you are passing an XmlDocument on a Web service
endpoint: you are passing what the WSDL says you are passing, and that's XML
data.
Cheers,
Stuart Celarier, Fern Creek This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Jason |
last post by:
I have an XML web control on a usercontrol. The only purpose for this
usercontrol is to get XML data from a URL and display
it in the xml web control with the help of XSL.
I can get this to work if I log into the machine that is hosting the
website, whether it be my dev box or staging box. When I try to access the
page remotely, I get an error:
This is an unexpected token. The expected token is 'QUOTE'. Line 1, position
110.
|
by: sunil |
last post by:
I am creating a XML document which opens fine in IE. Implies MSXML
thinks it is a well formed document.
But when I try to load this document in VB.net using the following
code
Dim doc As New XmlDocument
doc.Load("C:\Projects\SQLXML\corc.xml")
I get the following error:
"System.Xml.XmlException: An unexpected end of file parsing CDATA has
|
by: SqlJunkies User |
last post by:
I have pretty same problem with XmlDocument.Load(). It seems to appear after KB834623 hotfix installed. Here is the information to reproduce error:
Technical info:
• Windows XP Professional SP1
• .NET Framework 1.1
• KB834623 hotfix for .NET Framework 1.1 installed (installing with .NET Speech SDK 1.0)
Steps to reproduce:
1. Create new ASP.NET web application in IIS, for example, XmlDocBugTest
2. Place test XML document in the...
|
by: Sammy |
last post by:
Can anyone please explain me the cause and resolution of
this error.
TIA
Sammy
Server Error in '/' Application.
The device is not ready.
Description: An unhandled exception occurred during the
execution of the current web request. Please review the
|
by: Patrick |
last post by:
I understand it is built in behaviour that if an ASP.NET's web.config is set
to:
<customErrors
mode="RemoteOnly"
/>
then I only get a detailed error message on screen when the ASP.NET
application is executed on the IIS server itself. However, I note that
with the following
| |
by: XML newbie: Urgent pls help! |
last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it
verifies the login information it should display the SessionID and enable
some button . I appreciate your help and thanku in advance
When I run the pgm , I get the error:
Can't parse login information. Namespace Manager or XsltContext needed. This
query has a prefix, variable or userdefined function.
I have added the Try-catch in all my functions. In...
|
by: XML newbie: Urgent pls help! |
last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it
verifies the login information it should display the SessionID and enable
some button . I appreciate your help and thanku in advance
When I run the pgm , I get the error:
Can't parse login information. Namespace Manager or XsltContext needed. This
query has a prefix, variable or userdefined function.
I have added the Try-catch in all my functions. In...
|
by: XML newbie: Urgent pls help! |
last post by:
I am using VB.Net. My program is to connect to a remote IPAddress. Once, it
verifies the login information it should display the SessionID and enable
some button . I appreciate your help and thanku in advance
When I run the pgm , I get the error:
Can't parse login information. Object Reference not set to an instance of an
object. I have added the Try-catch in all my functions. In ParseLoginResponse
function, it catches the above...
|
by: santoshsri |
last post by:
Hi All,
My C# web application calls a webservice to process a report. It sends XMLs as parameter and in response gets an XML node which stores Binay datatype bin.base64.
It makes an instance of the proxy class of webservice and makes a synchronous call to webservice GetReport() op.
Here is the code snippet -
***************************************************************************************
wbFELIP.wsZProcessReport.ProcessReport...
|
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: 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: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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: 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...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
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
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |