For Programmers: Free Programming Magazines  


Home > Archive > ASP .NET Webservices > November 2005 > Problem With Typed DataSet Schema









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Problem With Typed DataSet Schema
OhioGolfer

2005-11-08, 7:00 pm

My app consists of a windows form client, a business logic layer, and a
web application that hosts a strongly typed dataset and a variety of
web services. The web services retrieve the data from the SQL Server
database, do whatever logical processing is required, and return the
results to the business logic layer, which holds the data in an
instance of the typed dataset.

In my typed dataset, I have added annotations to the xsd file to
provide nullValue values, and avoid the StrongTypingException issue
when nulls are present in the data store. However, when the app runs,
the StrongTypingException still is thrown. When I go into the
Reference.vb file, and check the xsd that the reference is hitting, the
annotations are not there. It is obviously generating its own schema,
while I want it to use the schema in the web application.

Any ideas on how to get around this? It is driving me crazy . . .

Jeff

Kevin Yu [MSFT]

2005-11-09, 3:58 am

Hi Jeff,

I would like to know how you set the nullValue for a certain column. Did
you modified the attribute in the xsd? Also are the business logic layer
and the webservice layer referencing to the same typed DataSet class?

Please take a look at the following KB article. It will be a good guide for
your to handle DBNull values in typed DataSet.

http://support.microsoft.com/defaul...kb;en-us;318048

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

OhioGolfer

2005-11-09, 7:58 am

Kevin -- I modified the .xsd file by adding the
xmlns:codegen="urn:schemas-microsoft-com:xml-msprop" reference, and
adding codegen:nullValue="_empty" or "0" or "1980-01-01", depending
upon the field type involved. This works fine on the server side --
the .vb file for the typed dataset properly incorporates the
annotations, and no StrongTypingException is thrown.

The problem arises on the client side. The web reference to the web
service regenerates the schema as part of the reference, and drops the
annotations. Thus, the Reference.vb file throws the
StrongTypingException. I have tried modifying the .wsdl file to point
to the "original" xsd schema, but that doesn't work. I could modify
the Reference.vb file, but this is an unstable solution, as those
changes will be lost anytime the reference is updated.

There have been a few allusions to this as a known bug in the web
service treatment of typed datasets in other forums, but I have yet to
see a proposed solution. Hope you can shed some light on this.

Jeff

Kevin Yu [MSFT]

2005-11-10, 3:59 am

Hi Jeff,

With my further research, I found that it is a known issue in ADO .net.
When XmlSerializing the typed dataset, the extended properties will not be
persisted. So the nullValue attribute cannot be passed through a web
service.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

OhioGolfer

2005-11-10, 7:57 am

Kevin -- That's it? No workaround, no indication as to whether this is
fixed in 2.0? With the push of Smart Client architecture, I find it
hard to believe that MS is simply stating this can't be done. Are you
really implying that we either have to abandon typed datasets when
using web services or make all of our database fields not nullable, and
provide default values?

Very disappointing.

Jeff

Kevin Yu [MSFT]

2005-11-11, 3:59 am

Hi Jeff,

I'm sorry, but currently there is nothing we can do on this issue. I
suggest you try to contact Microsoft PSS for more information on this issue
to see if they can work out a fix for you. Here is their contact
information.

http://support.microsoft.com/defaul...S;OfferProPhone

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

OhioGolfer

2005-11-12, 7:00 pm

Kevin (and any others who may encounter this issue):

After much agonizing and trial and error, I have found a workaround
that enables the client to capture the nullValue attributes.

Assuming a typed datset named myData, generate the dataset. In the
myData.vb file, modify the Init_Class procedure for each datatable in
your dataset by including the following for any nullable fields. (Here
I am assuming fields called myString, myInt, myDate):
columnmyString.ExtendedProperties.Add("nullValue","_empty")
columnmyInt.ExtendedProperties.Add("nullValue","0")
columnmyDate.ExtendedProperties.Add("nullValue,"2000-01-01")

Save the myData.vb file. Delete any existing web references that call
for the myData schema, and create a new web reference. If you check
the myData.xsd file generated, as well as the Reference.vb file, you
will see that the attributes are preserved, and the calls to the
StrongTypingException in the Reference.vb file no longer exist.

One caveat here is that this should be done after you have finalized
the structure of your typed dataset. Regenerating the .xsd file on the
server will regenerate the .vb file on the server, and you will have to
add the ExtendedProperties again.

Hope this helps others. Is Microsoft fixing this in 2.0?

Jeff






Kevin Yu [MSFT] wrote:
> Hi Jeff,
>
> I'm sorry, but currently there is nothing we can do on this issue. I
> suggest you try to contact Microsoft PSS for more information on this issue
> to see if they can work out a fix for you. Here is their contact
> information.
>
> http://support.microsoft.com/defaul...S;OfferProPhone
>
> Kevin Yu
> =======
> "This posting is provided "AS IS" with no warranties, and confers no
> rights."


Kevin Yu [MSFT]

2005-11-14, 9:58 pm

Hi Jeff,

Thanks for your workaround. So far, I didn't see .NET 2.0 framework has
fixed this yet.

Kevin Yu
=======
"This posting is provided "AS IS" with no warranties, and confers no
rights."

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com