472,791 Members | 1,444 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,791 software developers and data experts.

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.wsWeb.WebData.Test('nsProgram.wsWeb.Hea der)' has some invalid
arguments
Error 2 Argument '1': cannot convert from 'nsProgram.Data' to
'nsProgram.wsWeb.Data'

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

Thank you

Simon

Jan 2 '08 #1
5 1527
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.wsWeb.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" <no**@none.com>
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.wsWeb.WebData.Test('nsProgram.wsWeb.Hea der)' has some invalid
arguments
Error 2 Argument '1': cannot convert from 'nsProgram.Data' to
'nsProgram.wsWeb.Data'

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

Thank you

Simon
Jan 2 '08 #2
"Simon" <no**@none.comwrote in message
news:D8**********************************@microsof t.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.wsWeb.WebData.Test('nsProgram.wsWeb.Hea der)' has some invalid
arguments
Error 2 Argument '1': cannot convert from 'nsProgram.Data' to
'nsProgram.wsWeb.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
Jan 2 '08 #3
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]" <st*****@online.microsoft.comwrote in message
news:TW**************@TK2MSFTNGHUB02.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.wsWeb.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" <no**@none.com>
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.wsWeb.WebData.Test('nsProgram.wsWeb.Hea der)' has some invalid
arguments
Error 2 Argument '1': cannot convert from 'nsProgram.Data' to
'nsProgram.wsWeb.Data'

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

Thank you

Simon

Jan 2 '08 #4
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" <no**@none.com>
References: <D8**********************************@microsoft.co m>
<TW**************@TK2MSFTNGHUB02.phx.gbl>
In-Reply-To: <TW**************@TK2MSFTNGHUB02.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]" <st*****@online.microsoft.comwrote in message
news:TW**************@TK2MSFTNGHUB02.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.wsWeb.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" <no**@none.com>
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.wsWeb.WebData.Test('nsProgram.wsWeb.Hea der)' has some invalid
arguments
Error 2 Argument '1': cannot convert from 'nsProgram.Data' to
'nsProgram.wsWeb.Data'

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

Thank you

Simon


Jan 3 '08 #5
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: st*****@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" <no**@none.com>
References: <D8**********************************@microsoft.co m>
<TW**************@TK2MSFTNGHUB02.phx.gbl>
In-Reply-To: <TW**************@TK2MSFTNGHUB02.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]" <st*****@online.microsoft.comwrote in message
news:TW**************@TK2MSFTNGHUB02.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.wsWeb.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" <no**@none.com>
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.wsWeb.WebData.Test('nsProgram.wsWeb.Hea der)' has some invalid
arguments
Error 2 Argument '1': cannot convert from 'nsProgram.Data' to
'nsProgram.wsWeb.Data'

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

Thank you

Simon


Jan 8 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Steven Bethard | last post by:
In the "empty classes as c structs?" thread, we've been talking in some detail about my proposed "generic objects" PEP. Based on a number of suggestions, I'm thinking more and more that instead of...
6
by: Stefan Franke | last post by:
Hi, I've got a little bit of a problem when dealing with namespaces and XPath. I'm trying very basic things, like showing all the nodes of one particular namespace. Here is my XPath statement:...
15
by: Rob Ratcliff | last post by:
I'm compiling the latest version of a CORBA ORB called MICO on a Cray X1. It makes heavy use of templates and namespaces. Up until the link step, the C++ source code compiled flawlessly. But, when...
11
by: Random | last post by:
I'm confused about the proper use and usefulness of namespaces. I beleive I understand the purpose is so the developer can put classes within namespaces to essentially organize your code. And I...
7
by: Railinc | last post by:
Hi... I'm trying to write a web service client and am running into a problem with getting a response back from the server. I know that a full xml message is being returned (thanks to a tcp/ip...
1
by: Keith Patrick | last post by:
I have an object, Teacher, that has a namespace. Let's call it http://foo. Teacher has a child object called Name, composed of String first, middle, last, etc. Problem I have is when I try to...
0
by: Tim_Mac | last post by:
hi, i have an aspx page, which loads a user control dynamically. (by the way i don't have any problems using namespaces in C# web projects, this seems to be just a VB thing). the user control...
84
by: jacob navia | last post by:
As many people know, I think that garbage collection is a good solution for many memory allocation problems. I am aware however, that nothing is "the silver bullet", not even the GC. A recent...
1
by: Ryan | last post by:
Hello Xml Gurus, I'm trying to build an XML schema in memory using the System.Xml.XmlSchema namespace objects, validate it, and then write it to a file. The problem I'm facing is that...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
0
by: lllomh | last post by:
How does React native implement an English player?
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.