pass business object to a web service

ivanp

New member
Joined
May 23, 2008
Messages
3
Location
Belgrade
Programming Experience
3-5
Is it possible to pass business objest (business class) to a web service.

I need my business classes or dll's to be on client side, but to execute them on web server side.
 
You have to define the class in the service, and use the service proxy definition from client.
 
sample webservice:
VB.NET:
Public Class myone
    Public name As String
End Class

<WebMethod()> _
Public Function Hello() As myone
    Dim x As New myone
    x.name = "hello"
    Return x
End Function
sample client:
VB.NET:
Dim client As New servicereference.Service
Dim webobject As servicereference.myone = client.Hello()
msgbox(webobject.name)
You can of course separate the webservice message interface and data business object layers. By referencing the same class library in service and client you can serialize the data business object and transfer it as a byte array via the webservice message object.
 
Thanks for sample, but I don’t think you understand me.
What you send me is a classic execution of web method from client side.
I need a business class on client side, and then call web method from client which would assume (or whatever) that object and execute it. Something like delegate, but I’m not sure.

I need a web method that would dynamically execute defined class that client have sent. So I need to pass class as a parameter or something.
Concept would be like this:

VB.NET:
<WebMethod> _
    Public Sub ExecuteObjectMethod(ByVal MyBusiness As business) 
        Try

           'execute MyBusiness

            Return True

        Catch ex As Exception
            sPoruka = ex.ToString
        End Try
    End Function
 
Only methods can be "executed", not class objects. No, I don't understand what you mean.
If you meant a custom type parameter for a web method, then this type has to be a service defined type.
 
Back
Top