Re: Problems with namespaces



{\rtf1\ansi\ansicpg936\deff0\deflang1033\deflangfe2052{\fonttbl{\f0\fnil\fprq2\fcharset0 MS Sans Serif;}}
\viewkind4\uc1\pard\lang2052\f0\fs20 Hi Simon,
\par
\par 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.
\par
\par 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.
\par
\par Sincerely,
\par
\par Steven Cheng
\par
\par Microsoft MSDN Online Support Lead
\par \tab
\par
\par This posting is provided "AS IS" with no warranties, and confers no rights.
\par
\par \pard\li720 --------------------
\par From: "Simon" <none@xxxxxxxx>
\par References: <D8658B36-F7C5-446A-934E-9CEA71D53782@xxxxxxxxxxxxx> <TWKnuZSTIHA.7612@xxxxxxxxxxxxxxxxxxxxxx>
\par In-Reply-To: <TWKnuZSTIHA.7612@xxxxxxxxxxxxxxxxxxxxxx>
\par Subject: Re: Problems with namespaces
\par Date: Wed, 2 Jan 2008 17:05:46 +0100
\par
\par Steven thank you for the answer.
\par
\par Maybe it would be better if you could tell me what would be the preferred
\par way to handle this. The situation is:
\par
\par 1. I have several classes that will be used in different parts of the
\par application and web service. They are gathered in one CS file.
\par
\par 2. I have application that uses these types and also consumes web
\par service that uses data types.
\par
\par 3. I have web service that uses some classes for internal operations and
\par some classes for data exchange. They are all declared in CS file.
\par
\par How can I define this and not get and problems with namespaces?
\par
\par Best regards
\par
\par Simon
\par
\par
\par "Steven Cheng[MSFT]" <stcheng@xxxxxxxxxxxxxxxxxxxx> wrote in message
\par news:TWKnuZSTIHA.7612@xxxxxxxxxxxxxxxxxxxxxxxxx
\par > Hi Simon,
\par >
\par > From your description, you're consuming a .NET webservice in an client
\par > app.
\par > The webservice has some certain custom data classes which will be shared
\par > in
\par > both client and service project. However, when you try building the
\par > solution, you found that the client app report error about the custom
\par > class
\par > object(type/namespace mismatch), correct?
\par >
\par > Based on my experience, this is an expected behavior when your webservice
\par > method use a custom class(an this class has also been shared in client
\par > project). Because for webservice, the client-side proxy will also
\par > generate
\par > a delegate class type (together with the proxy class), therefore, the
\par > generated webproxy class will use that delegate class type by default(
\par > that
\par > is the "nsProgram.wsWeb.Data" in your case). And if you try passing the
\par > originally defined class type( that is "nsProgram.Data" in your case), it
\par > will report type mismatch error.
\par >
\par > To resolve this , you can consider the following means:
\par >
\par > 1. Just let client application use the generated proxy class type instead
\par > of the originally server-side type
\par >
\par > 2. You can manually modify the generated proxy class(modify the
\par > Reference.cs file ...) and change those "delegate class" to your own class
\par > type. However, this update will be erased whenever you update the
\par > webreference. To further overcome this problem, you can use partial class
\par > feature to put your own customized proxy code logic:
\par >
\par > #How to customize the Web Service proxy generated by wsdl.exe (or add web
\par > references)
\par > http://blogs.msdn.com/maximelamure/archive/2007/08/31/how-to-customize-the-w
\par > eb-service-proxy-generated-by-wsdl-exe-or-add-web-references.aspx
\par >
\par > Sincerely,
\par >
\par > Steven Cheng
\par >
\par > Microsoft MSDN Online Support Lead
\par >
\par >
\par >
\par > ==================================================
\par >
\par > Get notification to my posts through email? Please refer to
\par > http://msdn.microsoft.com/subscriptions/managednewsgroups/default.aspx#notif
\par > ications.
\par >
\par >
\par >
\par > Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
\par > where an initial response from the community or a Microsoft Support
\par > Engineer within 1 business day is acceptable. Please note that each follow
\par > up response may take approximately 2 business days as the support
\par > professional working with you may need further investigation to reach the
\par > most efficient resolution. The offering is not appropriate for situations
\par > that require urgent, real-time or phone-based interactions or complex
\par > project analysis and dump analysis issues. Issues of this nature are best
\par > handled working with a dedicated Microsoft Support Engineer by contacting
\par > Microsoft Customer Support Services (CSS) at
\par > http://msdn.microsoft.com/subscriptions/support/default.aspx.
\par >
\par > ==================================================
\par >
\par >
\par > This posting is provided "AS IS" with no warranties, and confers no
\par > rights.
\par >
\par > --------------------
\par > From: "Simon" <none@xxxxxxxx>
\par > Subject: Problems with namespaces
\par > Date: Wed, 2 Jan 2008 08:54:55 +0100
\par >
\par > I have problem with namespaces. I have a program that consumes the web
\par > service and has for instance names space nsProgram. In this program I have
\par > defined several classes that I use for storing and handling internal
\par > information. Than I have web service, that also uses the same classes (I
\par > included the file as linked external resource). I included this web
\par > service
\par > as web reference and used name wsWeb.
\par >
\par > When I am trying to call the web service with parameter that is my class
\par > (for instance Data) I can declare this Data class in my main program
\par > without
\par > any problem, but compiler reports an error:
\par > Error 1 The best overloaded method match for
\par > 'nsProgram.wsWeb.WebData.Test('nsProgram.wsWeb.Header)' has some invalid
\par > arguments
\par > Error 2 Argument '1': cannot convert from 'nsProgram.Data' to
\par > 'nsProgram.wsWeb.Data'
\par >
\par > Why is the wsWeb also included for all data types? How can I get around
\par > that?
\par >
\par > Thank you
\par >
\par > Simon
\par >
\par >
\par
\par \pard
\par
\par }

Relevant Pages

  • Re: How to alias 2 classes in c#
    ... For ASP.NET webservice's client proxy, if you use "Add WebReference" to ... the type sharing support is still limited. ... where an initial response from the community or a Microsoft Support ... having 2 versions of a web service with a total compatibility ...
    (microsoft.public.dotnet.languages.csharp)
  • RE: How to alias 2 classes in c#
    ... For ASP.NET webservice's client proxy, if you use "Add WebReference" to ... it will always create a new copy of the custom types(even ... the type sharing support is still limited. ... having 2 versions of a web service with a total compatibility ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Problems with namespaces
    ... I have several classes that will be used in different parts of the application and web service. ... you found that the client app report error about the custom class ... the client-side proxy will also generate ... Microsoft MSDN Online Support Lead ...
    (microsoft.public.dotnet.framework.webservices)
  • RE: Problems with namespaces
    ... \par Microsoft MSDN Online Support Lead ... \par where an initial response from the community or a Microsoft Support ... Than I have web service, that also uses the same classes (I ... \par Simon ...
    (microsoft.public.dotnet.framework.webservices)
  • SOAP over SSL? NotSupportedException in generated client proxy code
    ... I used the wizards in VC.NET to generate code to generate a client proxy for ... a web service in the usual manner. ... System.NotSupportedException: The ServicePointManager does not support ...
    (microsoft.public.dotnet.framework.aspnet.webservices)