Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > ASP .Net Web Services > Web Services and user defined types

Reply
Thread Tools

Web Services and user defined types

 
 
Paolo Nunberg
Guest
Posts: n/a
 
      10-02-2004
Hi,

I am a newbie to Web Service and I cannot figure how to share a user defined
type between a Windows application and a Web Service.
I have a Windows Forms application and a Web Service, both referring to an
assembly which defines a simple structure (see code below).
When I try to compile the solution (VB.NET 2003) I get the following error
at the line marked 'Error here' in the code for 'Form1_Load':

Unable to connvert the type value "TestTipiWS.WSTipi.Persona" into
"Persone.Persona".

If I change the declaration of p into:

Dim p As WSTipi.Persona

the solution compiles and works as expected, but I would like to have a
single type definition.

Any suggestion?
Thanks!

------------------------------
Paolo Nunberg



*** Type definition assembly ***
Namespace Persone
Public Structure Persona
Dim ID As Integer
Dim Nome As String
End Structure
End Namespace

*** Form code ***
Imports Persone
....
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
Dim Sv As New WSTipi.ServTipi
Dim p As Persona
p = Sv.GetPersona() '*** Error here ***
lbID.Text = p.ID
lbNome.Text = p.Nome
End Sub

*** Web Service ***
......
Imports Persone

<System.Web.Services.WebService(Namespace:="http ://tempuri.org/ProvaWS/ServT
ipi"

)> _
Public Class ServTipi
Inherits System.Web.Services.WebService
......
<WebMethod()> _
Public Function GetPersona() As Persona
Dim p As Persona
p.ID = 11581
p.Nome = "Paolo Nunberg"
Return p
End Function

End Class


 
Reply With Quote
 
 
 
 
Ken Dopierala Jr.
Guest
Posts: n/a
 
      10-02-2004
Hi,

The easiest way to do this is to not have your Windows app refer to the user
defined type except through the web service. Just use it like you are using
it through the web service. That way you will only be referencing it in one
spot. When you change the UDT, recompile your web service, then update the
reference to it in your Windows app and you'll be able see the new
properties. You could also try using the CType function to see if that can
do it for you. I pass classes from web services to my ASP.Net app and CType
didn't work for me. But maybe using UDTs it will. If it does make sure you
have both apps pointing to the same DLL. If that gets messed up you'll be
wondering what the heck is going on because the compiler shows no problems
but the runtime version won't work. Good luck! Ken.


--
Ken Dopierala Jr.
For great ASP.Net web hosting try:
http://www.webhost4life.com/default.asp?refid=Spinlight
If you sign up under me and need help, email me.

"Paolo Nunberg" <> wrote in message
news:3rB7d.28720$...
> Hi,
>
> I am a newbie to Web Service and I cannot figure how to share a user

defined
> type between a Windows application and a Web Service.
> I have a Windows Forms application and a Web Service, both referring to an
> assembly which defines a simple structure (see code below).
> When I try to compile the solution (VB.NET 2003) I get the following error
> at the line marked 'Error here' in the code for 'Form1_Load':
>
> Unable to connvert the type value "TestTipiWS.WSTipi.Persona" into
> "Persone.Persona".
>
> If I change the declaration of p into:
>
> Dim p As WSTipi.Persona
>
> the solution compiles and works as expected, but I would like to have a
> single type definition.
>
> Any suggestion?
> Thanks!
>
> ------------------------------
> Paolo Nunberg
>
>
>
> *** Type definition assembly ***
> Namespace Persone
> Public Structure Persona
> Dim ID As Integer
> Dim Nome As String
> End Structure
> End Namespace
>
> *** Form code ***
> Imports Persone
> ...
> Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> System.EventArgs) Handles MyBase.Load
> Dim Sv As New WSTipi.ServTipi
> Dim p As Persona
> p = Sv.GetPersona() '*** Error here ***
> lbID.Text = p.ID
> lbNome.Text = p.Nome
> End Sub
>
> *** Web Service ***
> .....
> Imports Persone
>
>

<System.Web.Services.WebService(Namespace:="http ://tempuri.org/ProvaWS/ServT
> ipi"
>
> )> _
> Public Class ServTipi
> Inherits System.Web.Services.WebService
> .....
> <WebMethod()> _
> Public Function GetPersona() As Persona
> Dim p As Persona
> p.ID = 11581
> p.Nome = "Paolo Nunberg"
> Return p
> End Function
>
> End Class
>
>



 
Reply With Quote
 
 
 
 
Paolo Nunberg
Guest
Posts: n/a
 
      10-03-2004
Hi Ken,

Ctype does not work for me either.
What baffles me is that in the 'Tracker' application from Infragistics
(www.infragistics.com) they apparently succeed in getting back their user
defined classes from a Web Service (see the Business Logic classes).

Thanks!

"Ken Dopierala Jr." <> ha scritto nel messaggio
news:...
> Hi,
>
> The easiest way to do this is to not have your Windows app refer to the

user
> defined type except through the web service. Just use it like you are

using
> it through the web service. That way you will only be referencing it in

one
> spot. When you change the UDT, recompile your web service, then update

the
> reference to it in your Windows app and you'll be able see the new
> properties. You could also try using the CType function to see if that

can
> do it for you. I pass classes from web services to my ASP.Net app and

CType
> didn't work for me. But maybe using UDTs it will. If it does make sure

you
> have both apps pointing to the same DLL. If that gets messed up you'll be
> wondering what the heck is going on because the compiler shows no problems
> but the runtime version won't work. Good luck! Ken.
>
>
> --
> Ken Dopierala Jr.
> For great ASP.Net web hosting try:
> http://www.webhost4life.com/default.asp?refid=Spinlight
> If you sign up under me and need help, email me.
>
> "Paolo Nunberg" <> wrote in message
> news:3rB7d.28720$...
> > Hi,
> >
> > I am a newbie to Web Service and I cannot figure how to share a user

> defined
> > type between a Windows application and a Web Service.
> > I have a Windows Forms application and a Web Service, both referring to

an
> > assembly which defines a simple structure (see code below).
> > When I try to compile the solution (VB.NET 2003) I get the following

error
> > at the line marked 'Error here' in the code for 'Form1_Load':
> >
> > Unable to connvert the type value "TestTipiWS.WSTipi.Persona" into
> > "Persone.Persona".
> >
> > If I change the declaration of p into:
> >
> > Dim p As WSTipi.Persona
> >
> > the solution compiles and works as expected, but I would like to have a
> > single type definition.
> >
> > Any suggestion?
> > Thanks!
> >
> > ------------------------------
> > Paolo Nunberg
> >
> >
> >
> > *** Type definition assembly ***
> > Namespace Persone
> > Public Structure Persona
> > Dim ID As Integer
> > Dim Nome As String
> > End Structure
> > End Namespace
> >
> > *** Form code ***
> > Imports Persone
> > ...
> > Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
> > System.EventArgs) Handles MyBase.Load
> > Dim Sv As New WSTipi.ServTipi
> > Dim p As Persona
> > p = Sv.GetPersona() '*** Error here ***
> > lbID.Text = p.ID
> > lbNome.Text = p.Nome
> > End Sub
> >
> > *** Web Service ***
> > .....
> > Imports Persone
> >
> >

>

<System.Web.Services.WebService(Namespace:="http ://tempuri.org/ProvaWS/ServT
> > ipi"
> >
> > )> _
> > Public Class ServTipi
> > Inherits System.Web.Services.WebService
> > .....
> > <WebMethod()> _
> > Public Function GetPersona() As Persona
> > Dim p As Persona
> > p.ID = 11581
> > p.Nome = "Paolo Nunberg"
> > Return p
> > End Function
> >
> > End Class
> >
> >

>
>



 
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
User-defined exception: "global name 'TestRunError' is not defined" jmike@alum.mit.edu Python 1 07-10-2008 12:37 PM
the problem with packages and generics and user defined types(arrays, records, etc) wallge VHDL 7 02-12-2008 09:39 PM
#if (defined(__STDC__) && !defined(NO_PROTOTYPE)) || defined(__cplusplus) Oodini C Programming 1 09-27-2005 07:58 PM
pointer arithmetic and user-defined types Simon Morgan C Programming 8 08-18-2005 05:59 AM
Doubt in distinguishing between modules and user-defined types main features. Guilherme Pinto C++ 1 10-10-2003 04:30 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