PDA

View Full Version : Switching from Staging to Production



Jeff Smith
02-20-2005, 09:59 AM
Hello,
My general question is, what's the easiest way to dynamically change my development environment from staging to production. I know the high-level answer is, "just repoint to another wsdl", but...

I used asp.NET's discovery process to originally access the staging wsdl. From this, as well as the SDK, I now have code that has embedded within it staging references (i.e. public CommonServiceSoap() {
this.Url = "http://findv3.staging.mappoint.net/Find-30/Common.asmx";
} )

Following the SDN, I wrote code that has the following initialization of the various services:
private MapPointService.RenderServiceSoap renderService;
private MapPointService.FindServiceSoap findService;
private MapPointService.RouteServiceSoap routeService;
private MapPointService.CommonServiceSoap commonService;

If I look at the URLs, while stepping through the code, these naturally reference the hard-coded staging URLs. Is there a single place (i.e. within MapPointService) that I can just say, re-discover from the production (service) wsdl? Otherwise, is it safe to change each of the Urls dynamically to the production versions. For example:

renderService.Url = "http://findv3.service.mappoint.net/Find-30/Common.asmx";

Is this even a valid URL?

Thanks,
Jeff

Anonymous
03-29-2005, 08:06 AM
Hello,

Settings in web.config file:


<add key="IsProduction" value="T" />


<add key="RServiceStaging" value="http://renderv3.staging.mappoint.net/render-30/RenderService.asmx" />
<add key="RServiceProduction" value="http://renderv3.mappoint.net/render-30/RenderService.asmx" />


<add key="FServiceStaging" value="http://findv3.staging.mappoint.net/find-30/FindService.asmx" />
<add key="FServiceProduction" value="http://findv3.mappoint.net/find-30/FindService.asmx" />


<add key="RtServiceStaging" value="http://routev3.staging.mappoint.net/route-30/RouteService.asmx" />
<add key="RtServiceProduction" value="http://routev3.mappoint.net/route-30/RouteService.asmx" />


<add key="CServiceStaging" value="http://findv3.staging.mappoint.net/find-30/CommonService.asmx" />
<add key="CServiceProduction" value="http://findv3.mappoint.net/find-30/CommonService.asmx" />


Method in Global file:

Public Sub AuthenticateServices()

Try
Dim myCredentials As New NetworkCredential(ConfigurationSettings.AppSetting s("MPUser"), ConfigurationSettings.AppSettings("MPPassword"))


' Render service
RService = New RenderServiceSoap
RService.Credentials = myCredentials
RService.PreAuthenticate = True

' Find service
FService = New FindServiceSoap
FService.Credentials = myCredentials
FService.PreAuthenticate = True

' Route service
RtService = New RouteServiceSoap
RtService.Credentials = myCredentials
RtService.PreAuthenticate = True

' Common service
CService = New CommonServiceSoap
CService.Credentials = myCredentials
CService.PreAuthenticate = True

' Set the endpoints to staging or production
If ConfigurationSettings.AppSettings("IsProduction") = "T" Then
RService.Url = ConfigurationSettings.AppSettings("RServiceProduction")
FService.Url = ConfigurationSettings.AppSettings("FServiceProduction")
RtService.Url = ConfigurationSettings.AppSettings("RtServiceProduction")
CService.Url = ConfigurationSettings.AppSettings("CServiceProduction")
Else
RService.Url = ConfigurationSettings.AppSettings("RServiceStaging")
FService.Url = ConfigurationSettings.AppSettings("FServiceStaging")
RtService.Url = ConfigurationSettings.AppSettings("RtServiceStaging")
CService.Url = ConfigurationSettings.AppSettings("CServiceStaging")
End If

Return myServices

Catch ex As Exception

End Try

End Sub

All you have to do is change the IsProduction value in the config file to T or F, doesn't cause a recompile. Staging and production are exactly the same just different end points which are specified by the .URL property.


Steven Pushee

This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2003 Microsoft Corporation. All rights
reserved.