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