Passing objects with web services

Discussion in 'ASP .Net' started by ThatsIT.net.au, Aug 20, 2009.

  1. I have a object that I want to pass back though a web service to the
    consumer. when I do this i get the object but can not see any methods. the
    object is decleared in the webservice as PublicUser, in the consuming web
    site PublicUser comes up in intellisence so i know that it must be comming
    though ok, but I can not access its methods.

    Am i missing something any ideas?
    ThatsIT.net.au, Aug 20, 2009
    #1
    1. Advertising

  2. ThatsIT.net.au

    Peter K Guest

    "ThatsIT.net.au" <me@work> skrev i en meddelelse
    news:...
    >I have a object that I want to pass back though a web service to the
    >consumer. when I do this i get the object but can not see any methods. the
    >object is decleared in the webservice as PublicUser, in the consuming web
    >site PublicUser comes up in intellisence so i know that it must be comming
    >though ok, but I can not access its methods.
    >
    > Am i missing something any ideas?


    Hard to say what your problem could be. Are the properties in your custom
    class public?

    This is a nice little intro to passing custom objects from a webservice:
    http://www.dalepreston.com/Blog/2005/02/returning-custom-classes-from-web.html


    /Peter
    Peter K, Aug 20, 2009
    #2
    1. Advertising

  3. "Peter K" <> wrote in message
    news:%...
    >
    > "ThatsIT.net.au" <me@work> skrev i en meddelelse
    > news:...
    >>I have a object that I want to pass back though a web service to the
    >>consumer. when I do this i get the object but can not see any methods. the
    >>object is decleared in the webservice as PublicUser, in the consuming web
    >>site PublicUser comes up in intellisence so i know that it must be comming
    >>though ok, but I can not access its methods.
    >>
    >> Am i missing something any ideas?

    >
    > Hard to say what your problem could be. Are the properties in your custom
    > class public?
    >


    yes they are


    > This is a nice little intro to passing custom objects from a webservice:
    > http://www.dalepreston.com/Blog/2005/02/returning-custom-classes-from-web.html
    >


    having a read but no luck so far



    >
    > /Peter
    >
    ThatsIT.net.au, Aug 20, 2009
    #3
  4. ThatsIT.net.au

    Peter K Guest

    "Mark Rae [MVP]" <> skrev i en meddelelse
    news:%...
    > "ThatsIT.net.au" <me@work> wrote in message
    > news:...
    >
    >>> "ThatsIT.net.au" <me@work> skrev i en meddelelse
    >>> news:...
    >>>>I have a object that I want to pass back though a web service to the
    >>>>consumer. when I do this i get the object but can not see any methods.
    >>>>the object is decleared in the webservice as PublicUser, in the
    >>>>consuming web site PublicUser comes up in intellisence so i know that it
    >>>>must be comming though ok, but I can not access its methods.
    >>>>
    >>>> Am i missing something any ideas?
    >>>
    >>> Hard to say what your problem could be. Are the properties in your
    >>> custom class public?

    >>
    >> yes they are

    >
    >
    > Are you casting the deserialised object back to a PublicUser...?


    The times I've written consumers of webservices, this has not been
    necessary. I use Visual Studio to create the appropriate proxy, and the
    generated class can simply be used by my consumer.

    For example, in Visual Studio, I create a "web reference" to the webservice
    at http://somewebservice.asmx,

    Then in code I can do something like:

    SomeWebServiceRef.WebServiceName ws = new
    SomeWebServiceRef.WebServiceName();
    SomeWebServiceRef.MyCustomClass result = ws.GetTheResult(123);


    /Peter
    Peter K, Aug 20, 2009
    #4
  5. ThatsIT.net.au

    Peter K Guest

    "Mark Rae [MVP]" <> skrev i en meddelelse
    news:...
    > "Peter K" <> wrote in message
    > news:...
    >
    >>> Are you casting the deserialised object back to a PublicUser...?

    >>
    >> The times I've written consumers of webservices, this has not been
    >> necessary. I use Visual Studio to create the appropriate proxy, and the
    >> generated class can simply be used by my consumer.

    >
    > Indulge me...
    >
    >> SomeWebServiceRef.WebServiceName ws = new
    >> SomeWebServiceRef.WebServiceName();
    >> SomeWebServiceRef.MyCustomClass result = ws.GetTheResult(123);

    >
    > Before running those three lines, what does
    > was.GetTheResult(123).GetType(); reveal...?


    One can see that the type is for example "SomeWebServiceRef.MyCustomClass".
    This type is generated by Visual Studio as part of the proxy-generation
    process - and the class can be found in the generated "Reference.cs".

    I'm not quite sure where your line of questioning is headed (and I know you
    are aware of all this and a whole lot more). I simply use the tools provided
    by Visual Studio, and I don't have to worry about casting any results from
    calls to web-methods - all the deserialisation/casting is handled by the
    code generated by Visual Studio.

    If the OP uses Visual Studio to make a web-reference to his web-service then
    he'll be able to use a class called something like
    webRef.PublicUser. Perhaps if the OP posted a real small example showing his
    web-service code, and the client code, then it would be easier to find out
    what the problem could be.
    Peter K, Aug 20, 2009
    #5
  6. ThatsIT.net.au

    Jeff Johnson Guest

    "ThatsIT.net.au" <me@work> wrote in message
    news:...

    >I have a object that I want to pass back though a web service to the
    >consumer. when I do this i get the object but can not see any methods. the
    >object is decleared in the webservice as PublicUser, in the consuming web
    >site PublicUser comes up in intellisence so i know that it must be comming
    >though ok, but I can not access its methods.
    >
    > Am i missing something any ideas?


    [Apologies if I'm telling you something you already know.]

    Web services create proxy classes to pass objects. These proxy classes only
    have properties, no methods. You have to convert your custom class to a
    proxy class before sending and, in the other direction, you have to convert
    the received proxy object to an instance of your actual custom class. Only
    when dealing with an instance of the original class will you see the methods
    that class provides. This not only means that the afore-mentioned conversion
    is necessary, but also that the client needs the custom class definition
    (i.e., the client must have some assembly with that class definition in it).

    Is it possible you're dealing with a proxy class and not the original? If
    so, that's why you don't see methods.
    Jeff Johnson, Aug 20, 2009
    #6
  7. "Mark Rae [MVP]" <> wrote in message
    news:%...
    > "ThatsIT.net.au" <me@work> wrote in message
    > news:...
    >
    >>> "ThatsIT.net.au" <me@work> skrev i en meddelelse
    >>> news:...
    >>>>I have a object that I want to pass back though a web service to the
    >>>>consumer. when I do this i get the object but can not see any methods.
    >>>>the object is decleared in the webservice as PublicUser, in the
    >>>>consuming web site PublicUser comes up in intellisence so i know that it
    >>>>must be comming though ok, but I can not access its methods.
    >>>>
    >>>> Am i missing something any ideas?
    >>>
    >>> Hard to say what your problem could be. Are the properties in your
    >>> custom class public?

    >>
    >> yes they are

    >
    >
    > Are you casting the deserialised object back to a PublicUser...?
    >



    yes i tried that

    when you say deserialised am I suposed to deserialise it manulay, i have
    tried to serlizing the webservice made no difference, I tried to serialise
    the method but it errored


    >
    > --
    > Mark Rae
    > ASP.NET MVP
    > http://www.markrae.net
    ThatsIT.net.au, Aug 20, 2009
    #7
  8. "Peter K" <> wrote in message
    news:...
    >
    > "Mark Rae [MVP]" <> skrev i en meddelelse
    > news:%...
    >> "ThatsIT.net.au" <me@work> wrote in message
    >> news:...
    >>
    >>>> "ThatsIT.net.au" <me@work> skrev i en meddelelse
    >>>> news:...
    >>>>>I have a object that I want to pass back though a web service to the
    >>>>>consumer. when I do this i get the object but can not see any methods.
    >>>>>the object is decleared in the webservice as PublicUser, in the
    >>>>>consuming web site PublicUser comes up in intellisence so i know that
    >>>>>it must be comming though ok, but I can not access its methods.
    >>>>>
    >>>>> Am i missing something any ideas?
    >>>>
    >>>> Hard to say what your problem could be. Are the properties in your
    >>>> custom class public?
    >>>
    >>> yes they are

    >>
    >>
    >> Are you casting the deserialised object back to a PublicUser...?

    >
    > The times I've written consumers of webservices, this has not been
    > necessary. I use Visual Studio to create the appropriate proxy, and the
    > generated class can simply be used by my consumer.
    >
    > For example, in Visual Studio, I create a "web reference" to the
    > webservice at http://somewebservice.asmx,
    >
    > Then in code I can do something like:
    >
    > SomeWebServiceRef.WebServiceName ws = new
    > SomeWebServiceRef.WebServiceName();
    > SomeWebServiceRef.MyCustomClass result = ws.GetTheResult(123);
    >
    >
    > /Peter
    >
    >


    that looks the same


    Dim w As WebUser = New WebUser
    Dim oUser As PublicUser = CType(w.getUser, PublicUser)
    Response.Write(oUser.www)

    www is a method, but it gives an error saying www is not a method of oUser,
    by the way I can access www in the web service, so object is correct at that
    point.


    webService below




    <System.Web.Script.Services.ScriptService()> _
    <System.Web.Services.WebService(Namespace:="http://thatsbooking.com.au/WebUser")>
    _
    <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
    _
    <Serializable()> _
    <ToolboxItem(False)> _
    Public Class WebUser
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As String
    Return "Hello World"
    End Function
    <WebMethod()> _
    Public Function getUser() As TBBO.PublicUser
    Dim u As TBBO.PublicUser = New TBBO.PublicUser
    Return u
    End Function

    Public Sub New()

    End Sub
    End Class
    ThatsIT.net.au, Aug 20, 2009
    #8
  9. "Peter K" <> wrote in message
    news:...
    > "Mark Rae [MVP]" <> skrev i en meddelelse
    > news:...
    >> "Peter K" <> wrote in message
    >> news:...
    >>
    >>>> Are you casting the deserialised object back to a PublicUser...?
    >>>
    >>> The times I've written consumers of webservices, this has not been
    >>> necessary. I use Visual Studio to create the appropriate proxy, and the
    >>> generated class can simply be used by my consumer.

    >>
    >> Indulge me...
    >>
    >>> SomeWebServiceRef.WebServiceName ws = new
    >>> SomeWebServiceRef.WebServiceName();
    >>> SomeWebServiceRef.MyCustomClass result = ws.GetTheResult(123);

    >>
    >> Before running those three lines, what does
    >> was.GetTheResult(123).GetType(); reveal...?

    >
    > One can see that the type is for example
    > "SomeWebServiceRef.MyCustomClass". This type is generated by Visual Studio
    > as part of the proxy-generation process - and the class can be found in
    > the generated "Reference.cs".
    >
    > I'm not quite sure where your line of questioning is headed (and I know
    > you are aware of all this and a whole lot more). I simply use the tools
    > provided by Visual Studio, and I don't have to worry about casting any
    > results from calls to web-methods - all the deserialisation/casting is
    > handled by the code generated by Visual Studio.
    >
    > If the OP uses Visual Studio to make a web-reference to his web-service
    > then he'll be able to use a class called something like
    > webRef.PublicUser. Perhaps if the OP posted a real small example showing
    > his web-service code, and the client code, then it would be easier to find
    > out what the problem could be.
    >



    just posted them in previous post.

    I am using visual studio 2008 to create reference and to create web service.
    ThatsIT.net.au, Aug 20, 2009
    #9
  10. "Jeff Johnson" <> wrote in message
    news:...
    > "ThatsIT.net.au" <me@work> wrote in message
    > news:...
    >
    >>I have a object that I want to pass back though a web service to the
    >>consumer. when I do this i get the object but can not see any methods. the
    >>object is decleared in the webservice as PublicUser, in the consuming web
    >>site PublicUser comes up in intellisence so i know that it must be comming
    >>though ok, but I can not access its methods.
    >>
    >> Am i missing something any ideas?

    >
    > [Apologies if I'm telling you something you already know.]
    >
    > Web services create proxy classes to pass objects. These proxy classes
    > only have properties, no methods. You have to convert your custom class to
    > a proxy class before sending and, in the other direction, you have to
    > convert the received proxy object to an instance of your actual custom
    > class. Only when dealing with an instance of the original class will you
    > see the methods that class provides. This not only means that the
    > afore-mentioned conversion is necessary, but also that the client needs
    > the custom class definition (i.e., the client must have some assembly with
    > that class definition in it).
    >
    > Is it possible you're dealing with a proxy class and not the original? If
    > so, that's why you don't see methods.



    I have not converted to a proxy class as far as I know, unless this is done
    by visual studio.
    How do I find out?
    ThatsIT.net.au, Aug 20, 2009
    #10
  11. ThatsIT.net.au

    Mr. Arnold Guest

    "ThatsIT.net.au" <me@work> wrote in message
    news:...
    >I have a object that I want to pass back though a web service to the
    >consumer. when I do this i get the object but can not see any methods. the
    >object is decleared in the webservice as PublicUser, in the consuming web
    >site PublicUser comes up in intellisence so i know that it must be comming
    >though ok, but I can not access its methods.


    When you pass an object like that back from the Web service, the methods are
    left behind, and you only have access to public properties of the object on
    the client side.

    You have to serialize the object on the Web service side and pass back an
    XML serialized object to the client.

    You have to deserialize the XML serialize object and cast it back to
    PublicUser on the client side. You will then have the data in the
    PublicUser, and you can then access any public properties and methods of the
    object at that time, on the client side.

    PublicUser.vb must be a file in the Web service project, and it must be a
    file in the client project, so that you can serialize, deserialize and cast
    back to the object.

    The Web service method is going to return 'string', since a XML serialized
    object is 'string' when it's serialized.



    __________ Information from ESET NOD32 Antivirus, version of virus signature database 4353 (20090820) __________

    The message was checked by ESET NOD32 Antivirus.

    http://www.eset.com
    Mr. Arnold, Aug 21, 2009
    #11
  12. ThatsIT.net.au

    Peter K Guest

    "ThatsIT.net.au" <me@work> skrev i en meddelelse
    news:...
    >>>>> Hard to say what your problem could be. Are the properties in your
    >>>>> custom class public?
    >>>>
    >>>> yes they are
    >>>
    >>> Are you casting the deserialised object back to a PublicUser...?

    >>
    >> The times I've written consumers of webservices, this has not been
    >> necessary. I use Visual Studio to create the appropriate proxy, and the
    >> generated class can simply be used by my consumer.
    >>
    >> For example, in Visual Studio, I create a "web reference" to the
    >> webservice at http://somewebservice.asmx,
    >>
    >> Then in code I can do something like:
    >>
    >> SomeWebServiceRef.WebServiceName ws = new
    >> SomeWebServiceRef.WebServiceName();
    >> SomeWebServiceRef.MyCustomClass result = ws.GetTheResult(123);

    >
    > that looks the same
    >
    > Dim w As WebUser = New WebUser
    > Dim oUser As PublicUser = CType(w.getUser, PublicUser)
    > Response.Write(oUser.www)
    >
    > www is a method, but it gives an error saying www is not a method of
    > oUser, by the way I can access www in the web service, so object is
    > correct at that point.


    When you say "method" do you really mean method, or do you mean "property".
    As far as I am aware, you cannot pass a class'es methods via a webservice -
    only the propeties (ie getters and setters) will be passed. Usually I only
    use simple "data" objects (I think they can also be termed "DTO"s) which
    only have data - no functionality as such.

    > <System.Web.Script.Services.ScriptService()> _
    > <System.Web.Services.WebService(Namespace:="http://thatsbooking.com.au/WebUser")>
    > _
    > <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
    > _
    > <Serializable()> _
    > <ToolboxItem(False)> _
    > Public Class WebUser
    > Inherits System.Web.Services.WebService
    >
    > <WebMethod()> _
    > Public Function HelloWorld() As String
    > Return "Hello World"
    > End Function
    > <WebMethod()> _
    > Public Function getUser() As TBBO.PublicUser
    > Dim u As TBBO.PublicUser = New TBBO.PublicUser
    > Return u
    > End Function
    >
    > Public Sub New()
    >
    > End Sub
    > End Class



    What about your PublicUser class, and your client. Sometimes it can be
    helpful to quickly create a little ConsoleApp to act as a test client for
    your webservice.
    Peter K, Aug 21, 2009
    #12
  13. ThatsIT.net.au

    Peter K Guest

    "ThatsIT.net.au" <me@work> skrev i en meddelelse
    news:...
    >
    > "Jeff Johnson" <> wrote in message
    > news:...
    >> Is it possible you're dealing with a proxy class and not the original? If
    >> so, that's why you don't see methods.

    >
    > I have not converted to a proxy class as far as I know, unless this is
    > done by visual studio.


    If, in your consumer/client, you have used Visual Studio to create a "web
    reference" to your web-service, then yes. Visual Studio will have created a
    proxy for your client - and will perform the necessary deserialisation and
    casting so the client can simply use PublicUser. This is not the same
    "PublicUser" as your web-service uses, it is a new class (with the same
    name) that your client uses.

    I normally do it like that - because it is so easy.

    You can find the visual studio generated code somewhere in your client
    solution. With c# it will be called Reference.cs, and here you can find a
    class called PublicUser.

    I usually try to keep web-services and any clients separated in their own
    solutions so I don't get confused about which class really belongs where.
    Peter K, Aug 21, 2009
    #13
  14. "Mr. Arnold" <MR. > wrote in message
    news:%...
    >
    > "ThatsIT.net.au" <me@work> wrote in message
    > news:...
    >>I have a object that I want to pass back though a web service to the
    >>consumer. when I do this i get the object but can not see any methods. the
    >>object is decleared in the webservice as PublicUser, in the consuming web
    >>site PublicUser comes up in intellisence so i know that it must be comming
    >>though ok, but I can not access its methods.

    >
    > When you pass an object like that back from the Web service, the methods
    > are left behind, and you only have access to public properties of the
    > object on the client side.
    >
    > You have to serialize the object on the Web service side and pass back an
    > XML serialized object to the client.


    do you mean to mark it serlizable
    or somthing like this

    Private Function Serialize(ByVal obj As Object) As Byte()
    Dim binaryFormatter As BinaryFormatter = New BinaryFormatter()
    Dim memoryStream As MemoryStream = New MemoryStream()
    binaryFormatter.Serialize(memoryStream, obj)
    Return memoryStream.ToArray()
    End Function


    >
    > You have to deserialize the XML serialize object and cast it back to
    > PublicUser on the client side. You will then have the data in the
    > PublicUser, and you can then access any public properties and methods of
    > the object at that time, on the client side.



    so the PublicUser classi get from the WS for casting the XML back to object,
    that explains a lot, I could not understand why i got a PublicUser back at
    all.




    >
    > PublicUser.vb must be a file in the Web service project, and it must be a
    > file in the client project, so that you can serialize, deserialize and
    > cast back to the object.


    Yes i do
    PublicUser.vb
    PublicUser.asmx

    >
    > The Web service method is going to return 'string', since a XML serialized
    > object is 'string' when it's serialized.


    then i have the wrong Idea on how to serlize it.
    the code i have above returns byte()

    do you have a example?

    Thanks for your help.

    dont go too far I have a few questions on WS authentication later.



    >
    >
    >
    > __________ Information from ESET NOD32 Antivirus, version of virus
    > signature database 4353 (20090820) __________
    >
    > The message was checked by ESET NOD32 Antivirus.
    >
    > http://www.eset.com
    >
    >
    >
    ThatsIT.net.au, Aug 21, 2009
    #14
  15. "Peter K" <> wrote in message
    news:eN$...
    > "ThatsIT.net.au" <me@work> skrev i en meddelelse
    > news:...
    >>
    >> "Jeff Johnson" <> wrote in message
    >> news:...
    >>> Is it possible you're dealing with a proxy class and not the original?
    >>> If so, that's why you don't see methods.

    >>
    >> I have not converted to a proxy class as far as I know, unless this is
    >> done by visual studio.

    >
    > If, in your consumer/client, you have used Visual Studio to create a "web
    > reference" to your web-service, then yes. Visual Studio will have created
    > a proxy for your client - and will perform the necessary deserialisation
    > and casting so the client can simply use PublicUser. This is not the same
    > "PublicUser" as your web-service uses, it is a new class (with the same
    > name) that your client uses.
    >
    > I normally do it like that - because it is so easy.
    >
    > You can find the visual studio generated code somewhere in your client
    > solution. With c# it will be called Reference.cs, and here you can find a
    > class called PublicUser.
    >
    > I usually try to keep web-services and any clients separated in their own
    > solutions so I don't get confused about which class really belongs where.
    >
    >



    That's how I have done it, I'm using vb, but yes I Have the Reference.vb
    file and I can see PublicUser in it, I also have a PublicUser.data file

    But I still don't have the methods or properties
    ThatsIT.net.au, Aug 21, 2009
    #15
  16. "Peter K" <> wrote in message
    news:...
    > "ThatsIT.net.au" <me@work> skrev i en meddelelse
    > news:...
    >>>>>> Hard to say what your problem could be. Are the properties in your
    >>>>>> custom class public?
    >>>>>
    >>>>> yes they are
    >>>>
    >>>> Are you casting the deserialised object back to a PublicUser...?
    >>>
    >>> The times I've written consumers of webservices, this has not been
    >>> necessary. I use Visual Studio to create the appropriate proxy, and the
    >>> generated class can simply be used by my consumer.
    >>>
    >>> For example, in Visual Studio, I create a "web reference" to the
    >>> webservice at http://somewebservice.asmx,
    >>>
    >>> Then in code I can do something like:
    >>>
    >>> SomeWebServiceRef.WebServiceName ws = new
    >>> SomeWebServiceRef.WebServiceName();
    >>> SomeWebServiceRef.MyCustomClass result = ws.GetTheResult(123);

    >>
    >> that looks the same
    >>
    >> Dim w As WebUser = New WebUser
    >> Dim oUser As PublicUser = CType(w.getUser, PublicUser)
    >> Response.Write(oUser.www)
    >>
    >> www is a method, but it gives an error saying www is not a method of
    >> oUser, by the way I can access www in the web service, so object is
    >> correct at that point.

    >
    > When you say "method" do you really mean method, or do you mean
    > "property". As far as I am aware, you cannot pass a class'es methods via a
    > webservice - only the propeties (ie getters and setters) will be passed.
    > Usually I only use simple "data" objects (I think they can also be termed
    > "DTO"s) which only have data - no functionality as such.


    Yes I do Mean methods, but I have tried with properties also.



    >
    >> <System.Web.Script.Services.ScriptService()> _
    >> <System.Web.Services.WebService(Namespace:="http://thatsbooking.com.au/WebUser")>
    >> _
    >> <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
    >> _
    >> <Serializable()> _
    >> <ToolboxItem(False)> _
    >> Public Class WebUser
    >> Inherits System.Web.Services.WebService
    >>
    >> <WebMethod()> _
    >> Public Function HelloWorld() As String
    >> Return "Hello World"
    >> End Function
    >> <WebMethod()> _
    >> Public Function getUser() As TBBO.PublicUser
    >> Dim u As TBBO.PublicUser = New TBBO.PublicUser
    >> Return u
    >> End Function
    >>
    >> Public Sub New()
    >>
    >> End Sub
    >> End Class

    >
    >
    > What about your PublicUser class, and your client. Sometimes it can be
    > helpful to quickly create a little ConsoleApp to act as a test client for
    > your webservice.
    >
    ThatsIT.net.au, Aug 21, 2009
    #16
  17. ThatsIT.net.au

    Peter K Guest

    "Mr. Arnold" <MR. > skrev i en meddelelse
    news:%...
    >
    > "ThatsIT.net.au" <me@work> wrote in message
    > news:...
    >>I have a object that I want to pass back though a web service to the
    >>consumer. when I do this i get the object but can not see any methods. the
    >>object is decleared in the webservice as PublicUser, in the consuming web
    >>site PublicUser comes up in intellisence so i know that it must be comming
    >>though ok, but I can not access its methods.

    >
    > When you pass an object like that back from the Web service, the methods
    > are left behind, and you only have access to public properties of the
    > object on the client side.
    >
    > You have to serialize the object on the Web service side and pass back an
    > XML serialized object to the client.


    But aren't the details of this normally handled by code automatically
    generated by Visual Studio for example?

    (I've only had to manually serialise some data in a WCF service we were
    developing for .net <-> .net applications).

    At least as far as simple web-services go, I've let VS handle all the hard
    stuff for me.


    > You have to deserialize the XML serialize object and cast it back to
    > PublicUser on the client side. You will then have the data in the
    > PublicUser, and you can then access any public properties and methods of
    > the object at that time, on the client side.


    Again, it appears to me that Visual Studio automatically generates the code
    that handles this. Doesn't it? I'd be the first to admit I could be
    completely wrong, and have just been incredibly lucky with the few simple
    web-services I've written over the last few years - but for me, at least,
    I've let Visual Studio do all this, and I simply call the generated proxy
    and use the "PublicUser" object.

    I also always thought one couldn't actually send "methods" of a custom
    object via a webservice. I thought it was only possible to send "properties"
    (or data). I've really only had success with that anyway. Guess I'll do a
    little more digging myself.
    Peter K, Aug 21, 2009
    #17
  18. "Peter K" <> wrote in message
    news:uBcf$...
    >
    > "Mr. Arnold" <MR. > skrev i en meddelelse
    > news:%...
    >>
    >> "ThatsIT.net.au" <me@work> wrote in message
    >> news:...
    >>>I have a object that I want to pass back though a web service to the
    >>>consumer. when I do this i get the object but can not see any methods.
    >>>the object is decleared in the webservice as PublicUser, in the consuming
    >>>web site PublicUser comes up in intellisence so i know that it must be
    >>>comming though ok, but I can not access its methods.

    >>
    >> When you pass an object like that back from the Web service, the methods
    >> are left behind, and you only have access to public properties of the
    >> object on the client side.
    >>
    >> You have to serialize the object on the Web service side and pass back an
    >> XML serialized object to the client.

    >
    > But aren't the details of this normally handled by code automatically
    > generated by Visual Studio for example?
    >
    > (I've only had to manually serialise some data in a WCF service we were
    > developing for .net <-> .net applications).
    >
    > At least as far as simple web-services go, I've let VS handle all the hard
    > stuff for me.
    >
    >
    >> You have to deserialize the XML serialize object and cast it back to
    >> PublicUser on the client side. You will then have the data in the
    >> PublicUser, and you can then access any public properties and methods of
    >> the object at that time, on the client side.

    >
    > Again, it appears to me that Visual Studio automatically generates the
    > code that handles this. Doesn't it? I'd be the first to admit I could be
    > completely wrong, and have just been incredibly lucky with the few simple
    > web-services I've written over the last few years - but for me, at least,
    > I've let Visual Studio do all this, and I simply call the generated proxy
    > and use the "PublicUser" object.


    it looks that way to me in the code in Reference.vb

    <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml",
    "2.0.50727.4016"), _
    System.SerializableAttribute(), _
    System.Diagnostics.DebuggerStepThroughAttribute(), _
    System.ComponentModel.DesignerCategoryAttribute("code"), _
    System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://blah
    blah/WebUser")> _
    Partial Public Class PublicUser
    Inherits Person
    End Class


    >
    > I also always thought one couldn't actually send "methods" of a custom
    > object via a webservice. I thought it was only possible to send
    > "properties" (or data). I've really only had success with that anyway.
    > Guess I'll do a little more digging myself.
    >
    >
    ThatsIT.net.au, Aug 21, 2009
    #18
  19. ThatsIT.net.au

    Peter K Guest

    "ThatsIT.net.au" <me@work> skrev i en meddelelse
    news:...
    >
    > "Peter K" <> wrote in message
    > news:uBcf$...
    >>
    >> "Mr. Arnold" <MR. > skrev i en meddelelse
    >> news:%...
    >>>
    >>> "ThatsIT.net.au" <me@work> wrote in message
    >>> news:...
    >>>>I have a object that I want to pass back though a web service to the
    >>>>consumer. when I do this i get the object but can not see any methods.
    >>>>the object is decleared in the webservice as PublicUser, in the
    >>>>consuming web site PublicUser comes up in intellisence so i know that it
    >>>>must be comming though ok, but I can not access its methods.
    >>>
    >>> When you pass an object like that back from the Web service, the methods
    >>> are left behind, and you only have access to public properties of the
    >>> object on the client side.
    >>>
    >>> You have to serialize the object on the Web service side and pass back
    >>> an XML serialized object to the client.

    >>
    >> But aren't the details of this normally handled by code automatically
    >> generated by Visual Studio for example?
    >>
    >> (I've only had to manually serialise some data in a WCF service we were
    >> developing for .net <-> .net applications).
    >>
    >> At least as far as simple web-services go, I've let VS handle all the
    >> hard stuff for me.
    >>
    >>
    >>> You have to deserialize the XML serialize object and cast it back to
    >>> PublicUser on the client side. You will then have the data in the
    >>> PublicUser, and you can then access any public properties and methods of
    >>> the object at that time, on the client side.

    >>
    >> Again, it appears to me that Visual Studio automatically generates the
    >> code that handles this. Doesn't it? I'd be the first to admit I could be
    >> completely wrong, and have just been incredibly lucky with the few simple
    >> web-services I've written over the last few years - but for me, at least,
    >> I've let Visual Studio do all this, and I simply call the generated proxy
    >> and use the "PublicUser" object.

    >
    > it looks that way to me in the code in Reference.vb
    >
    > <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml",
    > "2.0.50727.4016"), _
    > System.SerializableAttribute(), _
    > System.Diagnostics.DebuggerStepThroughAttribute(), _
    > System.ComponentModel.DesignerCategoryAttribute("code"), _
    > System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://blah
    > blah/WebUser")> _
    > Partial Public Class PublicUser
    > Inherits Person
    > End Class


    Well it is obvious the PublicUser class has no properties or methods - and
    it appears it descends from a class called Person. You need to ensure that
    the Person class is also serialised so your client knows about it. Is there
    a Person class in the Reference.vb code?
    Peter K, Aug 21, 2009
    #19
  20. If I should get this object to work, what can this object do, do I have to
    pass it back to the web service to get changes or is it somehow connected?
    will I be able to some how contact database thought object?

    Thanks


    "ThatsIT.net.au" <me@work> wrote in message
    news:...
    >
    > "Peter K" <> wrote in message
    > news:uBcf$...
    >>
    >> "Mr. Arnold" <MR. > skrev i en meddelelse
    >> news:%...
    >>>
    >>> "ThatsIT.net.au" <me@work> wrote in message
    >>> news:...
    >>>>I have a object that I want to pass back though a web service to the
    >>>>consumer. when I do this i get the object but can not see any methods.
    >>>>the object is decleared in the webservice as PublicUser, in the
    >>>>consuming web site PublicUser comes up in intellisence so i know that it
    >>>>must be comming though ok, but I can not access its methods.
    >>>
    >>> When you pass an object like that back from the Web service, the methods
    >>> are left behind, and you only have access to public properties of the
    >>> object on the client side.
    >>>
    >>> You have to serialize the object on the Web service side and pass back
    >>> an XML serialized object to the client.

    >>
    >> But aren't the details of this normally handled by code automatically
    >> generated by Visual Studio for example?
    >>
    >> (I've only had to manually serialise some data in a WCF service we were
    >> developing for .net <-> .net applications).
    >>
    >> At least as far as simple web-services go, I've let VS handle all the
    >> hard stuff for me.
    >>
    >>
    >>> You have to deserialize the XML serialize object and cast it back to
    >>> PublicUser on the client side. You will then have the data in the
    >>> PublicUser, and you can then access any public properties and methods of
    >>> the object at that time, on the client side.

    >>
    >> Again, it appears to me that Visual Studio automatically generates the
    >> code that handles this. Doesn't it? I'd be the first to admit I could be
    >> completely wrong, and have just been incredibly lucky with the few simple
    >> web-services I've written over the last few years - but for me, at least,
    >> I've let Visual Studio do all this, and I simply call the generated proxy
    >> and use the "PublicUser" object.

    >
    > it looks that way to me in the code in Reference.vb
    >
    > <System.CodeDom.Compiler.GeneratedCodeAttribute("System.Xml",
    > "2.0.50727.4016"), _
    > System.SerializableAttribute(), _
    > System.Diagnostics.DebuggerStepThroughAttribute(), _
    > System.ComponentModel.DesignerCategoryAttribute("code"), _
    > System.Xml.Serialization.XmlTypeAttribute([Namespace]:="http://blah
    > blah/WebUser")> _
    > Partial Public Class PublicUser
    > Inherits Person
    > End Class
    >
    >
    >>
    >> I also always thought one couldn't actually send "methods" of a custom
    >> object via a webservice. I thought it was only possible to send
    >> "properties" (or data). I've really only had success with that anyway.
    >> Guess I'll do a little more digging myself.
    >>
    >>

    >
    ThatsIT.net.au, Aug 21, 2009
    #20
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Nick
    Replies:
    1
    Views:
    6,123
    Alvin Bruney - ASP.NET MVP
    Sep 12, 2005
  2. Anup
    Replies:
    1
    Views:
    2,779
    Mark Rae
    May 9, 2006
  3. imlakhani

    Web Services Restful Services

    imlakhani, Dec 16, 2009, in forum: Java
    Replies:
    1
    Views:
    419
    Jeffrey H. Coffield
    Dec 16, 2009
  4. Roshawn

    Passing custom objects in web services

    Roshawn, Oct 20, 2003, in forum: ASP .Net Web Services
    Replies:
    2
    Views:
    153
    Roshawn
    Oct 20, 2003
  5. John
    Replies:
    4
    Views:
    443
Loading...

Share This Page