473,399 Members | 2,774 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,399 software developers and data experts.

Sharing Types between Webservice and Client

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


Nov 23 '05 #1
4 2555
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.

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

Nov 23 '05 #2
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" <ma************@gmx.de> wrote in message
news:Ot**************@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


Nov 23 '05 #3
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]" <st***********@mvps.org> schrieb im Newsbeitrag
news:eO****************@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" <ma************@gmx.de> wrote in message
news:Ot**************@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

Nov 23 '05 #4

check out Schema Importer Extensions, in 2005 (.net 2.0). It's what you
need.

--
andreimatei
------------------------------------------------------------------------
Posted via http://www.mcse.ms
------------------------------------------------------------------------
View this thread: http://www.mcse.ms/message1348707.html

Apr 3 '06 #5

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

Similar topics

6
by: Davie | last post by:
I want to authorise a user of a web service by using the AuthHeaderValue for some reason I keep getting a null reference exception when I try to run the following code: It seems to work fine on a...
4
by: HG | last post by:
Hi gurus Sorry the rather long post... I am facing a real world problem here, and I dunno how to approach it. Don't even know if this is the right group...but since my app is ASP.NET I tried...
0
by: George Bool | last post by:
Hello, I have a simple webservice that accepts a network credential as an argument to a webmethod. When i create a proxy for my client to use, the proxy generator then recreates a new type ...
7
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i don´t want to filter the return value of the method, i have to pass a new instance of the...
6
by: Moshe Kravchik | last post by:
Hi all! I have 2 web services, one writtenin C++ (ATL) and another one in C#. Is there a way to define data stuctures in a single place both services could use? The structures are the same, but if...
10
by: Chris | last post by:
Hi, I'm new to web services and I'm having some trouble figuring out how to define a custom object that works through the webservice. For example, I have the following on the server side: ...
1
by: louis_la_brocante | last post by:
Dear all, I am having trouble generating a client proxy for a webservice whose methods return a "complex" type. The type is complex in that it is a class whose members are a mix of primitive...
0
by: Daniel P. | last post by:
http://danutp.blogspot.com/ Web Services - sharing data between client and server Dealing a lot with web services a friend of mine (Ehsan Samani) and I ran into another issue: when we move...
0
by: shaily | last post by:
hi I have a java web service called "Registration service" and C# client which is a consumer of that service java web service running under Tomcat has following interface API exposed ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.