Пример #1
0
        public static void Initialize()
        {
            // Render service
            renderService                 = new RenderServiceSoap();
            renderService.Credentials     = new System.Net.NetworkCredential(mpwsUserName, mpwsPassword);
            renderService.PreAuthenticate = true;

            initialized = true;
        }
        /// <summary>
        /// Make the constructor private becasuse we want the GetInstance be used.
        /// </summary>
        /// <param name="userid">MapPoint userid</param>
        /// <param name="password">MapPoint password</param>
        private MapPointWebServiceHelper(string userid, string password)
        {
            try
            {
                netCreds = new NetworkCredential(userid, password);

                theMapPointFindService             = new FindServiceSoap();
                theMapPointFindService.Credentials = netCreds;
                theMapPointFindService.Timeout     = MAPPOINT_DEFAULT_TIMEOUT;
                if (webProxy != null)
                {
                    theMapPointFindService.Proxy = webProxy;
                }

                theMapPointRouteService             = new RouteServiceSoap();
                theMapPointRouteService.Credentials = netCreds;
                theMapPointRouteService.Timeout     = MAPPOINT_DEFAULT_TIMEOUT;
                if (webProxy != null)
                {
                    theMapPointRouteService.Proxy = webProxy;
                }

                // setup route distances to be in miles
                UserInfoRouteHeader routeHeader = new UserInfoRouteHeader();
                // set distance in miles
                routeHeader.DefaultDistanceUnit = DistanceUnit.Mile;
                theMapPointRouteService.UserInfoRouteHeaderValue = routeHeader;

                theMapPointRenderService             = new RenderServiceSoap();
                theMapPointRenderService.Credentials = netCreds;
                theMapPointRenderService.Timeout     = MAPPOINT_DEFAULT_TIMEOUT;
                if (webProxy != null)
                {
                    theMapPointRenderService.Proxy = webProxy;
                }
            }
            catch (Exception e)
            {
                throw e;                 // app can handle it
            }
        }