Solved

Web Service Method that returns an XmlNode has invalid XML characters

Posted on 2012-03-09
4
593 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

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

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.
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …
Finding and deleting duplicate (picture) files can be a time consuming task. My wife and I, our three kids and their families all share one dilemma: Managing our pictures. Between desktops, laptops, phones, tablets, and cameras; over the last decade…

726 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