I should probably add [RESOLVED] to the title since I have this working, but I have some questions about the whole web service reference thing...
My company's sites all have a "find a dealer" page where users can enter a zip/postal code and radius which then calls a web service function that returns a dataset containing a list of dealers within the radius from the entered zip code.
We recently acquired another company who's web site is handled by a third party that still uses old-fashioned asp. They are adding a "find a dealer" page but they don't want the data returned in a .NET dataset - they want it in XML. No problem, right?
I created a new service function that returns an XmlDataDocument:
<WebMethod()> _
Public Function findDealerByZip(ByVal postalCode As String, ByVal radius As String, ByVal distanceUOM As String) As XmlDataDocument
'gathers list of service locations and returns them in an XmlDataDocument
...
End Function
I added the reference to it to a test project, but in that automatically-generated reference the return values are NOT XmlDataDocument:
Public Function findDealerByZip(ByVal postalCode As String, ByVal radius As String, ByVal distanceUOM As String) As System.Xml.XmlNode
Dim results() As Object = Me.Invoke("findDealerByZip", New Object() {postalCode, radius, distanceUOM})
Return CType(results(0),System.Xml.XmlNode)
End Function
The project reference returns an XmlNode, not an XmlDataDocument. I was pulling my hair out trying to understand why I was getting a "Specified cast was not valid" error until I saw the return value in the reference was changed. Once I changed the return type in my test project to expect an XmlNode instead of an XmlDataDocument I no longer get the error.
Does anybody know why the return type in the reference was changed? I don't understand it.I would have said from a cursory glance the namespace you used was looking for xml.node instead of document which is why when you built your solution once you added your webservice the program itself was hardcoded by design would look for xml.node as opposed to xml.document. Are you using Imports System.Xml in the project or something more specific under that heading ?
I do not remember why, but I remember that you cannot return an XMLDataDocument from a web service. You can return an XMLNode, or an XMLDocument, or even a string which your ASP code takes and converts into its XMLDocument, but not XMLDataDocument.
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment