Dynamic URL Failure

W

WhiskyRomeo

I have an solution with several projects which call a web service for the
data retrieval and updates.

The main program is called DMS.exe. When I configure the webservice to use
Dynamic URL and create entries in the app.config file of the following
format, the application can't find the webservice. Static works fine but I
have to set the url in code in every place a webservice is used.

<appSettings>
<add key="myApplication.myServer.Service1"
value="http://myServer/myXmlWebService/Service1.asmx"/>
</appSettings>

So given:

application name is DMS,
the web service project is called DMSDataWS,
the server is LASER,
the physcial path on the server is:\InetPub\wwwroot\DMSDataWS\wsCommon.asmx,
the virtual folder is named DMSDATAWS (under DefaultWebSite)
the service is name wsCommon.asmx

What should the entry look like? The following does not work.

<appSettings>
<add key="DMS.Laser.wsCommon.asmx"
value="http://LASER/DMSDATA/wsCommon.asmx"/>
</appSettings>
 
D

Dan Rogers

You should set the URL setting to be the URL of the service asmx entry
point. So if it is on a server named laser, it would start with
http://laser/....

Try debugging your application - are you sure you are getting the string in
your config file correctly and then using that to set the proxy URL
setting? You really only have to do this at the place you create your
proxy each time. If you can use a local string resource with the right URL
and that works, you can prove whether or not the string you need is coming
from the config file.

Something to be careful of is the \ character - make sure that you account
for it as the escape operator in any local strings (so you would have
"http:\\\\laser\\foo.asmx"

--------------------
 
W

WhiskyRomeo

Thanks for the reply . . .

When debugging it is obvious the URL did not come from the config file. But
what I don't know is -- did it fail because it couldn't find the key it was
looking for or what?

So my question remains what does the key look like so the lookup will
suceed? The URL I am using is correct because when I use the static mode, it
works correctly.

I can move it to the production server and set the URL each time I form the
proxy and it works fine. However, I don't want to have to go through code
and change it everytime I deploy to a different server.

I have another way to accomplish this, by I don't understand what is failing
with they dynamic URL route.

WR

Dan Rogers said:
You should set the URL setting to be the URL of the service asmx entry
point. So if it is on a server named laser, it would start with
http://laser/....

Try debugging your application - are you sure you are getting the string in
your config file correctly and then using that to set the proxy URL
setting? You really only have to do this at the place you create your
proxy each time. If you can use a local string resource with the right URL
and that works, you can prove whether or not the string you need is coming
from the config file.

Something to be careful of is the \ character - make sure that you account
for it as the escape operator in any local strings (so you would have
"http:\\\\laser\\foo.asmx"

--------------------
 
D

Dan Rogers

I think the problem is going to be in the code you use to get your
appsettings. If you don't specify a match on key name, you won't get the
data you want. What I'm suggesting is you debug your logic with
breakpoints so you can see what and when (or if) your code that gets the
appsettings is even accessed. You do have code that asks for the specific
app-setting don't you? There is no automatic app setting mapping done for
you to get a connection string.

--------------------
Thread-Topic: Dynamic URL Failure
thread-index: AcUj8rmKH5JcQEuXQaOmN2jbeWIMtQ==
X-WBNR-Posting-Host: 65.27.6.160
From: "=?Utf-8?B?V2hpc2t5Um9tZW8=?="
Subject: RE: Dynamic URL Failure
Date: Tue, 8 Mar 2005 07:23:05 -0800
Lines: 99
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 7bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.framework.aspnet.webservices
NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.1.29
Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSFTNGXA03.phx.gbl
Xref: TK2MSFTNGXA02.phx.gbl microsoft.public.dotnet.framework.aspnet.webservices:28492
X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet.webservices

Thanks for the reply . . .

When debugging it is obvious the URL did not come from the config file. But
what I don't know is -- did it fail because it couldn't find the key it was
looking for or what?

So my question remains what does the key look like so the lookup will
suceed? The URL I am using is correct because when I use the static mode, it
works correctly.

I can move it to the production server and set the URL each time I form the
proxy and it works fine. However, I don't want to have to go through code
and change it everytime I deploy to a different server.

I have another way to accomplish this, by I don't understand what is failing
with they dynamic URL route.

WR
 
W

WhiskyRomeo

The article on which I am basing my question is:

Redirecting an Application to Target a Different XML Web Service During
Installation

I found it by searching VS Help using "Dynamic URL."

This article implies -- simply putting a key:value entry in the appconfig
file of the form I listed in my original question and changing the URL
Behaviour to Dynamic is all that is needed. They go on to specify a custom
installer class, so that a user can input the name of the server and service.
This used to modify the key:value entry in the appconfig during
installation. I am not doing this, I am simply modifying the appconfig file
before generating the install files.

In otherwords, when the URL Behaviour is Dynamic, the application knows to
look in the appconfig for the key --> MyWebApp.localhost.Service1

In this case, there is no other code at runtime being used to access the
appconfig file to set the URL.
 
D

Dan Rogers

Ahh.

You're right. When you change the URL behavior property from Static to
Dynamic, you'll find that the setting gets made for you automatically in
the appsettings section of your config file. The pattern for the key is
ProjectNamespace.ProxyNamespace.ServiceClassname.

You should be able to look in your myapplicationexename.config file and see
this setting. If you put this in a different file, it could explain the
issue.


SO where you have

In your example:
You have an extra .asmx in the key name. This could be the problem.


this means your applications namespace is myApplication, your proxy
namespace is "myServer", and the name of the service class is Service1.

--------------------
Thread-Topic: Dynamic URL Failure
thread-index: AcUkI+aYz8xNpjy3QNOfIYz/9YKiyQ==
X-WBNR-Posting-Host: 65.27.6.160
From: "=?Utf-8?B?V2hpc2t5Um9tZW8=?="
<[email protected]>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,008
Latest member
Rahul737

Latest Threads

Top