Issue with redefined .Net custome type in the proxy class for a web service...

Discussion in 'ASP .Net Web Services' started by Kris, Feb 4, 2005.

  1. Kris

    Kris Guest

    Hi there,

    I have web service which uses custom .Net types as parameter/return types. These custom types r defined in a seperate assembly and being refered in the web service using "using" directive for that assembly.

    Now when I Add a Web Reference to the client application which consumes this web service, it is generating a proxy class for the web service in which it is REDEFINING the custome types and adding relevent schema types, instead of just using the using directive for the assembly containg custom types. Note that I have this assembly as part of the solution but not in GAC.

    The issue with this is it is conflicting between the types defined in client application(I used using directive for this custom types assembly) and one returned from the webmethods invokation. Is there any way to have proxy class generated for the web service refer these custom types using that assembly's using directive instead of redefining them in the proxy class.

    It works fine if I manually delete the custom types from the proxy class generated and specify using directive for the assembly containg custom types. But I need this to happen automatically as I have several web services which r refering those custom types and also the issue is becoming even worse if there are any updates in the web service code and do update web references in the client project.

    Any help will be greatly appreciated...

    Thanks in advance...
    Kris

    Posted via DevelopmentNow Groups
    www.developmentnow.com/g
    www.developmentnow.com
    Kris, Feb 4, 2005
    #1
    1. Advertising

  2. Kris

    DalePres Guest

    The proxy generated by the Add Web Reference wizard is always going to based
    on reading the WSDL from the web service. Methods I have used to solve
    similar problems include any or combinations of:

    1. manually editing the proxy class,
    2. creating the custom class by deriving from MarshalByRefObject. Create
    the instance your client needs on the server and then the server and client
    are now using the same class and can share it.
    3 (and this is the easiest where it works). Add the XMLInclude attribute to
    your custom class and to any classes within your custom class.

    DalePres
    MCAD, MCDBA, MCSE

    "Kris" <12.ga.us> wrote in message
    news:...
    > Hi there,
    >
    > I have web service which uses custom .Net types as parameter/return types.
    > These custom types r defined in a seperate assembly and being refered in
    > the web service using "using" directive for that assembly.
    >
    > Now when I Add a Web Reference to the client application which consumes
    > this web service, it is generating a proxy class for the web service in
    > which it is REDEFINING the custome types and adding relevent schema types,
    > instead of just using the using directive for the assembly containg custom
    > types. Note that I have this assembly as part of the solution but not in
    > GAC.
    >
    > The issue with this is it is conflicting between the types defined in
    > client application(I used using directive for this custom types assembly)
    > and one returned from the webmethods invokation. Is there any way to have
    > proxy class generated for the web service refer these custom types using
    > that assembly's using directive instead of redefining them in the proxy
    > class.
    >
    > It works fine if I manually delete the custom types from the proxy class
    > generated and specify using directive for the assembly containg custom
    > types. But I need this to happen automatically as I have several web
    > services which r refering those custom types and also the issue is
    > becoming even worse if there are any updates in the web service code and
    > do update web references in the client project.
    >
    > Any help will be greatly appreciated...
    >
    > Thanks in advance...
    > Kris
    >
    > Posted via DevelopmentNow Groups
    > www.developmentnow.com/g
    > www.developmentnow.com
    DalePres, Feb 4, 2005
    #2
    1. Advertising

  3. Hello 12.ga.us,

    Wouldnt recommend it but here goes...

    http://msdn.microsoft.com/library/en-us/dnservice/html/service07162002.asp

    HTH
    Regards,
    Dilip Krishnan
    MCAD, MCSD.net
    dkrishnan at geniant dot com
    http://www.geniant.com

    > Hi there,
    >
    > I have web service which uses custom .Net types as parameter/return
    > types. These custom types r defined in a seperate assembly and being
    > refered in the web service using "using" directive for that assembly.
    >
    > Now when I Add a Web Reference to the client application which
    > consumes this web service, it is generating a proxy class for the web
    > service in which it is REDEFINING the custome types and adding
    > relevent schema types, instead of just using the using directive for
    > the assembly containg custom types. Note that I have this assembly as
    > part of the solution but not in GAC.
    >
    > The issue with this is it is conflicting between the types defined in
    > client application(I used using directive for this custom types
    > assembly) and one returned from the webmethods invokation. Is there
    > any way to have proxy class generated for the web service refer these
    > custom types using that assembly's using directive instead of
    > redefining them in the proxy class.
    >
    > It works fine if I manually delete the custom types from the proxy
    > class generated and specify using directive for the assembly containg
    > custom types. But I need this to happen automatically as I have
    > several web services which r refering those custom types and also the
    > issue is becoming even worse if there are any updates in the web
    > service code and do update web references in the client project.
    >
    > Any help will be greatly appreciated...
    >
    > Thanks in advance...
    > Kris
    > Posted via DevelopmentNow Groups
    > www.developmentnow.com/g
    > www.developmentnow.com
    Dilip Krishnan, Feb 4, 2005
    #3
  4. Hi All,

    Thanks for all ur replies. I checked this article before on shared types
    on msdn. As I said before I have several .Net custom types defined in
    one assembly and I am using them in several web services(around 50). All
    I am looking for is to see if there is any way to add a reference to
    this assembly automatically in the proxy classes generated.

    I added a using directive for this custom types assembly in the actual
    web service implementation code. And the issue is when the proxy class
    is generated(during Add WebReference/or wsdl.exe) it is redefining those
    custom types in each proxy class instead of adding the using directive
    as it is in the actual web service imlementation code(in asmx.cs file).

    Any idea?

    thnaks,
    Kris

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Krishna Kanthi, Feb 7, 2005
    #4
  5. Kris

    DalePres Guest

    The problem may be in the implementation in the client. Rather than point
    the client to the custom type in the assembly, you might try creating the
    type as a public member of the web service and then declare the custom type
    in the client as an instance of the web service class member. In that way,
    you get the web service and its client identifying the same class rather
    than them acting like they are looking at two identical but separate
    classes.

    HTH

    DalePres
    MCAD, MCDBA, MCSE


    "Krishna Kanthi" <12.ga.us> wrote in message
    news:%...
    > Hi All,
    >
    > Thanks for all ur replies. I checked this article before on shared types
    > on msdn. As I said before I have several .Net custom types defined in
    > one assembly and I am using them in several web services(around 50). All
    > I am looking for is to see if there is any way to add a reference to
    > this assembly automatically in the proxy classes generated.
    >
    > I added a using directive for this custom types assembly in the actual
    > web service implementation code. And the issue is when the proxy class
    > is generated(during Add WebReference/or wsdl.exe) it is redefining those
    > custom types in each proxy class instead of adding the using directive
    > as it is in the actual web service imlementation code(in asmx.cs file).
    >
    > Any idea?
    >
    > thnaks,
    > Kris
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    DalePres, Feb 8, 2005
    #5
  6. Kris

    Kris Guest

    Well the problem with this is I am using the same custom type as
    parameter/return type in the client application. And I also have several
    client applications which use these custom types. Hence I can not do
    what u have suggested here.

    Also, why the proxy generated is redefining the custom type instead of
    adding a using directive at the top, as it does for several builtin .Net
    types?

    Any ideas further will be appreciated.

    Thanks,
    Kris



    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!
    Kris, Feb 8, 2005
    #6
  7. Kris

    DalePres Guest

    Keep in mind that web services are supposedly to be cross platform and
    standards based. Microsoft is limited on how much they can vary from those
    standards and still be accepted in the marketplace.

    If you want to have better control over types, inlcuding sharing types via
    the GAC, look into .Net Remoting using the BinaryFormatter.

    HTH

    DalePres

    "Kris" <> wrote in message
    news:...
    > Well the problem with this is I am using the same custom type as
    > parameter/return type in the client application. And I also have several
    > client applications which use these custom types. Hence I can not do
    > what u have suggested here.
    >
    > Also, why the proxy generated is redefining the custom type instead of
    > adding a using directive at the top, as it does for several builtin .Net
    > types?
    >
    > Any ideas further will be appreciated.
    >
    > Thanks,
    > Kris
    >
    >
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!
    DalePres, Feb 9, 2005
    #7
  8. Kris

    Dan Rogers Guest

    Hi,

    In short, no. Web services do not share implementations explicitely as a
    philosophical tenet. So the automatically generated proxy code does not
    magically copy an external DLL into it's local implementation.

    You have a few choices: Hand code the proxy you want to have all of your
    clients use. This proxy code would be an assembly (just some code, eh?)
    that imports the shared assembly by reference. Then you would ship both
    DLL's to all of your clients, and they would all get the right types.

    A simple solution is to tell the people generating the proxies to name the
    proxy with the same namespace as the shared assembly. They should NOT use
    your shared DLL, but should get all of their definitions from the new proxy
    class - which has shadow methods and approximations of the data types. No
    methods from the shared assembly will be avaliable - but this is the way
    that web service based coupling is supposed to work.

    --------------------
    >From: Krishna Kanthi <12.ga.us>
    >References: <>
    >X-Newsreader: AspNNTP 1.50 (ActionJackson.com)
    >Subject: Re: Issue with redefined .Net custome type in the proxy class for

    a web service...
    >Mime-Version: 1.0
    >Content-Type: text/plain; charset="us-ascii"
    >Content-Transfer-Encoding: 7bit
    >Message-ID: <#>
    >Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
    >Date: Mon, 07 Feb 2005 07:04:57 -0800
    >NNTP-Posting-Host: 67.41.129.85
    >Lines: 1
    >Path:

    cpmsftngxa10.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA02.phx.gbl!cpmsftngxa0
    6.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
    >Xref: cpmsftngxa10.phx.gbl

    microsoft.public.dotnet.framework.aspnet.webservices:27991
    >X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices
    >
    >Hi All,
    >
    >Thanks for all ur replies. I checked this article before on shared types
    >on msdn. As I said before I have several .Net custom types defined in
    >one assembly and I am using them in several web services(around 50). All
    >I am looking for is to see if there is any way to add a reference to
    >this assembly automatically in the proxy classes generated.
    >
    >I added a using directive for this custom types assembly in the actual
    >web service implementation code. And the issue is when the proxy class
    >is generated(during Add WebReference/or wsdl.exe) it is redefining those
    >custom types in each proxy class instead of adding the using directive
    >as it is in the actual web service imlementation code(in asmx.cs file).
    >
    >Any idea?
    >
    >thnaks,
    >Kris
    >
    >*** Sent via Developersdex http://www.developersdex.com ***
    >Don't just participate in USENET...get rewarded for it!
    >
    Dan Rogers, Feb 15, 2005
    #8
    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. Mahesh Devjibhai Dhola

    Problem in deriving custome class from XmlNode

    Mahesh Devjibhai Dhola, Oct 15, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    494
    Mahesh Devjibhai Dhola
    Oct 15, 2004
  2. Replies:
    1
    Views:
    627
    Victor Bazarov
    Apr 1, 2005
  3. Ryan
    Replies:
    1
    Views:
    340
  4. chris
    Replies:
    4
    Views:
    337
    chris
    May 2, 2008
  5. MiG
    Replies:
    8
    Views:
    149
    Ryan Leavengood
    Oct 19, 2005
Loading...

Share This Page