Asp Forum
Home
|
Login
|
Register
|
Search
Forums
>
microsoft.public.dotnet.framework.aspnet.webservices
Problems using services which return data using xsi:nil
Stan Yamane
7/14/2003 7:11:00 PM
I'm trying to use a web service which sometimes returns
objects which contain null members. However, when
returning those objects, rather than just leaving those
members out of the returned XML, it represents them with
elements with xsi:nil attribute set to "true". (as
apparently allowed in the SOAP 1.1 rules for encoding,
section 5.1) [By default, .NET just leaves out elements
when it wants to return null from a server.
However, .NET can be made to replicate this behavior if
you set the IsNullable flag on the XmlElementAttribute
to "true" for each member you want to return as null]
My problem is that when a generated .NET client receives
this message, rather than unmarshalling it as null, it
calls the default constructor of the object and returns
that object to my client code.
Example fragment:
Normal .NET response:
<ReturnNullObjectInContainerResponse
xmlns="
http://tempuri.org/"><ReturnNullObjectInC...
sult /></ReturnNullObjectInContainerResponse>
..NET response w/ IsNullable=true [or from the server I
need to connect to]:
<ReturnNullObjectInContainerResponse
xmlns="
http://tempuri.org/"><ReturnNullObjectInC...
sult><TestObject
xsi:nil="true" /></ReturnNullObjectInContainerResult></Ret
urnNullObjectInContainerResponse>
As I understand it, the xsi:nil attribute should cause
the .NET runtime to create the container object and place
a null object inside of it, just as not having the object
should, but this doesn't seem to happen.
Has anyone else run across this and found a workaround?
I've tested this in .NET framework 1.1 and it still seems
to be a problem.
1 Answer
Stan Yamane
7/15/2003 5:56:00 PM
0
Found a workaround that seems to work. Thanks.
>-----Original Message-----
>I'm trying to use a web service which sometimes returns
>objects which contain null members. However, when
>returning those objects, rather than just leaving those
>members out of the returned XML, it represents them with
>elements with xsi:nil attribute set to "true". (as
>apparently allowed in the SOAP 1.1 rules for encoding,
>section 5.1) [By default, .NET just leaves out elements
>when it wants to return null from a server.
>However, .NET can be made to replicate this behavior if
>you set the IsNullable flag on the XmlElementAttribute
>to "true" for each member you want to return as null]
>
>My problem is that when a generated .NET client receives
>this message, rather than unmarshalling it as null, it
>calls the default constructor of the object and returns
>that object to my client code.
>
>Example fragment:
>
>Normal .NET response:
><ReturnNullObjectInContainerResponse
>xmlns="
http://tempuri.org/"><ReturnNullObjectInC...
>sult /></ReturnNullObjectInContainerResponse>
>
>..NET response w/ IsNullable=true [or from the server I
>need to connect to]:
><ReturnNullObjectInContainerResponse
>xmlns="
http://tempuri.org/"><ReturnNullObjectInC...
>sult><TestObject
>xsi:nil="true"
/></ReturnNullObjectInContainerResult></Ret>urnNullObjectInContainerResponse>
>
>As I understand it, the xsi:nil attribute should cause
>the .NET runtime to create the container object and place
>a null object inside of it, just as not having the object
>should, but this doesn't seem to happen.
>
>Has anyone else run across this and found a workaround?
>
>I've tested this in .NET framework 1.1 and it still seems
>to be a problem.
>
>.
>
Servizio di avviso nuovi messaggi
Ricevi direttamente nella tua mail i nuovi messaggi per
Problems using services which return data using xsi:nil
Inserendo la tua e-mail nella casella sotto, riceverai un avviso tramite posta elettronica ogni volta che il motore di ricerca troverà un nuovo messaggio per te
Il servizio è completamente GRATUITO!
x
Login to ForumsZone
Login with Google
Login with E-Mail & Password