Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > How to use own classes as WebMethod-Parameters?

Reply
Thread Tools

How to use own classes as WebMethod-Parameters?

 
 
Daniel Barisch
Guest
Posts: n/a
 
      08-19-2003
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


 
Reply With Quote
 
 
 
 
Simon Smith
Guest
Posts: n/a
 
      09-01-2003
"Daniel Barisch" <(E-Mail Removed)> wrote in message news:<#(E-Mail Removed)>...
> 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.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using own classloader inside J2EE to load and unload own classes. Stefan Siegl Java 1 07-02-2013 05:05 AM
Re: How include a large array? Edward A. Falk C Programming 1 04-04-2013 08:07 PM
Times where one would use new style classes vs classic classes Quek Python 3 07-03-2008 05:51 PM
I have built my own (simple) thread manager [TM], but just found java 5 has its own. Saverio M. Java 0 07-03-2006 08:52 AM
How do I use my own referenced classes in an asp.net page? Bodza Bodza ASP .Net 3 02-27-2004 10:58 AM



Advertisments