Friday, November 05, 2004

VJs Tip Of The Day - November 5th 2004

XmlDocument on WebService

This is just an observation which you can make... If there is a web method in your webservice which takes or returns a parameter of type System.Xml.XmlDocument then it gets converted into System.Xml.XmlNode on the client side (if you are using .Net on both the ends and adding web reference via wsdl.exe)...

ie if your service web method definition looks like below...
_
Public Function GetXmlDoc(ByVal Id As Integer, _
ByVal doc As XmlDocument) As XmlDocument
End Function

The proxy definition of the same method will look like below...
Public Function GetXmlDoc(ByVal Id As Integer, ByVal doc As System.Xml.XmlNode) As System.Xml.XmlNode
Dim results() As Object = Me.Invoke("GetXmlNode", New Object() {Id, doc})
Return CType(results(0),System.Xml.XmlNode)
End Function


It is an understood behavior that for WSDL you are always receiving a XmlNode if it is a document for you then you are suppose to implicitly convert the same into a XmlDocument...

I do wish that there was a special indication in WSDL which could inform the proxy generator whether a node is expected or a document is, but that is more to do with the WSDL file format right!!...

PS: Have a wonderful weekend... :-) If you are reading this mail on Monday then decide right away that you got to have a wonderful next weekend... If you were 'requested' to work over this weekend even if you had to do something for yourself at that time, then better start taking lessons on 'being affirmative'...
:-) If you have not seen the movie "Office Space" then make sure you grab it from somewhere and watch it next weekend... To an extent it helped me laugh at my own doomed situation... :-)

No comments: