Ask a Question related to ASP.NET Web Services, Design and Development.
-
Daniel Barisch #1
How to use own classes as WebMethod-Parameters?
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
Daniel Barisch Guest
-
Mandatory WebMethod parameters
Hi, I have WebService (C#) with one WebMethod that takes 4 parameters, as below: <s:element minOccurs="0" maxOccurs="1" name="requestedBy"... -
WebMethod and WSDL with optional parameters
Hi If i have a simple web service lik [WebMethodAttribute() public string DoIt(string Name, int Age return "" and i look at the WSDL i get... -
Carriage Return in WebMethod parameters
Hi! I have this problem. I am sending as a parameter for a webmethod a string containing '\r\n' sequences. For some reason, when I debug my... -
create parameters without creating parameters
cant you create ado command parameteres without creating a parameter object? i have a function that takes the name of a stored proc, and two... -
exposing derived classes to proxy without fake webmethod?
Hi, try using on the appropriate WebMethod. This attribute instructs the ASMX engine to include the type description for type bla. Cheers, --... -
Simon Smith #2
Re: How to use own classes as WebMethod-Parameters?
"Daniel Barisch" <goblin.inc@gmx.de> wrote in message news:<#cLHo5lZDHA.1644@TK2MSFTNGP10.phx.gbl>...
<snip>> Is it possible to use self defined classes as parameters for a WebMethod? I
> thought of the following....
>
You're almost there. The Web Reference in the client has the code in a> 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
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.
Simon Smith Guest



Reply With Quote

