Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / Web Services / March 2006

Tip: Looking for answers? Try searching our database.

Sharing Types between Webservice and Client

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Martin Ehrlich - 13 Jan 2005 20:52 GMT
Hello NG.

I've got a little problem with sharing types between webservices and
clients.

I've created a business class with public fields within a shared assembly
like:

public class Item
{
   public System.Guid UID
   public System.String Displayname
   public DateTime LastChanged
}

A corresponding webservice use this class and returns it.

[WebMethod()]
public Item GetItem()
{
   Item i = new Item();
   i.UID = Guid.NewGuid();
   i.Displayname = "New Item";
   i.LastChanged = DateTime.Now;
   return i;
}

I've also created a client application that consumes this webservice.
Webservice and client are sharing the same assembly which contains the class
"Item". Now I want to get the Item-object from the proxy, but because the
proxy generator creates his own class definition of "Item" out of the
wsdl-file, I cannot cast the webservice method return value to the business
object.

DataServices.ItemService service = new DataServices.ItemService();
Item i = service.Getitem();

I've made some research on this problem and discovered, that there is only
one way to manage this by editing the proxy-generated file "reference.cs".
This have to be done every time the webservice is changing. But there was
something wired about that.

If I'm returning a DataSet object or a XmlNode or XmlDocument, I get the
right type back, why is that so? I've checked if they have implemented some
interfaces on these classes, but that's not the case.

My question now is: Is there any way to make my own classes behaving like
XmlNode or XmlDocument? Maybe an attribute? Or Interface?

I'm currently using NET v1.1 and VS2003.

-Martin
Dilip Krishnan - 13 Jan 2005 21:54 GMT
Hello Martin,

   XmlNode XmlElement and XmlDocument etc are the types the .net Serializer
knows to work with. So anything that comes across the wire is first translated
to those types (not implying its implemented that way, just for explaining
my point) before they are converted into other domain specific types. They
are the building blocks of the serializer so to say. An analogy of it would
be in .net you have primitives (Xml types) which you can compose to form
complex types (objects like Item).
HTH
Regards,
Dilip Krishnan
MCAD, MCSD.net
dkrishnan at geniant dot com
http://www.geniant.com

> Hello NG.
>
[quoted text clipped - 46 lines]
>
> -Martin
William Stacey [MVP] - 14 Jan 2005 06:05 GMT
Is your wsdl already creating the type in another namespace.  So it creates
that type and you can't cast that type to your manual type.  Check your .cs
files (view all files) to see what types have been automatically generated
and their namespaces, etc.

Signature

William Stacey, MVP
http://mvp.support.microsoft.com

> Hello NG.
>
[quoted text clipped - 48 lines]
>
> -Martin
Martin Ehrlich - 14 Jan 2005 10:03 GMT
The wsdl file contains the right namespaces. But the proxy contains
xsd-generated types instead of the types from the shared assembly, which I
have to change manually.

-Martin

> Is your wsdl already creating the type in another namespace.  So it
> creates
[quoted text clipped - 60 lines]
>>
>> -Martin
andreimatei - 30 Mar 2006 15:39 GMT
check out Schema Importer Extensions, in 2005 (.net 2.0). It's what you
need.

--
andreimatei


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.