[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.dotnet.framework.aspnet.webservices

How to use own classes as WebMethod-Parameters?

Daniel Barisch

8/19/2003 3:30:00 PM

Is it possible to use self defined classes as parameters for a WebMethod? I
thought of the following....

1. Library-Project: "LibProj"

Public Class ParamClass
private ...
public ...
public sub addXY...
End Class

2. WebService-Project: "WSProj"
(Reference to "LibProj")

<WebService>
Public Class WServer
<WebMethod> _
Public function getSth( param as LibProj.ParamClass)....
end class

3. Client-Project: "ClientProj"
(Reference to "LibProj", WebReference to "WSProj" as "WSProjProxy")

public sub doSth
dim ws as new WSProjProxy.WServer()
dim pc as new LibProj.ParamClass()
msgbox ws.getSth( pc ) >> ERROR (Parameter "pc")
end sub


This does not work, because " 'LibProj.ParamClass' can't be converted to
'ClientProj.WSProjProxy.ParamClass' "

What is wrong with this code? Why suddenly the type of the
WebService-parameter switches from 'LibProj.ParamClass' (as defined in the
WebMethod) to 'WSProjProxy.ParamClass'?

Is there possibility to get this work?

Thanks, D.Barisch


1 Answer

simon.smith

9/1/2003 12:53:00 PM

0

"Daniel Barisch" <goblin.inc@gmx.de> wrote in message news:<#cLHo5lZDHA.1644@TK2MSFTNGP10.phx.gbl>...
> Is it possible to use self defined classes as parameters for a WebMethod? I
> thought of the following....
>

<snip>

> This does not work, because " 'LibProj.ParamClass' can't be converted to
> 'ClientProj.WSProjProxy.ParamClass' "
>
> What is wrong with this code? Why suddenly the type of the
> WebService-parameter switches from 'LibProj.ParamClass' (as defined in the
> WebMethod) to 'WSProjProxy.ParamClass'?
>
> Is there possibility to get this work?
>
> Thanks, D.Barisch

You're almost there. The Web Reference in the client has the code in a
file called Reference.cs - this is the proxy for the Web Service. In
that file is a definition of what your custom class looks like when
deserialised - all properties etc as public fields. This is the class
called WSProjProxy.ParamClass. Whjat you need to do is delete that
class and add a using LibProj to theis file. That will tell the
compiler to deserialise to you your custom class in LibProj, not the
'stub' generated.

HTH.