Solved

Web Service Method that returns an XmlNode has invalid XML characters

Posted on 2012-03-09
4
581 Views
Last Modified: 2012-04-01
I have a vb.net web method that returns an XML node that is generated via serialization, but somehow still contains characters that are invalid in XML.  If you make a soap call, you get the XML data, but if you attempt to load this XML into an XML Doc it will throw an error about invalid characters.

I imagine that there is some type of encoding that I am missing, but I am perplexed as to how they are even able to be loaded into an XML node before being returned.

The serialization is happening via System.Xml.Serialization.XmlSerializer.Serialize.  Below is a short sample of the serialization and the response of the web method.
Dim lobjCompanyInformationStream As New MemoryStream
Dim lobjSerializeCompanyInformation As XmlSerializer = New XmlSerializer(GetType(abc.CompanyInformation.Response))
Dim lobjXmlNameSpace As New XmlSerializerNamespaces
lobjXmlNameSpace.Add("", "")

lobjSerializeCompanyInformation.Serialize(lobjCompanyInformationStream, lobjResponse, lobjXmlNameSpace)
lobjCompanyInformationStream.Position = 0
lobjCompanyInformationXmlDoc.Load(lobjCompanyInformationStream)

Dim lobjNameSpaceManager As New XmlNamespaceManager(lobjCompanyInformationXmlDoc.NameTable)
lobjNameSpaceManager.AddNamespace(abcNameSpace.abc_NameSpace_abcXMLRootNode_Prefix, abcNameSpace.abc_NameSpace_CompanyInformation_v2)

Return lobjCompanyInformationXmlDoc.SelectSingleNode("//" & abcNameSpace.abc_NameSpace_abcXMLRootNode_Prefix & ":" & NODENAME_RESPONSEROOT, lobjNameSpaceManager)

Open in new window

0
Comment
Question by:StarbucksDrinker
  • 2
  • 2
4 Comments
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
Have you tried inspecting the XML just prior to loading it into the
XmlDocument

Open in new window

? What type of object are you loading from:  string, XmlReader, etc.?
0
 
LVL 1

Accepted Solution

by:
StarbucksDrinker earned 0 total points
Comment Utility
Was not able to find a resolution to this issue and had to go about a different approach.
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
Comment Utility
It generally helps if you respond to questions that are asked. We cannot help you if we don't understand your environment  : \
0
 
LVL 1

Author Closing Comment

by:StarbucksDrinker
Comment Utility
No other solution was found
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Introduction As chip makers focus on adding processor cores over increasing clock speed, developers need to utilize the features of modern CPUs.  One of the ways we can do this is by implementing parallel algorithms in our software.   One recent…
Introduction When many people think of the WebBrowser (http://msdn.microsoft.com/en-us/library/2te2y1x6%28v=VS.85%29.aspx) control, they immediately think of a control which allows the viewing and navigation of web pages. While this is true, it's a…
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now