473,385 Members | 1,356 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

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

How do I get the Web Service address?

I'm writing a client (C#) for an ASP.NET 2.0 Web Service. From within the client, with its web reference to the Web Service, how do I get the Web Service address as a string? Since the address must be known to the client, I guess there must be a simple way to do it.

Gustaf
Sep 12 '07 #1
5 1422
"Gustaf" <gu*****@algonet.sewrote in message
news:%2***************@TK2MSFTNGP04.phx.gbl...
I'm writing a client (C#) for an ASP.NET 2.0 Web Service. From within the
client, with its web reference to the Web Service, how do I get the Web
Service address as a string? Since the address must be known to the
client, I guess there must be a simple way to do it.
The address is in the Url property of your proxy object.
--
--------------------------------------------------------------------------------
John Saunders | MVP - Windows Server System - Connected System Developer

Sep 12 '07 #2
John Saunders [MVP] wrote:
>I'm writing a client (C#) for an ASP.NET 2.0 Web Service. From within
the client, with its web reference to the Web Service, how do I get
the Web Service address as a string? Since the address must be known
to the client, I guess there must be a simple way to do it.

The address is in the Url property of your proxy object.
Thank you! Another related question: is it possible to change the Url property at run-time, so that you can build a client that can switch between a test and deployment server?

Gustaf
Sep 14 '07 #3
On Sep 14, 8:58 pm, Gustaf <gust...@algonet.sewrote:
John Saunders [MVP] wrote:
I'm writing a client (C#) for an ASP.NET 2.0 Web Service. From within
the client, with its web reference to the Web Service, how do I get
the Web Service address as a string? Since the address must be known
to the client, I guess there must be a simple way to do it.
The address is in the Url property of your proxy object.

Thank you! Another related question: is it possible to change the Url property at run-time, so that you can build a client that can switch between a test and deployment server?

Gustaf
yes, just do MyWebService.URL = "http://www.mypage.com/service.asmx"
Sep 14 '07 #4
densial wrote:
>Thank you! Another related question: is it possible to change the
Url property at run-time, so that you can build a client that can
switch between a test and deployment server?

yes, just do MyWebService.URL = "http://www.mypage.com/service.asmx"
Sounds good. What I worry about is that this will clash with the automatic settings that comes from adding a Web Reference. I suppose when you create a flexible client like this, the way to go is to use wsdl.exe and import the generated classes manually, rather than using the Web Reference wizard. That's what I tried to do now.

Unfortunately, the imported proxy class doesn't expose any Uri method to set, so I added some code for this:

public MyWebService()
{
this.Url = null;
}

public new string Url
{
get { return this.Url; }
set { this.Url = value; }
}

The new keyword is there to clarify that I hide the inherited member 'System.Web.Services.Protocols.WebClientProtocol.U rl'. But I'm not sure if that's really what I want to do. What do you think?

Gustaf
Sep 14 '07 #5
I wrote:
Sounds good. What I worry about is that this will clash with the
automatic settings that comes from adding a Web Reference. I suppose
when you create a flexible client like this, the way to go is to use
wsdl.exe and import the generated classes manually, rather than using
the Web Reference wizard. That's what I tried to do now.
Nevermind this comment. I got it working. now. :-)

Gustaf
Sep 14 '07 #6

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

Similar topics

4
by: Joe | last post by:
I'm hosting my web service on a Windows 2003 box which is remotely located. When trying to add a web reference to a C# project I get an error message 'There was an error downloading...
3
by: Roland Riess | last post by:
Hi all, as an absolute beginner with all web matters I'm sure there are still many things that I do net understand yet - so please point me to the right direction whereever you feel that I'm...
0
by: pwilliams | last post by:
NCOALink Change of Address Verification Each year over 40 million Americans change their mailing addresses. This change is equivalent to every person in California deciding to change addresses...
2
by: Richard Collette | last post by:
Hi, I have a service, that runs perfectly when executed outside of the web service environment. When called as a web service I get the exception listed below sporadically. A call to the web...
5
by: mivey4 | last post by:
Hi, First off, I am aware that this is a very heavily documented error and I have done my homework for throughly researching probable causes before deciding to post my problem here. At this point,...
3
dmjpro
by: dmjpro | last post by:
plz send me a good link which can clearify me how the J2EE framework works i want the details information .... plz help thanx
0
by: =?Utf-8?B?QWRyaWFuIENvbGU=?= | last post by:
I have written a simple WCF service hosted in a Windows console application and a simple WCF client console application that connects successfully to that service and retrieves data. I then ported...
4
by: Dylan | last post by:
Hello, I was trying to do a WCF tutorial (http://wcf.netfx3.com/content/ BuildingHelloWorld.aspx). I need to get the meta data from my service usin svcutil.exe why is not working? Please see...
1
by: =?Utf-8?B?S2F1c2hhbCBNZWh0YQ==?= | last post by:
Hi, Could you let me know what exactly happens when web service provider receives request from the client (from system perspective, like threading and all) ? Also, how does the web service...
3
by: kkao77 | last post by:
can you show me in more detail? I have same problem where on the page it's https://service.premilance.com/Company.svc, but the svcutil tells me to get it from https://pserver1/Company.svc?wsdl...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.