473,385 Members | 1,748 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,385 software developers and data experts.

Type Conversion to Original Type

I have a class library, lets call it ClassLib, which contains an abstract
class, lets call it Entity, that acts as sort of a marker.

I have a web service that consumes the ClassLib to make use of the Entity
abstract class. The web service has a class, lets call it MyEntity that
inherits from ClassLib.Entity and a method called GetEntitites that returns
an array of MyEntity classes.

Next I have a web application that consumes the web service. Of course the
reference to the web services makes a proxy classes called Entity and
MyEntity. The problem is that these types are NOT the same types as the web
service referenced therefore when the GetEntities method is called it returns
the array of MyEntity objects as defined by the proxy.

This is all well and expected. I understand all of what I just explained.
Now here comes my question...

How can I convert each of the MyEntity objects returned from the web service
into the original type that the web serviced used from the ClassLib?

NOTE: I do not want to change anything in the references.cs file of the
reference to the web service.

I looked at the System.ComponentModel.TypeConverter class but that just
doesn't work. Casting doesn't work as well. Any ideas?

--
-Demetri
Nov 17 '05 #1
2 1478
Demetri wrote:
How can I convert each of the MyEntity objects returned from the web service
into the original type that the web serviced used from the ClassLib?

NOTE: I do not want to change anything in the references.cs file of the
reference to the web service.


I had a similar situation, but I resolved by editing the references
file of proxy classes to return the appropriate types. It works fine,
but if you ever refresh the web service, you have to do it again.

I don't beleive there will be an automatic way to what you want. One
possibility would be to include in your MyEntity class a constructor
that takes an instance of the web proxy class. Then when you get one
back from the web service, just pass it to the constructor:

Dim obj As New MyEntity(instanceofwebproxyclass)

Then inside the constructor, take the properties of the web proxy class
and assign them to your custom class. Depending on the size of your
class, this may be tedious, though.

Nov 17 '05 #2
the simple answers is you can't without writing your own conversion code.

In next version of visual studio you will be able to share libraries across
the web service boundary in this manner.

HTH

Ollie Riches

"Demetri" <De*****@discussions.microsoft.com> wrote in message
news:20**********************************@microsof t.com...
I have a class library, lets call it ClassLib, which contains an abstract
class, lets call it Entity, that acts as sort of a marker.

I have a web service that consumes the ClassLib to make use of the Entity
abstract class. The web service has a class, lets call it MyEntity that
inherits from ClassLib.Entity and a method called GetEntitites that
returns
an array of MyEntity classes.

Next I have a web application that consumes the web service. Of course the
reference to the web services makes a proxy classes called Entity and
MyEntity. The problem is that these types are NOT the same types as the
web
service referenced therefore when the GetEntities method is called it
returns
the array of MyEntity objects as defined by the proxy.

This is all well and expected. I understand all of what I just explained.
Now here comes my question...

How can I convert each of the MyEntity objects returned from the web
service
into the original type that the web serviced used from the ClassLib?

NOTE: I do not want to change anything in the references.cs file of the
reference to the web service.

I looked at the System.ComponentModel.TypeConverter class but that just
doesn't work. Casting doesn't work as well. Any ideas?

--
-Demetri

Nov 17 '05 #3

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

Similar topics

12
by: Aaron Watters | last post by:
I'm doing a heart/lung bypass procedure on a largish Python program at the moment and it prompted the thought that the methodology I'm using would be absolutely impossible with a more "type safe"...
5
by: Tongu? Yumruk | last post by:
I have a little proposal about type checking in python. I'll be glad if you read and comment on it. Sorry for my bad english (I'm not a native English speaker) A Little Stricter Typing in Python...
21
by: Nitin Bhardwaj | last post by:
Hi all, It is said that C++ is a strongly typed language and thus a type-safe language (unlike C). So how does one explain the following behaviour : int main(void) { char *p = NULL; p = "A...
5
by: Philip Pemberton | last post by:
Hi, I've just been trying to get some (pretty badly written) code working on a different compiler. Unfortunately, I've hit a problem. When the code below is compiled under Borland C++ it...
14
by: tweak | last post by:
I'm struggling with the concept of typecasting when setting up a TCP client. Here's a code snip (modified from W. Richard Stevens Unix Programming book) to demonstrate where I am struggling: ...
8
by: andyjgw | last post by:
Hi all, hope someone can help here, I'm really stuck. Reading and googling like mad, to no avail so far... Basically, my problem *seems* to boil down to type conversion: Here's a sample web...
8
by: Rob T | last post by:
When I was using VS2003, I was able to compile my asp.net project locally on my machine and copy it to the production server and it would run just fine. I've now converted to VS2005. The project...
8
by: Smithers | last post by:
Are there any important differences between the following two ways to convert to a type?... where 'important differences' means something more profound than a simple syntax preference of the...
6
by: Rahul | last post by:
Hi Everyone, I have the following code, class B; class A { public : operator B();
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.