Deploying a Windows Forms App that uses Web Services.

C

Chris Dunaway

A quick scan of the group did not immediately reveal an answer to my
questions so here goes.

First let me describe my app and then I'll ask the questions.

I am writing a Windows Forms App (not Web Forms) that serves as a thin
client to some web services. In other words, the Windows Forms app will be
installed on the client machines and that app will call web services that
are deployed on my server.

In the process of developing the Windows Forms app and web services, I
naturally used my development machine. I referenced the web services using
localhost since my development machine has both IIS and SQL2K. All fine
and dandy, now my questions, which are probably easy, but this is a new
arena for me (web servies, not VB).

1. When I look at the web references for the app, the reference is
localhost (referring to my development machine). The web services will
ultimately be deployed to the production server which is not localhost.
How will the Windows Forms Client cope with it? The code references
localhost. Will I have to rebuild the client AFTER I have deployed to the
production server? What if, during the life of the app, I need to move the
web services to a different server? How does the client app cope with
that? I feel dumb asking because this seems like a common scenario that I
already should know, but any help is appreciated.

2. I only want my web serviced to be consumed by my client app. How can I
restrict access to only my application? How can I prevent other
applications from detecting and consuming my web services without
permission?

Thanks again, looking forward to any responses.
 
M

Munsifali Rashid

When compiling the application on your development machine, you should use
localhost as your reference. However, you can also store the Url of the
webservice in the app.config file, and then set this value at run time,
using the Url property.

Eg.

MyWebService proxy = new MyWebService();
proxy.Url =
System.Configuration.ConfigurationSettings.AppSettings["WebServiceUrl"];

Your app.config file would then contain the WebService Url:

<add key="WebServiceUrl"
value="http://ProductionServer/WebServices/SomeService.asmx" />

If during the life of the application, the Url to the webservice changed,
you would only need to change the app.config on each client machine, rather
than change the webreference, recompile, and re-install on every machine.
When the application is run, it will automatically pull the updated
webservice location from app.config.

To answer your second question, there are various ways of securing
webservices. If the application is only going to be used from within your
network, and you've got a fixed IP range, then you could use IP-based
security on the IIS host. You could also use SOAP headers, passing a
username and password or some kind of authorisation ticket in each request
to the webservice. See this article on MSDN for details:
http://msdn.microsoft.com/library/d.../en-us/cpguide/html/cpconUsingSOAPHeaders.asp

Hope this helps,

Mun
 
D

David Guyer [MS]

Try looking at the Passing Data to a Custom Action walkthrough at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/ht
ml/vxwlkwalkthroughpassingdatatocustomaction.asp

It shows how to set the WebService reference URL to Dynamic, and then
modifying the web service URL during install time to a user-specified value.


Another approach would be to use the Configuration Override File property.
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vsintro7/ht
ml/vxurfdeploymentconfigurationpropertiesprojectnamepropertypagesdialogbox.a
sp

In C# you have to set it in your project file, or you can use a macro to do
it. In VB, it is exposed in the Project Properties dialog under the
Deployment tab.

In short, it allows you to have multiple Web.Config files in your project
(with different file names). Use the web.config file for your development
machine, and have a Release.Config file (or named something like that).
When you select the "Release" configuration, the Release.Config file will
be passed to the setup project, but with a Web.Config file name. Put the
full URL into that .config file.
 

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

Top