Problems with namespaces

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Simon

    Problems with namespaces

    I have problem with namespaces. I have a program that consumes the web
    service and has for instance names space nsProgram. In this program I have
    defined several classes that I use for storing and handling internal
    information. Than I have web service, that also uses the same classes (I
    included the file as linked external resource). I included this web service
    as web reference and used name wsWeb.

    When I am trying to call the web service with parameter that is my class
    (for instance Data) I can declare this Data class in my main program without
    any problem, but compiler reports an error:
    Error 1 The best overloaded method match for
    'nsProgram.wsWe b.WebData.Test( 'nsProgram.wsWe b.Header)' has some invalid
    arguments
    Error 2 Argument '1': cannot convert from 'nsProgram.Data ' to
    'nsProgram.wsWe b.Data'

    Why is the wsWeb also included for all data types? How can I get around
    that?

    Thank you

    Simon

  • Steven Cheng[MSFT]

    #2
    RE: Problems with namespaces

    Hi Simon,

    From your description, you're consuming a .NET webservice in an client app.
    The webservice has some certain custom data classes which will be shared in
    both client and service project. However, when you try building the
    solution, you found that the client app report error about the custom class
    object(type/namespace mismatch), correct?

    Based on my experience, this is an expected behavior when your webservice
    method use a custom class(an this class has also been shared in client
    project). Because for webservice, the client-side proxy will also generate
    a delegate class type (together with the proxy class), therefore, the
    generated webproxy class will use that delegate class type by default( that
    is the "nsProgram.wsWe b.Data" in your case). And if you try passing the
    originally defined class type( that is "nsProgram.Data " in your case), it
    will report type mismatch error.

    To resolve this , you can consider the following means:

    1. Just let client application use the generated proxy class type instead
    of the originally server-side type

    2. You can manually modify the generated proxy class(modify the
    Reference.cs file ...) and change those "delegate class" to your own class
    type. However, this update will be erased whenever you update the
    webreference. To further overcome this problem, you can use partial class
    feature to put your own customized proxy code logic:

    #How to customize the Web Service proxy generated by wsdl.exe (or add web
    references)

    eb-service-proxy-generated-by-wsdl-exe-or-add-web-references.aspx

    Sincerely,

    Steven Cheng

    Microsoft MSDN Online Support Lead



    =============== =============== =============== =====

    Get notification to my posts through email? Please refer to
    Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

    ications.



    Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
    where an initial response from the community or a Microsoft Support
    Engineer within 1 business day is acceptable. Please note that each follow
    up response may take approximately 2 business days as the support
    professional working with you may need further investigation to reach the
    most efficient resolution. The offering is not appropriate for situations
    that require urgent, real-time or phone-based interactions or complex
    project analysis and dump analysis issues. Issues of this nature are best
    handled working with a dedicated Microsoft Support Engineer by contacting
    Microsoft Customer Support Services (CSS) at
    http://msdn.microsoft.com/subscripti...t/default.aspx.

    =============== =============== =============== =====


    This posting is provided "AS IS" with no warranties, and confers no rights.

    --------------------
    From: "Simon" <none@none.co m>
    Subject: Problems with namespaces
    Date: Wed, 2 Jan 2008 08:54:55 +0100

    I have problem with namespaces. I have a program that consumes the web
    service and has for instance names space nsProgram. In this program I have
    defined several classes that I use for storing and handling internal
    information. Than I have web service, that also uses the same classes (I
    included the file as linked external resource). I included this web service
    as web reference and used name wsWeb.

    When I am trying to call the web service with parameter that is my class
    (for instance Data) I can declare this Data class in my main program
    without
    any problem, but compiler reports an error:
    Error 1 The best overloaded method match for
    'nsProgram.wsWe b.WebData.Test( 'nsProgram.wsWe b.Header)' has some invalid
    arguments
    Error 2 Argument '1': cannot convert from 'nsProgram.Data ' to
    'nsProgram.wsWe b.Data'

    Why is the wsWeb also included for all data types? How can I get around
    that?

    Thank you

    Simon


    Comment

    • John Saunders [MVP]

      #3
      Re: Problems with namespaces

      "Simon" <none@none.comw rote in message
      news:D8658B36-F7C5-446A-934E-9CEA71D53782@mi crosoft.com...
      >I have problem with namespaces. I have a program that consumes the web
      >service and has for instance names space nsProgram. In this program I have
      >defined several classes that I use for storing and handling internal
      >information. Than I have web service, that also uses the same classes (I
      >included the file as linked external resource). I included this web service
      >as web reference and used name wsWeb.
      >
      When I am trying to call the web service with parameter that is my class
      (for instance Data) I can declare this Data class in my main program
      without any problem, but compiler reports an error:
      Error 1 The best overloaded method match for
      'nsProgram.wsWe b.WebData.Test( 'nsProgram.wsWe b.Header)' has some invalid
      arguments
      Error 2 Argument '1': cannot convert from 'nsProgram.Data ' to
      'nsProgram.wsWe b.Data'
      >
      Why is the wsWeb also included for all data types? How can I get around
      that?
      The classes in your client are proxy classes. They are not the same as the
      classes used by the server, and they're not meant to be the same.
      --
      --------------------------------------------------------------------------------
      John Saunders | MVP - Windows Server System - Connected System Developer


      Comment

      • Simon

        #4
        Re: Problems with namespaces

        Steven thank you for the answer.

        Maybe it would be better if you could tell me what would be the preferred
        way to handle this. The situation is:

        1. I have several classes that will be used in different parts of the
        application and web service. They are gathered in one CS file.

        2. I have application that uses these types and also consumes web
        service that uses data types.

        3. I have web service that uses some classes for internal operations and
        some classes for data exchange. They are all declared in CS file.

        How can I define this and not get and problems with namespaces?

        Best regards

        Simon


        "Steven Cheng[MSFT]" <stcheng@online .microsoft.comw rote in message
        news:TWKnuZSTIH A.7612@TK2MSFTN GHUB02.phx.gbl. ..
        Hi Simon,
        >
        From your description, you're consuming a .NET webservice in an client
        app.
        The webservice has some certain custom data classes which will be shared
        in
        both client and service project. However, when you try building the
        solution, you found that the client app report error about the custom
        class
        object(type/namespace mismatch), correct?
        >
        Based on my experience, this is an expected behavior when your webservice
        method use a custom class(an this class has also been shared in client
        project). Because for webservice, the client-side proxy will also
        generate
        a delegate class type (together with the proxy class), therefore, the
        generated webproxy class will use that delegate class type by default(
        that
        is the "nsProgram.wsWe b.Data" in your case). And if you try passing the
        originally defined class type( that is "nsProgram.Data " in your case), it
        will report type mismatch error.
        >
        To resolve this , you can consider the following means:
        >
        1. Just let client application use the generated proxy class type instead
        of the originally server-side type
        >
        2. You can manually modify the generated proxy class(modify the
        Reference.cs file ...) and change those "delegate class" to your own class
        type. However, this update will be erased whenever you update the
        webreference. To further overcome this problem, you can use partial class
        feature to put your own customized proxy code logic:
        >
        #How to customize the Web Service proxy generated by wsdl.exe (or add web
        references)

        eb-service-proxy-generated-by-wsdl-exe-or-add-web-references.aspx
        >
        Sincerely,
        >
        Steven Cheng
        >
        Microsoft MSDN Online Support Lead
        >
        >
        >
        =============== =============== =============== =====
        >
        Get notification to my posts through email? Please refer to
        Find official documentation, practical know-how, and expert guidance for builders working and troubleshooting in Microsoft products.

        ications.
        >
        >
        >
        Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
        where an initial response from the community or a Microsoft Support
        Engineer within 1 business day is acceptable. Please note that each follow
        up response may take approximately 2 business days as the support
        professional working with you may need further investigation to reach the
        most efficient resolution. The offering is not appropriate for situations
        that require urgent, real-time or phone-based interactions or complex
        project analysis and dump analysis issues. Issues of this nature are best
        handled working with a dedicated Microsoft Support Engineer by contacting
        Microsoft Customer Support Services (CSS) at
        http://msdn.microsoft.com/subscripti...t/default.aspx.
        >
        =============== =============== =============== =====
        >
        >
        This posting is provided "AS IS" with no warranties, and confers no
        rights.
        >
        --------------------
        From: "Simon" <none@none.co m>
        Subject: Problems with namespaces
        Date: Wed, 2 Jan 2008 08:54:55 +0100
        >
        I have problem with namespaces. I have a program that consumes the web
        service and has for instance names space nsProgram. In this program I have
        defined several classes that I use for storing and handling internal
        information. Than I have web service, that also uses the same classes (I
        included the file as linked external resource). I included this web
        service
        as web reference and used name wsWeb.
        >
        When I am trying to call the web service with parameter that is my class
        (for instance Data) I can declare this Data class in my main program
        without
        any problem, but compiler reports an error:
        Error 1 The best overloaded method match for
        'nsProgram.wsWe b.WebData.Test( 'nsProgram.wsWe b.Header)' has some invalid
        arguments
        Error 2 Argument '1': cannot convert from 'nsProgram.Data ' to
        'nsProgram.wsWe b.Data'
        >
        Why is the wsWeb also included for all data types? How can I get around
        that?
        >
        Thank you
        >
        Simon
        >
        >

        Comment

        • Steven Cheng[MSFT]

          #5
          Re: Problems with namespaces

          Hi Simon,

          For those classes, if you want to share them in non-webservice projects
          also, I suggest you move them into a separate class library project and all
          the other projects(need those classes ) reference that class library.

          For webservice, it is a fixed behavior that the generated client proxy will
          always create its own version of any custom type/classes that will be used
          in webservice methods(as parameter or return value). Therefore, if you want
          to use your own type(defined in class library above), you should manually
          change the generated proxy's code. Or if it is ok to use the proxy
          generated classes, then, just change the namespace to those proxy generated
          classes' namespace.

          Sincerely,

          Steven Cheng

          Microsoft MSDN Online Support Lead


          This posting is provided "AS IS" with no warranties, and confers no rights.

          --------------------
          From: "Simon" <none@none.co m>
          References: <D8658B36-F7C5-446A-934E-9CEA71D53782@mi crosoft.com>
          <TWKnuZSTIHA.76 12@TK2MSFTNGHUB 02.phx.gbl>
          In-Reply-To: <TWKnuZSTIHA.76 12@TK2MSFTNGHUB 02.phx.gbl>
          Subject: Re: Problems with namespaces
          Date: Wed, 2 Jan 2008 17:05:46 +0100

          Steven thank you for the answer.

          Maybe it would be better if you could tell me what would be the preferred
          way to handle this. The situation is:

          1. I have several classes that will be used in different parts of the
          application and web service. They are gathered in one CS file.

          2. I have application that uses these types and also consumes web
          service that uses data types.

          3. I have web service that uses some classes for internal operations
          and
          some classes for data exchange. They are all declared in CS file.

          How can I define this and not get and problems with namespaces?

          Best regards

          Simon


          "Steven Cheng[MSFT]" <stcheng@online .microsoft.comw rote in message
          news:TWKnuZSTIH A.7612@TK2MSFTN GHUB02.phx.gbl. ..
          Hi Simon,
          >
          From your description, you're consuming a .NET webservice in an client
          app.
          The webservice has some certain custom data classes which will be shared
          in
          both client and service project. However, when you try building the
          solution, you found that the client app report error about the custom
          class
          object(type/namespace mismatch), correct?
          >
          Based on my experience, this is an expected behavior when your webservice
          method use a custom class(an this class has also been shared in client
          project). Because for webservice, the client-side proxy will also
          generate
          a delegate class type (together with the proxy class), therefore, the
          generated webproxy class will use that delegate class type by default(
          that
          is the "nsProgram.wsWe b.Data" in your case). And if you try passing the
          originally defined class type( that is "nsProgram.Data " in your case), it
          will report type mismatch error.
          >
          To resolve this , you can consider the following means:
          >
          1. Just let client application use the generated proxy class type instead
          of the originally server-side type
          >
          2. You can manually modify the generated proxy class(modify the
          Reference.cs file ...) and change those "delegate class" to your own class
          type. However, this update will be erased whenever you update the
          webreference. To further overcome this problem, you can use partial class
          feature to put your own customized proxy code logic:
          >
          #How to customize the Web Service proxy generated by wsdl.exe (or add web
          references)
          >
          http://blogs.msdn.com/maximelamure/a...ustomize-the-w
          eb-service-proxy-generated-by-wsdl-exe-or-add-web-references.aspx
          >
          Sincerely,
          >
          Steven Cheng
          >
          Microsoft MSDN Online Support Lead
          >
          >
          >
          =============== =============== =============== =====
          >
          Get notification to my posts through email? Please refer to
          >
          http://msdn.microsoft.com/subscripti...ult.aspx#notif
          ications.
          >
          >
          >
          Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
          where an initial response from the community or a Microsoft Support
          Engineer within 1 business day is acceptable. Please note that each follow
          up response may take approximately 2 business days as the support
          professional working with you may need further investigation to reach the
          most efficient resolution. The offering is not appropriate for situations
          that require urgent, real-time or phone-based interactions or complex
          project analysis and dump analysis issues. Issues of this nature are best
          handled working with a dedicated Microsoft Support Engineer by contacting
          Microsoft Customer Support Services (CSS) at
          http://msdn.microsoft.com/subscripti...t/default.aspx.
          >
          =============== =============== =============== =====
          >
          >
          This posting is provided "AS IS" with no warranties, and confers no
          rights.
          >
          --------------------
          From: "Simon" <none@none.co m>
          Subject: Problems with namespaces
          Date: Wed, 2 Jan 2008 08:54:55 +0100
          >
          I have problem with namespaces. I have a program that consumes the web
          service and has for instance names space nsProgram. In this program I have
          defined several classes that I use for storing and handling internal
          information. Than I have web service, that also uses the same classes (I
          included the file as linked external resource). I included this web
          service
          as web reference and used name wsWeb.
          >
          When I am trying to call the web service with parameter that is my class
          (for instance Data) I can declare this Data class in my main program
          without
          any problem, but compiler reports an error:
          Error 1 The best overloaded method match for
          'nsProgram.wsWe b.WebData.Test( 'nsProgram.wsWe b.Header)' has some invalid
          arguments
          Error 2 Argument '1': cannot convert from 'nsProgram.Data ' to
          'nsProgram.wsWe b.Data'
          >
          Why is the wsWeb also included for all data types? How can I get around
          that?
          >
          Thank you
          >
          Simon
          >
          >

          Comment

          • Steven Cheng[MSFT]

            #6
            Re: Problems with namespaces

            Hi Simon,

            Have you got any progress on this? If you have any other questions, please
            feel free to post here.

            Sincerely,

            Steven Cheng

            Microsoft MSDN Online Support Lead


            This posting is provided "AS IS" with no warranties, and confers no rights.

            --------------------
            From: stcheng@online. microsoft.com (Steven Cheng[MSFT])
            Organization: Microsoft
            Date: Thu, 03 Jan 2008 02:33:51 GMT
            Subject: Re: Problems with namespaces

            Hi Simon,

            For those classes, if you want to share them in non-webservice projects
            also, I suggest you move them into a separate class library project and all
            the other projects(need those classes ) reference that class library.

            For webservice, it is a fixed behavior that the generated client proxy will
            always create its own version of any custom type/classes that will be used
            in webservice methods(as parameter or return value). Therefore, if you want
            to use your own type(defined in class library above), you should manually
            change the generated proxy's code. Or if it is ok to use the proxy
            generated classes, then, just change the namespace to those proxy generated
            classes' namespace.

            Sincerely,

            Steven Cheng

            Microsoft MSDN Online Support Lead


            This posting is provided "AS IS" with no warranties, and confers no rights.

            --------------------
            From: "Simon" <none@none.co m>
            References: <D8658B36-F7C5-446A-934E-9CEA71D53782@mi crosoft.com>
            <TWKnuZSTIHA.76 12@TK2MSFTNGHUB 02.phx.gbl>
            In-Reply-To: <TWKnuZSTIHA.76 12@TK2MSFTNGHUB 02.phx.gbl>
            Subject: Re: Problems with namespaces
            Date: Wed, 2 Jan 2008 17:05:46 +0100

            Steven thank you for the answer.

            Maybe it would be better if you could tell me what would be the preferred
            way to handle this. The situation is:

            1. I have several classes that will be used in different parts of the
            application and web service. They are gathered in one CS file.

            2. I have application that uses these types and also consumes web
            service that uses data types.

            3. I have web service that uses some classes for internal operations
            and
            some classes for data exchange. They are all declared in CS file.

            How can I define this and not get and problems with namespaces?

            Best regards

            Simon


            "Steven Cheng[MSFT]" <stcheng@online .microsoft.comw rote in message
            news:TWKnuZSTIH A.7612@TK2MSFTN GHUB02.phx.gbl. ..
            Hi Simon,
            >
            From your description, you're consuming a .NET webservice in an client
            app.
            The webservice has some certain custom data classes which will be shared
            in
            both client and service project. However, when you try building the
            solution, you found that the client app report error about the custom
            class
            object(type/namespace mismatch), correct?
            >
            Based on my experience, this is an expected behavior when your webservice
            method use a custom class(an this class has also been shared in client
            project). Because for webservice, the client-side proxy will also
            generate
            a delegate class type (together with the proxy class), therefore, the
            generated webproxy class will use that delegate class type by default(
            that
            is the "nsProgram.wsWe b.Data" in your case). And if you try passing the
            originally defined class type( that is "nsProgram.Data " in your case), it
            will report type mismatch error.
            >
            To resolve this , you can consider the following means:
            >
            1. Just let client application use the generated proxy class type instead
            of the originally server-side type
            >
            2. You can manually modify the generated proxy class(modify the
            Reference.cs file ...) and change those "delegate class" to your own class
            type. However, this update will be erased whenever you update the
            webreference. To further overcome this problem, you can use partial class
            feature to put your own customized proxy code logic:
            >
            #How to customize the Web Service proxy generated by wsdl.exe (or add web
            references)
            >
            http://blogs.msdn.com/maximelamure/a...ustomize-the-w
            eb-service-proxy-generated-by-wsdl-exe-or-add-web-references.aspx
            >
            Sincerely,
            >
            Steven Cheng
            >
            Microsoft MSDN Online Support Lead
            >
            >
            >
            =============== =============== =============== =====
            >
            Get notification to my posts through email? Please refer to
            >
            http://msdn.microsoft.com/subscripti...ult.aspx#notif
            ications.
            >
            >
            >
            Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
            where an initial response from the community or a Microsoft Support
            Engineer within 1 business day is acceptable. Please note that each follow
            up response may take approximately 2 business days as the support
            professional working with you may need further investigation to reach the
            most efficient resolution. The offering is not appropriate for situations
            that require urgent, real-time or phone-based interactions or complex
            project analysis and dump analysis issues. Issues of this nature are best
            handled working with a dedicated Microsoft Support Engineer by contacting
            Microsoft Customer Support Services (CSS) at
            http://msdn.microsoft.com/subscripti...t/default.aspx.
            >
            =============== =============== =============== =====
            >
            >
            This posting is provided "AS IS" with no warranties, and confers no
            rights.
            >
            --------------------
            From: "Simon" <none@none.co m>
            Subject: Problems with namespaces
            Date: Wed, 2 Jan 2008 08:54:55 +0100
            >
            I have problem with namespaces. I have a program that consumes the web
            service and has for instance names space nsProgram. In this program I have
            defined several classes that I use for storing and handling internal
            information. Than I have web service, that also uses the same classes (I
            included the file as linked external resource). I included this web
            service
            as web reference and used name wsWeb.
            >
            When I am trying to call the web service with parameter that is my class
            (for instance Data) I can declare this Data class in my main program
            without
            any problem, but compiler reports an error:
            Error 1 The best overloaded method match for
            'nsProgram.wsWe b.WebData.Test( 'nsProgram.wsWe b.Header)' has some invalid
            arguments
            Error 2 Argument '1': cannot convert from 'nsProgram.Data ' to
            'nsProgram.wsWe b.Data'
            >
            Why is the wsWeb also included for all data types? How can I get around
            that?
            >
            Thank you
            >
            Simon
            >
            >



            Comment

            Working...