Re: Sharing Types between Webservice and Client

From: Martin Ehrlich (martin.ehrlich_at_gmx.de)
Date: 01/14/05


Date: Fri, 14 Jan 2005 11:03:25 +0100

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

"William Stacey [MVP]" <staceywREMOVE@mvps.org> schrieb im Newsbeitrag
news:eOjgNAg%23EHA.3124@TK2MSFTNGP11.phx.gbl...
> 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.
>
> --
> William Stacey, MVP
> http://mvp.support.microsoft.com
>
> "Martin Ehrlich" <martin.ehrlich@gmx.de> wrote in message
> news:OtwQNHb#EHA.2032@tk2msftngp13.phx.gbl...
>> 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
>>
>>
>>
>>
>



Relevant Pages

  • Re: Using User-Defined Data Type
    ... WebService" you essentially invalidate the proxy you created. ... The WSDL file is then used on the client for generating "Proxy ... just deal with "objects" in your code on both Server & Client side. ... >web reference defination and reference my document dll file, ...
    (microsoft.public.dotnet.framework.webservices)
  • How to create virtual webservices?
    ... I want to create a servlet or something similar by which im able to create ... Lets say i would like to create a webservice with a method called 'getDate' ... i mean that i will create the wsdl file dynamically, ... client makes a request on my method. ...
    (comp.lang.java)
  • Re: Basic question about C# Web Services
    ... When you create a .NET webservice and set a Webreference to it from a client application, it uses the webservice - generated WSDL contract to create a client proxy class to make webmethod calls to the service. ... operate without a wsdl file, but that doesnt realy make sense to me. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Using the .NET WebService tools
    ... the XSD.exe tool can be used to help map between .NET classes and XML files. ... A WSDL file is a definition of a webservices interface. ... that the webservice accepts and returns. ... the WSDL file can reference an external Schema (a separate XSD file) ...
    (microsoft.public.dotnet.framework.aspnet.webservices)
  • Re: Using the .NET WebService tools
    ... This appears to be an excerpt from a client-side proxy class. ... client-side proxy class into a server-side webservice. ... If you want to generate a service from a WSDL file, ... > Public Function ...
    (microsoft.public.dotnet.framework.aspnet.webservices)

Loading