473,507 Members | 2,375 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Set WebService Namespace attribute at runtime

I have a webservice class MyService.asmx.cs with:
namespace XMLWS

{
[WebService(Namespace = "http://mydomain.com/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]

public class Poster : System.Web.Services.WebService

{
[WebMethod]public int MyMethod()

This web service is intended to developed for different customers that
will be installed and used for different domains, Some article says
that changing web server namespace at runtime is not something should
do. "The namespace is just a contract definition and if one specific
webservice is deployed to two different servers it should use the same
namespace on both. The url used in the namespace has no actual
meaning. By convention, you should use the your own domain, and append
to it to make it unique for the specific service (http://
www.yourdomain.com/poster)" But, since my web service is designed for
different costumers, and the changing and recompiling of code for each
for them is not something I think I should do.

Any suggestions? comments?

Thank you.
Jul 21 '08 #1
3 2776
<hu********@gmail.comwrote in message
news:cd**********************************@f36g2000 hsa.googlegroups.com...
I have a webservice class MyService.asmx.cs with:
namespace XMLWS

{
[WebService(Namespace = "http://mydomain.com/")]

[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]

public class Poster : System.Web.Services.WebService

{
[WebMethod]public int MyMethod()

This web service is intended to developed for different customers that
will be installed and used for different domains, Some article says
that changing web server namespace at runtime is not something should
do. "The namespace is just a contract definition and if one specific
webservice is deployed to two different servers it should use the same
namespace on both. The url used in the namespace has no actual
meaning. By convention, you should use the your own domain, and append
to it to make it unique for the specific service (http://
www.yourdomain.com/poster)" But, since my web service is designed for
different costumers, and the changing and recompiling of code for each
for them is not something I think I should do.
Do not change the namespace. It has nothing to do with the URL at which the
service is deployed. It has to do with the contract, and you're not changing
the contract from one customer to the next.
--
John Saunders | MVP - Connected System Developer

Jul 21 '08 #2
On Jul 21, 10:46*am, "John Saunders" <n...@dont.do.that.comwrote:
<huohaod...@gmail.comwrote in message

news:cd**********************************@f36g2000 hsa.googlegroups.com...
I have a webservice class MyService.asmx.cs with:
namespace XMLWS
{
[WebService(Namespace = "http://mydomain.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Poster : System.Web.Services.WebService
{
[WebMethod]public int MyMethod()
This web service is intended to developed for different customers that
will be installed and used for different domains, Some article says
that changing web server namespace at runtime is not something should
do. "The namespace is just a contract definition and if one specific
webservice is deployed to two different servers it should use the same
namespace on both. The url used in the namespace has no actual
meaning. By convention, you should use the your own domain, and append
to it to make it unique for the specific service (http://
www.yourdomain.com/poster)" *But, since my web service is designed for
different costumers, and the changing and recompiling of code for each
for them *is not something I think I should do.

Do not change the namespace. It has nothing to do with the URL at which the
service is deployed. It has to do with the contract, and you're not changing
the contract from one customer to the next.
--
John Saunders | MVP - Connected System Developer

Thanks for the response.
If I develop my web services for the AAA.com and BBB.com, how should
I define the wsdl's definitions to something like
targetNamespace="http://www.aaa.com/webservices" and
targetNamespace="http://www.bbb.com/webservices" respectively?

Thanks again.

Jul 21 '08 #3
<hu********@gmail.comwrote in message
news:17**********************************@m36g2000 hse.googlegroups.com...
On Jul 21, 10:46 am, "John Saunders" <n...@dont.do.that.comwrote:
><huohaod...@gmail.comwrote in message

news:cd**********************************@f36g200 0hsa.googlegroups.com...
I have a webservice class MyService.asmx.cs with:
namespace XMLWS
{
[WebService(Namespace = "http://mydomain.com/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ToolboxItem(false)]
public class Poster : System.Web.Services.WebService
{
[WebMethod]public int MyMethod()
This web service is intended to developed for different customers that
will be installed and used for different domains, Some article says
that changing web server namespace at runtime is not something should
do. "The namespace is just a contract definition and if one specific
webservice is deployed to two different servers it should use the same
namespace on both. The url used in the namespace has no actual
meaning. By convention, you should use the your own domain, and append
to it to make it unique for the specific service (http://
www.yourdomain.com/poster)" But, since my web service is designed for
different costumers, and the changing and recompiling of code for each
for them is not something I think I should do.

Do not change the namespace. It has nothing to do with the URL at which
the
service is deployed. It has to do with the contract, and you're not
changing
the contract from one customer to the next.
--
John Saunders | MVP - Connected System Developer


Thanks for the response.
If I develop my web services for the AAA.com and BBB.com, how should
I define the wsdl's definitions to something like
targetNamespace="http://www.aaa.com/webservices" and
targetNamespace="http://www.bbb.com/webservices" respectively?

It's a common misconception, but the namespaces are not URLs. They have
nothing to do with locations on the Internet. They are simply names, in a
particular format, used to disambiguate names in an XML document. It's
similar to the idea of namespaces in .NET, which allow you to have a class
named "huohaodian.Exception" and me to have a class named
"JohnSaunders.Exception" and for them to be seen as different names.

They are actually in the format of a URI (Universal Resource _Identifier_).
One form of a URI is a URL, which is an identifier that also represents the
location from which the identified resource may be retrieved. But the more
general form is a URI.

One example of a URI is "urn:schemas-microsoft-com:xml-msdatasource".

So, don't worry about it. Use a unique namespace that you devise for your
own web service. These namespaces need to be unique within your
organization, otherwise there can be confusion between the same name used in
two of your different web services. This means you will need some way to
keep track of namespaces you use, or at least a pattern of generating them
that will tend to prevent duplication. For example, you might use something
like
"http://www.yourcompany.com/division/department/application/service/wsdl/2008/07"
This sort of format, for instance, enables you to produce a different
version of the same service, with changes, at a later date, just by changing
the date part at the end.
--
John Saunders | MVP - Connected System Developer

Jul 22 '08 #4

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

Similar topics

4
3375
by: Jens | last post by:
Hello, i am trying to call a Apache WebService, which accepts NULL-Values for some Parameters of a specific Web-Method. NULL-Values are mapped within the soap-request by the .NET Client...
12
4103
by: Jose Fernandez | last post by:
Hello. I'm building a web service and I get this error. NEWS.News.CoverNews(string)': not all code paths return a value This is the WebMethod public SqlDataReader CoverNews(string Sport)...
7
5365
by: stephan querengaesser | last post by:
hi ng, i try to invoke a webservice-method with an filter-object, that contains value types. if i don´t want to filter the return value of the method, i have to pass a new instance of the...
7
4959
by: Christian Wilhelm | last post by:
Hi! I'm trying to call a Java WebService out of a .net Client. There are two Methods, one Method requires one Parameter of type Parameter, the other Method requires one Parameter of type...
2
2734
by: yqlu | last post by:
I hava developed a client in C# that is connected to a 3-party XML Web Services developed in Java based on the AXIS 1.1. Most methods call are successful except for one method named "findObjects"...
7
2899
by: Nalaka | last post by:
Hi, I created a sinple web service that returns a dataSet. Then I created a client program that uses this web service (that returns the Dataset). My question is, how did the client figure...
1
4014
by: jens Jensen | last post by:
Hello , i'm calling a webservice generated with oracle webservice java tools. I'm not able to add a web reference to a .net client the usual way with visual studio 2005. I was therefore...
0
755
by: Kirk | last post by:
I'm trying to use a Web Service to be a Remoting client of an existing ..NET 2.0 server. But I get the following error when I try to use System.Runtime.Remoting.Channels.Http in my WebService. ...
0
1388
by: Nogusta123 | last post by:
My web service has a single method called "CheckEligibility". This method can be used to check a person's eligibility for multiple products. Each product has different data requiements so each...
0
7223
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7111
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7319
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7376
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7031
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
4702
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3191
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3179
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
760
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.