Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Web Service Method that returns an XmlNode has invalid XML characters

Posted on 2012-03-09
4
Medium Priority
?
599 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

Independent Software Vendors: 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

Article by: jpaulino
XML Literals are a great way to handle XML files and the community doesn’t use it as much as it should.  An XML Literal is like a String (http://msdn.microsoft.com/en-us/library/system.string.aspx) Literal, only instead of starting and ending with w…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…
Suggested Courses

688 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