Solved

Web Service Method that returns an XmlNode has invalid XML characters

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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

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

Here I am going to explain creating proxies at runtime for WCF Service. So basically we use to generate proxies using Add Service Reference and then giving the Url of the WCF service then generate proxy files at client side. Ok, what if something ge…
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.
There's a multitude of different network monitoring solutions out there, and you're probably wondering what makes NetCrunch so special. It's completely agentless, but does let you create an agent, if you desire. It offers powerful scalability …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…

635 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