Solved

Web Service Method that returns an XmlNode has invalid XML characters

Posted on 2012-03-09
4
594 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37703894
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
ID: 37771422
Was not able to find a resolution to this issue and had to go about a different approach.
0
 
LVL 75

Expert Comment

by:käµfm³d 👽
ID: 37771470
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
ID: 37792631
No other solution was found
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Well, all of us have seen the multiple EXCEL.EXE's in task manager that won't die even if you call the .close, .dispose methods. Try this method to kill any excels in memory. You can copy the kill function to create a check function and replace the …
Calculating holidays and working days is a function that is often needed yet it is not one found within the Framework. This article presents one approach to building a working-day calculator for use in .NET.
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

734 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