Ureader.com  
Microsoft software help and Community
   home   |   control panel login   |   archive   |  
 
DotNet
acad.assignment.mngr
academic
adonet
aspnet
aspnet.announcements
aspnet.build.controls
aspnet.caching
aspnet.datagridcontrol
aspnet.mobile
aspnet.security
aspnet.webcontrols
aspnet.webservices
clr
compactframework
component_services
datatools
distributed_apps
drawing
faqs
framework
framework.wmi
general
internationalization
interop
languages.csharp
languages.jscript
languages.vb
languages.vb.controls
languages.vb.data
languages.vb.upgrade
languages.vc
languages.vc.libraries
myservices
odbcnet
performance
remoting
scripting
sdk
security
setup
vjsharp
vsa
webservi.enhancements
webservices
windowsforms
windowsforms.controls
winforms.databinding
winforms.designtime
xml
  
 
date: Thu, 21 Aug 2008 18:18:01 -0700,    group: microsoft.public.dotnet.framework.aspnet.webservices        back       


Accessing generic methods throug a proxy object   
Hello,

I have a class defination for Location which can have multiple keywords. The 
keyword class has one Public property LocKeyword.

For simplicity i have remove all the other properties. 
    Public Class Loc
        Inherits basecore
        Private _keywords As List(Of LocKeyword)

        Public Property Keywords() As List(Of LocKeyword)
            Get
                Return _keywords
            End Get
            Set(ByVal value As List(Of LocKeyword))
                _keywords = value
            End Set
        End Property
    End Class

    Public Class LocKeyword
        Inherits BaseCore

        Public Keyword As String
    End Class


Both Location and Keyword have their definations in the webservice project 
under App_GlobalResources


The problem:
When i try to create a proxy object of type Location in an ASP.Net website 
with the following code:

        Dim oLoc As New Loc

        oLoc.Keywords.Add(New LocKeyword())

I get an error - the Add generic method does not come up. Is there any way i 
can make it?    If i work on an object withen the Webservice project i dont 
have any problem - Ie the Code works. 

Any ideas? 

Regards
Ishan
date: Thu, 21 Aug 2008 18:18:01 -0700   author:   Ishan Bhalla

RE: Accessing generic methods throug a proxy object   
Hello,

I have a class definition for Location which can have multiple keywords. The 
LocKeyword class has one Public property LocKeyword.

For simplicity i have remove all the other properties. 
    Public Class Loc
        Inherits basecore
        Private _keywords As List(Of LocKeyword)

        Public Property Keywords() As List(Of LocKeyword)
            Get
                Return _keywords
            End Get
            Set(ByVal value As List(Of LocKeyword))
                _keywords = value
            End Set
        End Property
    End Class

    Public Class LocKeyword
        Inherits BaseCore

        Public Keyword As String
    End Class


Both Location and Keyword have their definitions in the web service project 
under App_GlobalResources


The problem:
When i try to create a proxy object of type location in an ASP.Net website 
with the following code:

        Dim oLoc As New Loc

        oLoc.Keywords.Add(New LocKeyword())

I get an error - the Add generic method does not come up. Is there any way i 
can make it?    If i work on an object within the Webservice project i don’t 
have any problem - Ie the Code works. 

Any ideas? 

Regards
Ishan
date: Thu, 21 Aug 2008 18:19:01 -0700   author:   Ishan Bhalla

Re: Accessing generic methods throug a proxy object   
You haven't shown us your web methods. Do you ever return an instance of Loc 
from a web method? Only classes used as return values or parameter types in 
a web method will have proxy classes made for them. The following worked for 
me. Server: UsingGenerics.asmx.vb:
-----------------------------------------------------------------------------------------------------------------------------
Imports System.Web.Services
Imports System.ComponentModel

<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> 
_
<ToolboxItem(False)> _
Public Class UsingGenerics
    Inherits System.Web.Services.WebService

    <WebMethod()> _
    Public Function HelloWorld() As Loc
        Dim lk As New List(Of LocKeyword)
        lk.Add(New LocKeyword With {.Keyword = "Key1"})
        lk.Add(New LocKeyword With {.Keyword = "key2"})
        Dim l As New Loc With {.Keywords = lk}
        Return l
    End Function

End Class

Public Class LocKeyword
    Private _keyword As String

    Public Property Keyword() As String
        Get
            Return _keyword
        End Get
        Set(ByVal value As String)
            _keyword = value
        End Set
    End Property

End Class

Public Class Loc
    Private _keywords As New List(Of LocKeyword)
    Public Property Keywords() As List(Of LocKeyword)
        Get
            Return _keywords
        End Get
        Set(ByVal value As List(Of LocKeyword))
            _keywords.Clear()
            _keywords.AddRange(value)
        End Set
    End Property
End Class

Public Class WillNotAppearOnClient
    Public Property DontCare() As Integer
        Get
            Return 1
        End Get
        Set(ByVal value As Integer)

        End Set
    End Property
End Class
-----------------------------------------------------------------------------------------------------------------------------
Client: Module1.vb:

Module Module1

    Sub Main()
        Using svc As New GenericService.UsingGenerics
            Dim list As GenericService.Loc = svc.HelloWorld()
            Console.WriteLine(list.Keywords(0).Keyword)
            ' Note GenericService.WillNotAppearOnClient will not
        End Using
    End Sub

End Module
-----------------------------------------------------------------------------------------------------------------------------
I hope that helps

-- 
John Saunders | MVP - Connected System Developer

"Ishan Bhalla"  wrote in message 
news:6313583F-71B2-418E-958F-092DACB9B700@microsoft.com...
> Hello,
>
> I have a class defination for Location which can have multiple keywords. 
> The
> keyword class has one Public property LocKeyword.
>
> For simplicity i have remove all the other properties.
>    Public Class Loc
>        Inherits basecore
>        Private _keywords As List(Of LocKeyword)
>
>        Public Property Keywords() As List(Of LocKeyword)
>            Get
>                Return _keywords
>            End Get
>            Set(ByVal value As List(Of LocKeyword))
>                _keywords = value
>            End Set
>        End Property
>    End Class
>
>    Public Class LocKeyword
>        Inherits BaseCore
>
>        Public Keyword As String
>    End Class
>
>
> Both Location and Keyword have their definations in the webservice project
> under App_GlobalResources
>
>
> The problem:
> When i try to create a proxy object of type Location in an ASP.Net website
> with the following code:
>
>        Dim oLoc As New Loc
>
>        oLoc.Keywords.Add(New LocKeyword())
>
> I get an error - the Add generic method does not come up. Is there any way 
> i
> can make it?    If i work on an object withen the Webservice project i 
> dont
> have any problem - Ie the Code works.
>
> Any ideas?
>
> Regards
> Ishan
>
>
date: Sat, 23 Aug 2008 12:28:46 -0400   author:   John Saunders

Re: Accessing generic methods throug a proxy object   
Hello John 

Thanks for the response, but it does solve my problem. 

I do not want to add a keyword in the webservice (HelloWorld()) - i want to 
add the keyword to the keyword collection in the front end ie - Your Sub 
Main()
Something like this:

Import <Webreference>

Sub Main()
Dim oLoc as Location

oLoc.Keyword.Add(New LocKeyword With {.Keyword = "Key1"})
oLoc.Keyword.Add(New LocKeyword With {.Keyword = "Key2"})

End Sub

End Module 

Well here is the background- i get the keyword information(and lots of other 
informaiton)  from the webpage, so i want  to assemble the location object in 
the webpages VB file. 

Regards
Ishan

"John Saunders" wrote:

> You haven't shown us your web methods. Do you ever return an instance of Loc 
> from a web method? Only classes used as return values or parameter types in 
> a web method will have proxy classes made for them. The following worked for 
> me. Server: UsingGenerics.asmx.vb:
> -----------------------------------------------------------------------------------------------------------------------------
> Imports System.Web.Services
> Imports System.ComponentModel
> 
> <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
> <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> 
> _
> <ToolboxItem(False)> _
> Public Class UsingGenerics
>     Inherits System.Web.Services.WebService
> 
>     <WebMethod()> _
>     Public Function HelloWorld() As Loc
>         Dim lk As New List(Of LocKeyword)
>         lk.Add(New LocKeyword With {.Keyword = "Key1"})
>         lk.Add(New LocKeyword With {.Keyword = "key2"})
>         Dim l As New Loc With {.Keywords = lk}
>         Return l
>     End Function
> 
> End Class
> 
> Public Class LocKeyword
>     Private _keyword As String
> 
>     Public Property Keyword() As String
>         Get
>             Return _keyword
>         End Get
>         Set(ByVal value As String)
>             _keyword = value
>         End Set
>     End Property
> 
> End Class
> 
> Public Class Loc
>     Private _keywords As New List(Of LocKeyword)
>     Public Property Keywords() As List(Of LocKeyword)
>         Get
>             Return _keywords
>         End Get
>         Set(ByVal value As List(Of LocKeyword))
>             _keywords.Clear()
>             _keywords.AddRange(value)
>         End Set
>     End Property
> End Class
> 
> Public Class WillNotAppearOnClient
>     Public Property DontCare() As Integer
>         Get
>             Return 1
>         End Get
>         Set(ByVal value As Integer)
> 
>         End Set
>     End Property
> End Class
> -----------------------------------------------------------------------------------------------------------------------------
> Client: Module1.vb:
> 
> Module Module1
> 
>     Sub Main()
>         Using svc As New GenericService.UsingGenerics
>             Dim list As GenericService.Loc = svc.HelloWorld()
>             Console.WriteLine(list.Keywords(0).Keyword)
>             ' Note GenericService.WillNotAppearOnClient will not
>         End Using
>     End Sub
> 
> End Module
> -----------------------------------------------------------------------------------------------------------------------------
> I hope that helps
> 
> -- 
> John Saunders | MVP - Connected System Developer
> 
> "Ishan Bhalla"  wrote in message 
> news:6313583F-71B2-418E-958F-092DACB9B700@microsoft.com...
> > Hello,
> >
> > I have a class defination for Location which can have multiple keywords. 
> > The
> > keyword class has one Public property LocKeyword.
> >
> > For simplicity i have remove all the other properties.
> >    Public Class Loc
> >        Inherits basecore
> >        Private _keywords As List(Of LocKeyword)
> >
> >        Public Property Keywords() As List(Of LocKeyword)
> >            Get
> >                Return _keywords
> >            End Get
> >            Set(ByVal value As List(Of LocKeyword))
> >                _keywords = value
> >            End Set
> >        End Property
> >    End Class
> >
> >    Public Class LocKeyword
> >        Inherits BaseCore
> >
> >        Public Keyword As String
> >    End Class
> >
> >
> > Both Location and Keyword have their definations in the webservice project
> > under App_GlobalResources
> >
> >
> > The problem:
> > When i try to create a proxy object of type Location in an ASP.Net website
> > with the following code:
> >
> >        Dim oLoc As New Loc
> >
> >        oLoc.Keywords.Add(New LocKeyword())
> >
> > I get an error - the Add generic method does not come up. Is there any way 
> > i
> > can make it?    If i work on an object withen the Webservice project i 
> > dont
> > have any problem - Ie the Code works.
> >
> > Any ideas?
> >
> > Regards
> > Ishan
> >
> > 
>
date: Sun, 24 Aug 2008 20:28:01 -0700   author:   Ishan Bhalla

Re: Accessing generic methods throug a proxy object   
Ok, so what is the problem? Assemble oLoc and then send it to the web 
service.

I still can't see your issue. Did you determine whether any of the web 
methods ever return or accept an instance of these classes?

-- 
John Saunders | MVP - Connected System Developer

"Ishan Bhalla"  wrote in message 
news:7FDD7176-73A3-48FE-9E46-B3F2F4DE7783@microsoft.com...
> Hello John
>
> Thanks for the response, but it does solve my problem.
>
> I do not want to add a keyword in the webservice (HelloWorld()) - i want 
> to
> add the keyword to the keyword collection in the front end ie - Your Sub
> Main()
> Something like this:
>
> Import <Webreference>
>
> Sub Main()
> Dim oLoc as Location
>
> oLoc.Keyword.Add(New LocKeyword With {.Keyword = "Key1"})
> oLoc.Keyword.Add(New LocKeyword With {.Keyword = "Key2"})
>
> End Sub
>
> End Module
>
> Well here is the background- i get the keyword information(and lots of 
> other
> informaiton)  from the webpage, so i want  to assemble the location object 
> in
> the webpages VB file.
>
> Regards
> Ishan
>
> "John Saunders" wrote:
>
>> You haven't shown us your web methods. Do you ever return an instance of 
>> Loc
>> from a web method? Only classes used as return values or parameter types 
>> in
>> a web method will have proxy classes made for them. The following worked 
>> for
>> me. Server: UsingGenerics.asmx.vb:
>> -----------------------------------------------------------------------------------------------------------------------------
>> Imports System.Web.Services
>> Imports System.ComponentModel
>>
>> <System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
>> <System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)>
>> _
>> <ToolboxItem(False)> _
>> Public Class UsingGenerics
>>     Inherits System.Web.Services.WebService
>>
>>     <WebMethod()> _
>>     Public Function HelloWorld() As Loc
>>         Dim lk As New List(Of LocKeyword)
>>         lk.Add(New LocKeyword With {.Keyword = "Key1"})
>>         lk.Add(New LocKeyword With {.Keyword = "key2"})
>>         Dim l As New Loc With {.Keywords = lk}
>>         Return l
>>     End Function
>>
>> End Class
>>
>> Public Class LocKeyword
>>     Private _keyword As String
>>
>>     Public Property Keyword() As String
>>         Get
>>             Return _keyword
>>         End Get
>>         Set(ByVal value As String)
>>             _keyword = value
>>         End Set
>>     End Property
>>
>> End Class
>>
>> Public Class Loc
>>     Private _keywords As New List(Of LocKeyword)
>>     Public Property Keywords() As List(Of LocKeyword)
>>         Get
>>             Return _keywords
>>         End Get
>>         Set(ByVal value As List(Of LocKeyword))
>>             _keywords.Clear()
>>             _keywords.AddRange(value)
>>         End Set
>>     End Property
>> End Class
>>
>> Public Class WillNotAppearOnClient
>>     Public Property DontCare() As Integer
>>         Get
>>             Return 1
>>         End Get
>>         Set(ByVal value As Integer)
>>
>>         End Set
>>     End Property
>> End Class
>> -----------------------------------------------------------------------------------------------------------------------------
>> Client: Module1.vb:
>>
>> Module Module1
>>
>>     Sub Main()
>>         Using svc As New GenericService.UsingGenerics
>>             Dim list As GenericService.Loc = svc.HelloWorld()
>>             Console.WriteLine(list.Keywords(0).Keyword)
>>             ' Note GenericService.WillNotAppearOnClient will not
>>         End Using
>>     End Sub
>>
>> End Module
>> -----------------------------------------------------------------------------------------------------------------------------
>> I hope that helps
>>
>> -- 
>> John Saunders | MVP - Connected System Developer
>>
>> "Ishan Bhalla"  wrote in message
>> news:6313583F-71B2-418E-958F-092DACB9B700@microsoft.com...
>> > Hello,
>> >
>> > I have a class defination for Location which can have multiple 
>> > keywords.
>> > The
>> > keyword class has one Public property LocKeyword.
>> >
>> > For simplicity i have remove all the other properties.
>> >    Public Class Loc
>> >        Inherits basecore
>> >        Private _keywords As List(Of LocKeyword)
>> >
>> >        Public Property Keywords() As List(Of LocKeyword)
>> >            Get
>> >                Return _keywords
>> >            End Get
>> >            Set(ByVal value As List(Of LocKeyword))
>> >                _keywords = value
>> >            End Set
>> >        End Property
>> >    End Class
>> >
>> >    Public Class LocKeyword
>> >        Inherits BaseCore
>> >
>> >        Public Keyword As String
>> >    End Class
>> >
>> >
>> > Both Location and Keyword have their definations in the webservice 
>> > project
>> > under App_GlobalResources
>> >
>> >
>> > The problem:
>> > When i try to create a proxy object of type Location in an ASP.Net 
>> > website
>> > with the following code:
>> >
>> >        Dim oLoc As New Loc
>> >
>> >        oLoc.Keywords.Add(New LocKeyword())
>> >
>> > I get an error - the Add generic method does not come up. Is there any 
>> > way
>> > i
>> > can make it?    If i work on an object withen the Webservice project i
>> > dont
>> > have any problem - Ie the Code works.
>> >
>> > Any ideas?
>> >
>> > Regards
>> > Ishan
>> >
>> >
>>
date: Mon, 25 Aug 2008 21:13:46 -0400   author:   John Saunders

Google
 
Web ureader.com


    COPYRIGHT 2007, YARDI TECHNOLOGY LIMITED, ALL RIGHT RESERVE  |   contact us