|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Announcements
Want a new Job?
Chapters
Services
Feature Zones
|
IntroductionI have been creating a number of small applications that take a document and pass it to a web service to be processed. I developed the Web Service and applications on a development computer, and would copy all to the production computer when completed. This worked fine until I started to migrate the applications to a second computer (App Server) and leave the Web Service on the Production Computer (Process Server). I found I needed to change the applications' web reference from I started thinking that it would have been much more efficient if I could have changed a configuration setting and have the applications point to a different server for its Web Services. If this was possible, I could have pointed the application to the test server and restarted the application. When the Production Server was corrected, change the configuration back, restart the application, and let it go. After doing a little research, I found that I could do this rather simply. SolutionWhen you use the VS IDE to create a Reference to a Web Service, it auto generates a file called Reference.vb. In this file, I found that there is a reference to the server's URL for where the Web Service is located. I made a copy of this file and deleted all references to the current Web Service. I created a class file and pasted the code from the Reference.vb into my new class called Next, I made a small change to the Public Sub New()
MyBase.New
Me.Url = "http://localhost/DynamicWS/DWS.asmx"
End Sub
To the following: Public Sub New(ByVal ServerUrl As String)
MyBase.New
Me.Url = "http://" & ServerUrl & "/DynamicWS/DWS.asmx"
End Sub
After modifying the Dim S1 As New localhost.Service1()
Changed to this: Dim S1 As New DynWS.Service1("localhost")
Step-by-Step Proof of ConceptFirst, you will need two machines capable of hosting a Web Service. Next, on each machine, create a basic web service and uncomment the HelloWorld Web Service that is in the basic project. On Machine #1, change the return value for the HelloWorld to something like "Hello World From the Production Server". Do the same on your Machine #2, but change the return value to "Hello World From the Test Server". Test each web service to verify they are returning the values you want. Next, create a simple application with a Dim S1 As New DynWS.Service1(TextBox1.Text.Trim)
Debug.WriteLine(S1.HelloWorld)
When you run your application, enter the server name or address to the computer that has your web service, and press the button. When you change the name to your second computer, you should get a separate message. Possible Improvements
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||