473,386 Members | 1,753 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Webservice Dataset Type Fidelity Hoo Hah!!

Hello.

I am getting an InvalidCastException which has revealed yet more of my ignorance. I cant believe i
dont already know this and haven't encountered it before until now.

I am consuming a dataset from a webservice. I wrote both the server and client apps and the both use
the same middle teir. I fill a dataset on the server that has a relationship between two of the
tables inside. The relationship is between two strongly typed tables but is added dynamically as one
of the strongly typed tables is from another strongly typed dataset.

In consuming that from the client and then attempting to fill a datastore using the consumed dataset
i get the invalid cast exception when trying to traverse the relationship from child to parent row:

budgetRow =
CType(report.GetParentRow(SalesManagementBase.RELA TION_SALESAGENTPERIODREPORT_SALESFIGURES & "_B"),
_ dsSalesBudget.SalesFiguresAggregateRow)

budgetRow is of type dsSalesBudget.SalesFiguresAggregateRow.

I couldn;t understand the exception because i believed i casting from a poly morphed
dsSalesBudget.SalesFiguresAggregateRow temporarily down cast to an untyped data row by the
GetParentRow method. But it turns out the row is not poly morphed at all but simply a datarow having
been stripped of its strong type i guess by the serialization process). Command line print our below
for interest.

Can anyone bring me up to speed here? Im a little embarrassed i got caught out by this because it
reeks of *basic learning* which clearly i haven;t got. Can anyone bring me up to speed here? I get
the same schema server side, before send, and after, once captured/consumed... which i would expect
but command line shows me the tables are clearly typed differently hence the invalid cast exception:

* server side *
? reports.tables(2)
{dsSalesBudget.SalesFiguresAggregateDataTable}
[dsSalesBudget.SalesFiguresAggregateDataTable]: {dsSalesBudget.SalesFiguresAggregateDataTable}

* client side *
? reports.tables(2)
{System.Data.DataTable}
CaseSensitive: False
ChildRelations: {System.Data.DataRelationCollection.DataTableRelat ionCollection}

Thanks
Richard
Nov 22 '05 #1
7 1924
Richard,

Do not tell so much at the start of your message, the error is as I assume
form your message in this,
budgetRow =
CType(report.GetParentRow(SalesManagementBase.RELA TION_SALESAGENTPERIODREPORT_SALESFIGURES
& "_B"),
_ dsSalesBudget.SalesFiguresAggregateRow)


That is enough to show your problem in my opinion, going on in this you can
than explain more.

This statement is abolutly not possible. (It is impossible because of that
string connection).

I will try to tell you something about casting and converting from a
dataset.

A dataset is a tree of objects, a strongly typed dataset is to help you to
easily go trough that tree and that without that casting is needed, so
normally it should not be needed.

However trying to explain it more in a simple way, an object is nothing
more than a box that holds values or again other objects.

By instance,
dim a as object = 1
This will create an object with an integer with the value 1 in it.

Dim b As Integer = DirectCast(a, Integer)
Get that 1 out of that box (object) as an integer (there are a lot more
posibilities to do that by instance just CInt what is in fact a convert
function, however more easy to write, and probably therefore mostly used)

Dim c As Double = CDbl(a)
Converts an integer to a double

Dim d As String = CType(a, String)
Gets the integer from the object and converts it to a string (object)

Dim e As String = a.ToString
Does the same as above and is mostly used for that instead of the one above.
It is only for strings on every object.

Because of the fact, that the way you can write the casting and converting,
is very much dependend from the used program language, I advice you to ask
this kind of questions the next time in the newsgroup.

microsoft.public.dotnet.languages.vb

I hope this helps something?

Cor

Nov 22 '05 #2
JD
What does you web method signature look like?
"Richard Myers" <fa**@address.com> wrote in message
news:OK**************@TK2MSFTNGP09.phx.gbl...
Hello.

I am getting an InvalidCastException which has revealed yet more of my ignorance. I cant believe i dont already know this and haven't encountered it before until now.

I am consuming a dataset from a webservice. I wrote both the server and client apps and the both use the same middle teir. I fill a dataset on the server that has a relationship between two of the tables inside. The relationship is between two strongly typed tables but is added dynamically as one of the strongly typed tables is from another strongly typed dataset.

In consuming that from the client and then attempting to fill a datastore using the consumed dataset i get the invalid cast exception when trying to traverse the relationship from child to parent row:
budgetRow =
CType(report.GetParentRow(SalesManagementBase.RELA TION_SALESAGENTPERIODREPOR
T_SALESFIGURES & "_B"), _ dsSalesBudget.SalesFiguresAggregateRow)

budgetRow is of type dsSalesBudget.SalesFiguresAggregateRow.

I couldn;t understand the exception because i believed i casting from a poly morphed dsSalesBudget.SalesFiguresAggregateRow temporarily down cast to an untyped data row by the GetParentRow method. But it turns out the row is not poly morphed at all but simply a datarow having been stripped of its strong type i guess by the serialization process). Command line print our below for interest.

Can anyone bring me up to speed here? Im a little embarrassed i got caught out by this because it reeks of *basic learning* which clearly i haven;t got. Can anyone bring me up to speed here? I get the same schema server side, before send, and after, once captured/consumed... which i would expect but command line shows me the tables are clearly typed differently hence the invalid cast exception:
* server side *
? reports.tables(2)
{dsSalesBudget.SalesFiguresAggregateDataTable}
[dsSalesBudget.SalesFiguresAggregateDataTable]: {dsSalesBudget.SalesFiguresAggregateDataTable}
* client side *
? reports.tables(2)
{System.Data.DataTable}
CaseSensitive: False
ChildRelations: {System.Data.DataRelationCollection.DataTableRelat ionCollection}
Thanks
Richard

Nov 22 '05 #3
Hi Cor

I have no idea what your dribbling on about?

Do not tell so much at the start of your message, the error is as I assume
form your message in this,
I'll phrase and word my messages however i see fit.
budgetRow =
CType(report.GetParentRow(SalesManagementBase.RELA TION_SALESAGENTPERIODREPORT_SALESFIGURES
& "_B"),
_ dsSalesBudget.SalesFiguresAggregateRow)
That is enough to show your problem in my opinion, going on in this you can
than explain more.

This statement is abolutly not possible. (It is impossible because of that
string connection).


It is absolutely possible. I do it several times in the remainder of the application.
SalesManagementBase.RELATION_SALESAGENTPERIODREPOR T_SALESFIGURES & "_B" is simply a string which when used in this way converts to the name of a relation. Check out the method signature for GetParentRow before you make your decisions about what is and what is
not possible?
I will try to tell you something about casting and converting from a
dataset.

A dataset is a tree of objects, a strongly typed dataset is to help you to
easily go trough that tree and that without that casting is needed, so
normally it should not be needed.

However trying to explain it more in a simple way, an object is nothing
more than a box that holds values or again other objects.

By instance,
dim a as object = 1
This will create an object with an integer with the value 1 in it.

Dim b As Integer = DirectCast(a, Integer)
Get that 1 out of that box (object) as an integer (there are a lot more
posibilities to do that by instance just CInt what is in fact a convert
function, however more easy to write, and probably therefore mostly used)

Dim c As Double = CDbl(a)
Converts an integer to a double

Dim d As String = CType(a, String)
Gets the integer from the object and converts it to a string (object)

Dim e As String = a.ToString
Does the same as above and is mostly used for that instead of the one above.
It is only for strings on every object.

What has this got to do with my question? Im not looking for a 101 primer on object types. Im asking
about type fidelity over the wire?

Because of the fact, that the way you can write the casting and converting,
is very much dependend from the used program language, I advice you to ask
this kind of questions the next time in the newsgroup.

microsoft.public.dotnet.languages.vb
I'll decide which newsgroup best suits my purpose. The question i am asking could well go into
ADO.net/webservices/c#/vb.net. So in this case i chose general.

I hope this helps something?

Cor


No it didn't. It was irritating at best.

Richard
Nov 22 '05 #4
Richard,

Sorry because your huge amount of text I missed the "report.getparentrow".

In a news message it is not so easy reading and therefore I assumed you
where missing what is casting.

So forget it.

Telling that it was irritating, was however very overdone.

I am glad you cannot make mistakes and will keep that in mind with your next
message, knowing that you need no help because of that.

Cor

"Richard Myers" <fa**@address.com>
...
Hi Cor

I have no idea what your dribbling on about?

Do not tell so much at the start of your message, the error is as I
assume
form your message in this,


I'll phrase and word my messages however i see fit.
budgetRow =
CType(report.GetParentRow(SalesManagementBase.RELA TION_SALESAGENTPERIODREPORT_SALESFIGURES
& "_B"),
> _ dsSalesBudget.SalesFiguresAggregateRow)


That is enough to show your problem in my opinion, going on in this you
can
than explain more.

This statement is abolutly not possible. (It is impossible because of
that
string connection).


It is absolutely possible. I do it several times in the remainder of the
application.
SalesManagementBase.RELATION_SALESAGENTPERIODREPOR T_SALESFIGURES
& "_B" is simply a string which when used in this way converts to the
name of a relation. Check

out the method signature for GetParentRow before you make your decisions
about what is and what is
not possible?
I will try to tell you something about casting and converting from a
dataset.

A dataset is a tree of objects, a strongly typed dataset is to help you
to
easily go trough that tree and that without that casting is needed, so
normally it should not be needed.

However trying to explain it more in a simple way, an object is nothing
more than a box that holds values or again other objects.

By instance,
dim a as object = 1
This will create an object with an integer with the value 1 in it.

Dim b As Integer = DirectCast(a, Integer)
Get that 1 out of that box (object) as an integer (there are a lot more
posibilities to do that by instance just CInt what is in fact a convert
function, however more easy to write, and probably therefore mostly used)

Dim c As Double = CDbl(a)
Converts an integer to a double

Dim d As String = CType(a, String)
Gets the integer from the object and converts it to a string (object)

Dim e As String = a.ToString
Does the same as above and is mostly used for that instead of the one
above.
It is only for strings on every object.

What has this got to do with my question? Im not looking for a 101 primer
on object types. Im asking
about type fidelity over the wire?

Because of the fact, that the way you can write the casting and
converting,
is very much dependend from the used program language, I advice you to
ask
this kind of questions the next time in the newsgroup.

microsoft.public.dotnet.languages.vb


I'll decide which newsgroup best suits my purpose. The question i am
asking could well go into
ADO.net/webservices/c#/vb.net. So in this case i chose general.

I hope this helps something?

Cor


No it didn't. It was irritating at best.

Richard

Nov 22 '05 #5
JD
When you expose the typed dataset returned by the web service call, does the
typed dataset describe both typed tables and the relationship between them?
Or does the typed dataset describe only the one original typed table?

What I'm getting at is, does the WSDL thats created on the client describe
this relationship? The Visual Studio auto-generated WSDL is created from the
type exposed by your web service method. If your type does not describe the
second table type and the relationship, then the WSDL won't either, and
thats probably why you are losing type information.

Take a look at your client's web reference (make sure show all files is on).
Does the WSDL and the XSD describe the type and relationship thats missing?

JD
"Richard Myers" <fa**@address.com> wrote in message
news:Oj**************@TK2MSFTNGP10.phx.gbl...
Hi JD

<WebMethod()> _
Public Function GetNonReviewedSalesAgentPeriodReports(ByVal credential As NetworkCredential) As dsSalesAgentPeriodReport

dsSalesAgentPeriodReport is the dataset into which another strongly typed table of type dsSalesBudget.SalesFiguresAggregate is merged.

The type of this table remains as dsSalesBudget.SalesFiguresAggregate even when merged into dsSalesAgentPeriodReport as i would expect but once consumed by the webservice it is downcast to System.Data.DataTable?

Thanks
Richard

"JD" <no@spam.com> wrote in message

news:M01od.545384$mD.510187@attbi_s02...
What does you web method signature look like?
"Richard Myers" <fa**@address.com> wrote in message
news:OK**************@TK2MSFTNGP09.phx.gbl...
Hello.

I am getting an InvalidCastException which has revealed yet more of my

ignorance. I cant believe i
dont already know this and haven't encountered it before until now.

I am consuming a dataset from a webservice. I wrote both the server
and client apps and the both use
the same middle teir. I fill a dataset on the server that has a

relationship between two of the
tables inside. The relationship is between two strongly typed tables
but is added dynamically as one
of the strongly typed tables is from another strongly typed dataset.

In consuming that from the client and then attempting to fill a
datastore using the consumed dataset
i get the invalid cast exception when trying to traverse the
relationship from child to parent row:

budgetRow =

CType(report.GetParentRow(SalesManagementBase.RELA TION_SALESAGENTPERIODREPOR T_SALESFIGURES & "_B"),
_ dsSalesBudget.SalesFiguresAggregateRow)

budgetRow is of type dsSalesBudget.SalesFiguresAggregateRow.

I couldn;t understand the exception because i believed i casting from
a poly morphed
dsSalesBudget.SalesFiguresAggregateRow temporarily down cast to an
untyped data row by the
GetParentRow method. But it turns out the row is not poly morphed at
all but simply a datarow having
been stripped of its strong type i guess by the serialization
process). Command line print our below
for interest.

Can anyone bring me up to speed here? Im a little embarrassed i got
caught out by this because it
reeks of *basic learning* which clearly i haven;t got. Can anyone
bring me up to speed here? I get
the same schema server side, before send, and after, once

captured/consumed... which i would expect
but command line shows me the tables are clearly typed differently
hence the invalid cast exception:

* server side *
? reports.tables(2)
{dsSalesBudget.SalesFiguresAggregateDataTable}
[dsSalesBudget.SalesFiguresAggregateDataTable]:

{dsSalesBudget.SalesFiguresAggregateDataTable}

* client side *
? reports.tables(2)
{System.Data.DataTable}
CaseSensitive: False
ChildRelations:

{System.Data.DataRelationCollection.DataTableRelat ionCollection}

Thanks
Richard



Nov 22 '05 #6

Sorry because your huge amount of text I missed the "report.getparentrow".

In a news message it is not so easy reading and therefore I assumed you
where missing what is casting.

So forget it.

Telling that it was irritating, was however very overdone.

I am glad you cannot make mistakes and will keep that in mind with your next
message, knowing that you need no help because of that.


Hi Cor,

I have made many mistakes and will probably continue to make some more. That is generally the best
way to learn. My irritation was not at your off beat response to my question, i have done that
myself several times such is the nature of newsgroup postings. It was instead directed towards your
telling me "what" too write. You often seem to take it upon yourself to tell posters where to post
and when to post.... and now when you wanted to tell me "how and what" to post, I felt was very over
done and as i say "irritating" especially given your misdirected response.

If you had of read the "huge" amount of text you told me not to include which i considered the
"context" of the message, you would have known that i had already identitifed the error as being
that of casting ( i even included a command line dump), and that i understood why this had occured.
My message was subject "webservice dataset type fidelity" not "Casting Error - I dont understand?".
I also fail to see how you missed report.getparentrow when you cut and pasted that section of code
and then told me that is all my message should have been?

Either way i have worked around the error now and have moved on.

In hindsight, i suppose my response was a little caustic, but thats what im like when irritated.
(And i suppose the obvious joke is that, in that case i seem to be irratated all the time.) For that
i apologise.

Richard

Nov 22 '05 #7
Hi JD

You're absolutely right. Im a complete idiot!

I was thinking about the schema of the dataset once it had arrived on the client in terms of how i
was using it rather than the schema of the service definition.

What is worse is that i have clearly taken a very insular, and somewhat lazy approach to the
architecture of the service by exposing a service that is not adequately defined by it's WSDL/
webmethod signatures. It requires implicit knowlegde of the service which is like the "complete
opposite" of what a webservice should be.
Its only an internal/small project service so i figured I'd take a shortcut and then promptly forgot
that even i had taken it.

Quite shocking really.

Good job i sometimes quite like having my backside paddled..... by the right kind of woman of
course..... as i think i should really be pulling my britches down for this one!

Thanks again!

Richard


Nov 22 '05 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Richard Myers | last post by:
Hello. I am getting an InvalidCastException which has revealed yet more of my ignorance. I cant believe i dont already know this and haven't encountered it before until now. I am consuming a...
7
by: Shaine Fisher | last post by:
I have had a look around but I'm either not finding or not seeing the answer to this, what i want to do is reurn the results as an array, or some other worldly useful format that flash mx2004 can...
2
by: Jimbo | last post by:
Hi people, I've written and deployed some webservices. However, the port type in the WSDL file is generated by .NET (e.g. Service1Soap). I want to define the port type myself. Is there a way to...
0
by: MS Newsgroups | last post by:
Hi, I have a ASP .Net web application that uses a stored procedure to populate a datset that is bound to a datagrid. One column in the database has the is using the SQL type datetime to store a...
5
by: mtv | last post by:
Hi all, I have the following code: ================================ Webservice side: public class MyWS: WebService { private myLib.DataObject curDataObject;
0
by: Naes | last post by:
Hello, Does anyone know of a way to change the Content-Type of a WebService? It defaults to utf-8 and I have heard that it cannot be changed. I am currently working with Cyrillic and I need to...
7
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
2
by: enantiomer | last post by:
I have a question about web services and .NET 2.0. My question is how you can maintain type fidelity of objects returned from your web service. This would be useful for me so that objects...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.