Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Passing objects with web services

Reply
Thread Tools

Passing objects with web services

 
 
ThatsIT.net.au
Guest
Posts: n/a
 
      08-20-2009
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?

 
Reply With Quote
 
 
 
 
Peter K
Guest
Posts: n/a
 
      08-20-2009

"ThatsIT.net.au" <me@work> skrev i en meddelelse
news:5BBFB070-9610-4824-8F88-...
>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...-from-web.html


/Peter


 
Reply With Quote
 
 
 
 
ThatsIT.net.au
Guest
Posts: n/a
 
      08-20-2009

"Peter K" <> wrote in message
news:%...
>
> "ThatsIT.net.au" <me@work> skrev i en meddelelse
> news:5BBFB070-9610-4824-8F88-...
>>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...-from-web.html
>


having a read but no luck so far



>
> /Peter
>


 
Reply With Quote
 
Peter K
Guest
Posts: n/a
 
      08-20-2009

"Mark Rae [MVP]" <> skrev i en meddelelse
news:%...
> "ThatsIT.net.au" <me@work> wrote in message
> news:EF3B587C-44B2-4011-BAE7-...
>
>>> "ThatsIT.net.au" <me@work> skrev i en meddelelse
>>> news:5BBFB070-9610-4824-8F88-...
>>>>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



 
Reply With Quote
 
Peter K
Guest
Posts: n/a
 
      08-20-2009
"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.


 
Reply With Quote
 
Jeff Johnson
Guest
Posts: n/a
 
      08-20-2009
"ThatsIT.net.au" <me@work> wrote in message
news:5BBFB070-9610-4824-8F88-...

>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.


 
Reply With Quote
 
ThatsIT.net.au
Guest
Posts: n/a
 
      08-20-2009

"Mark Rae [MVP]" <> wrote in message
news:%...
> "ThatsIT.net.au" <me@work> wrote in message
> news:EF3B587C-44B2-4011-BAE7-...
>
>>> "ThatsIT.net.au" <me@work> skrev i en meddelelse
>>> news:5BBFB070-9610-4824-8F88-...
>>>>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


 
Reply With Quote
 
ThatsIT.net.au
Guest
Posts: n/a
 
      08-20-2009

"Peter K" <> wrote in message
news:...
>
> "Mark Rae [MVP]" <> skrev i en meddelelse
> news:%...
>> "ThatsIT.net.au" <me@work> wrote in message
>> news:EF3B587C-44B2-4011-BAE7-...
>>
>>>> "ThatsIT.net.au" <me@work> skrev i en meddelelse
>>>> news:5BBFB070-9610-4824-8F88-...
>>>>>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

 
Reply With Quote
 
ThatsIT.net.au
Guest
Posts: n/a
 
      08-20-2009

"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.


 
Reply With Quote
 
ThatsIT.net.au
Guest
Posts: n/a
 
      08-20-2009

"Jeff Johnson" <> wrote in message
news:...
> "ThatsIT.net.au" <me@work> wrote in message
> news:5BBFB070-9610-4824-8F88-...
>
>>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?

 
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
Passing data between objects and calling all objects of a class in turn ghoetker Python 1 08-25-2010 03:18 AM
class objects, method objects, function objects 7stud Python 11 03-20-2007 06:05 PM
How .NET web services client handles exceptions from Java web services? John ASP .Net Web Services 4 03-31-2006 10:13 PM
how to implement Services Interface Tier (web services) Szymi MCSD 0 11-03-2003 10:50 AM
Passing custom objects in web services Roshawn ASP .Net Web Services 2 10-20-2003 08:06 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57