Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Problems using services which return data using xsi:nil

Reply
Thread Tools

Problems using services which return data using xsi:nil

 
 
Stan Yamane
Guest
Posts: n/a
 
      07-14-2003
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/"><ReturnNullObjectInContainerRe
sult /></ReturnNullObjectInContainerResponse>

..NET response w/ IsNullable=true [or from the server I
need to connect to]:
<ReturnNullObjectInContainerResponse
xmlns="http://tempuri.org/"><ReturnNullObjectInContainerRe
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.

 
Reply With Quote
 
 
 
 
Stan Yamane
Guest
Posts: n/a
 
      07-15-2003
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/"><ReturnNullObjectInContainerRe
>sult /></ReturnNullObjectInContainerResponse>
>
>..NET response w/ IsNullable=true [or from the server I
>need to connect to]:
><ReturnNullObjectInContainerResponse
>xmlns="http://tempuri.org/"><ReturnNullObjectInContainerRe
>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.
>
>.
>

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
suggestions re: data recovery services for Peachtree data? Jacques Clouseau Computer Support 4 04-09-2008 01:02 PM
Microcontrollers: which one ? which language ? which compiler ? The Jesus of Suburbia NZ Computing 2 02-11-2006 06:53 PM
Stylus Studio and Raining Data Partner to Simplify XML Data Services Stylus Studio XML 0 08-12-2005 01:46 AM
what value does lack of return or empty "return;" return Greenhorn C Programming 15 03-06-2005 08:19 PM
Data Recovery Book and Online Business Promotion, Products Sales Promotion, Search Engine Optimization and Online Data Recovery Training services Author Tarun Tyagi Cisco 0 12-15-2004 01:52 AM



Advertisments