Expose method of class returned by web service

T

Toby Mathews

Hi there,

Could anyone tell me if it is possible to expose the methods of a class
returned by a web service. I have an instance of a class created something
like this:

MyWebService webSrv = new MyWebService();

MyWebService.MyClass myClass = webSrv.GetClass();

The definition for MyClass in my web service includes some methods, say
MyClass.Method(), but these aren't visible from the client consuming the web
service.

Any help much appreciated, thanks,

Toby Mathews
 
D

Dino Chiesa [Microsoft]

The class has to be known to the client. There must be an implementation of
the class on the client side, in the form of a DLL. It should be the same
impl as used on the server side. ie: it should be in a shared dLL.

You need to
1. use targetNameSpace attribute on the type you want to share across client
and server. compile this into a DLL - you need to deploy this on both
client and server.
2. when you "Add Web Reference" or generate the proxy with wsdl.exe, you
need to remove the generated types from the source code. Replace references
to the generated type(s) with the common type(s) from the DLL in step 1.
Each time you update the WSDL and re-generate the proxy, you have to do this
manual edit step.
3. compile the client and server, referencing the common DLL.

Here's an old blog entry on tihs:
http://hoppersoft.com/Andy/commentview.aspx?guid=ABAF08B3-1ABD-4DAE-BE05-23B733FF3C5D

and a sort-of related KB article
http://support.microsoft.com/default.aspx?scid=kb;en-us;326790


-Dino
 
M

Mohan

Hi,
What you're trying to achieve is workable; but the best
practise is not to have business functionality in the
object that you're receiving, rather it has to be a
container.
These will avoid having the proxy class as dll and client
just access the web services and make use of it
immediately rather than waiting for the dll.
Have a look at this it might help you.
http://msdn.microsoft.com/msdnmag/issues/02/12/WebServicesD
esign/
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top