Share Class Library between Service and Consumer

Discussion in 'ASP .Net Web Services' started by Mike Lynch, Apr 21, 2004.

  1. Mike Lynch

    Mike Lynch Guest

    I want to share a class library between a web service and it's consumer (another web service). When I run the consumer I get a conversion error saying one class is not derived from the other

    How can I overcome this

    Simplified pseudo code is shown belo

    Service
    imports myClassLibrar

    <web Method> public function method1(param as string) as myClassLibrary.Class
    Dim r1 as myClassLibrary.Class
    'do some processin

    Return r
    End Functio

    End Service

    Service
    imports myClassLibrar

    <web Method> public function method2(param as string) as myClassLibrary.Class
    Dim r2 As New myClassLibrary.Class

    r2.Name = "Test
    r2.Obj = Service1.method1("A String"

    Return r
    End Functio

    End Service

    myClassLibrar

    Public Class Class

    End Clas

    Public Class Class
    Public Name as Strin
    Public obj As Class
    End Clas

    End myClassLibrary
     
    Mike Lynch, Apr 21, 2004
    #1
    1. Advertising

  2. Hello, Mike-

    Please see my blog entry regarding using "shared types" assemblies:
    http://dotnetified.com/CommentView.aspx?guid=abaf08b3-1abd-4dae-be05-23b733ff3c5d

    Hope this helps!
    -Andy Hopper

    "Mike Lynch" <> wrote in message
    news:...
    > I want to share a class library between a web service and it's consumer

    (another web service). When I run the consumer I get a conversion error
    saying one class is not derived from the other.
    >
    > How can I overcome this?
    >
    > Simplified pseudo code is shown below
    >
    > Service1
    > imports myClassLibrary
    >
    > <web Method> public function method1(param as string) as

    myClassLibrary.Class1
    > Dim r1 as myClassLibrary.Class1
    > 'do some processing
    >
    > Return r1
    > End Function
    >
    > End Service1
    >
    > Service2
    > imports myClassLibrary
    >
    > <web Method> public function method2(param as string) as

    myClassLibrary.Class2
    > Dim r2 As New myClassLibrary.Class2
    >
    > r2.Name = "Test"
    > r2.Obj = Service1.method1("A String")
    >
    > Return r2
    > End Function
    >
    > End Service2
    >
    > myClassLibrary
    >
    > Public Class Class1
    >
    > End Class
    >
    > Public Class Class2
    > Public Name as String
    > Public obj As Class1
    > End Class
    >
    > End myClassLibrary
     
    Andrew Hopper, Apr 21, 2004
    #2
    1. Advertising

  3. Mike Lynch

    Jan Tielens Guest

    In your client project there are proxy classes generated when you add a web
    reference to it. So you can't use your originating class client side, this
    is default web services behavior.

    --
    Greetz,
    Jan
    ________________________
    Read my weblog: http://weblogs.asp.net/jan

    "Mike Lynch" <> schreef in bericht
    news:...
    > I want to share a class library between a web service and it's consumer

    (another web service). When I run the consumer I get a conversion error
    saying one class is not derived from the other.
    >
    > How can I overcome this?
    >
    > Simplified pseudo code is shown below
    >
    > Service1
    > imports myClassLibrary
    >
    > <web Method> public function method1(param as string) as

    myClassLibrary.Class1
    > Dim r1 as myClassLibrary.Class1
    > 'do some processing
    >
    > Return r1
    > End Function
    >
    > End Service1
    >
    > Service2
    > imports myClassLibrary
    >
    > <web Method> public function method2(param as string) as

    myClassLibrary.Class2
    > Dim r2 As New myClassLibrary.Class2
    >
    > r2.Name = "Test"
    > r2.Obj = Service1.method1("A String")
    >
    > Return r2
    > End Function
    >
    > End Service2
    >
    > myClassLibrary
    >
    > Public Class Class1
    >
    > End Class
    >
    > Public Class Class2
    > Public Name as String
    > Public obj As Class1
    > End Class
    >
    > End myClassLibrary
     
    Jan Tielens, Apr 22, 2004
    #3
  4. Mike Lynch

    Mike Lynch Guest

    That worked a treat Andrew

    Thanks for your hel

    Mik

    ----- Andrew Hopper wrote: ----

    Hello, Mike

    Please see my blog entry regarding using "shared types" assemblies
    http://dotnetified.com/CommentView.aspx?guid=abaf08b3-1abd-4dae-be05-23b733ff3c5

    Hope this helps
    -Andy Hoppe

    "Mike Lynch" <> wrote in messag
    news:..
    > I want to share a class library between a web service and it's consume

    (another web service). When I run the consumer I get a conversion erro
    saying one class is not derived from the other
    >> How can I overcome this
    >> Simplified pseudo code is shown belo
    >> Service

    > imports myClassLibrar
    >><web Method> public function method1(param as string) a

    myClassLibrary.Class
    > Dim r1 as myClassLibrary.Class
    > 'do some processin
    >> Return r

    > End Functio
    >> End Service
    >> Service

    > imports myClassLibrar
    >><web Method> public function method2(param as string) a

    myClassLibrary.Class
    > Dim r2 As New myClassLibrary.Class
    >> r2.Name = "Test

    > r2.Obj = Service1.method1("A String"
    >> Return r

    > End Functio
    >> End Service
    >> myClassLibrar
    >> Public Class Class
    >> End Clas
    >> Public Class Class

    > Public Name as Strin
    > Public obj As Class
    > End Clas
    >> End myClassLibrar
     
    Mike Lynch, Apr 22, 2004
    #4
    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. K. Jansma
    Replies:
    7
    Views:
    335
    Duncan Booth
    Feb 21, 2006
  2. Lord0
    Replies:
    0
    Views:
    397
    Lord0
    Feb 19, 2007
  3. Michael Fan
    Replies:
    2
    Views:
    148
    Michael Fan
    Jul 16, 2004
  4. Saraswati lakki
    Replies:
    0
    Views:
    1,390
    Saraswati lakki
    Jan 6, 2012
  5. Jack
    Replies:
    2
    Views:
    234
Loading...

Share This Page