Groups | Blog | Home
all groups > dotnet web services > november 2006 >

dotnet web services : IsNullable:=true in Proxy class


teddysnips NO[at]SPAM hotmail.com
11/24/2006 7:36:09 AM
<NEWBIE ALERT>

Owing to staff lossage, I've been forced to take over maintenance and
upgrade of a completely undocumented web service (VS 2003, VB.NET).

I've been asked to amend a Public Function and, being a lazy sort,
thought about using Optional parameters.

However, I noticed something weird about the Function that was built in
the Proxy class:

VB
==

<WebMethod(), SoapHeader("Credentials"), SoapHeader("ResultHeader",
Direction:=SoapHeaderDirection.Out)> _
Public Function CreateGroupBooking(ByVal key As IndividualKey, ByVal
groupName As String, _
ByVal email As String, ByVal address As Address, ByVal
contactFirstName As String, _
ByVal contactLastName As String) As BookingList

PROXY
======

Public Function CreateGroupBooking(ByVal key As IndividualKey, ByVal
groupName As String, ByVal email As String,
<System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)> ByVal
Address As Address, ByVal contactFirstName As String, ByVal
contactLastName As String) As
<System.Xml.Serialization.XmlElementAttribute("BookingList",
IsNullable:=true)> BookingList


I can't quite figure out what's with the

<System.Xml.Serialization.XmlElementAttribute(IsNullable:=true)>

that prefixes the Address parameter and the BookingList return.

I note that the class declaration for the BookingList, for example is:

<XmlRoot(ElementName:="BookingList")> _
Public Class BookingList

If I remove the line

<XmlRoot(ElementName:="BookingList")> _

the tag is not there! The same goes for the Address class.

Is this some kind of kludge to allow nullable parameters? Remember, I
am a newbie!

Thanks

Edward
Claus Konrad [MCSD]
11/24/2006 1:49:01 PM
The XML structures being sent on the wire (the SOAP message content) have to
be declared somewhere. As BookingList in your case is a Class, it has to bear
the <XmlRoot> attribute to be serialized correctly. XmlSerialization is the
default when using WebServices.

This in injected automatically by VS when building.
--
rgds.
/Claus Konrad
MCSD.NET (C#)


[quoted text, click to view]
AddThis Social Bookmark Button