/// <summary> /// Initializes a new instance of the RestServiceContext class. /// </summary> /// <param name="context">The reference to the request context /// object for the REST service.</param> /// <param name="url">The url to be used for REST requests.</param> public RestServiceContext(RequestContext context, string url) { Debug.Assert(context != null); Debug.Assert(!string.IsNullOrEmpty(url)); this.Context = context; this.Url = url; }
/// <summary> /// Initializes REST service connection context. /// </summary> /// <param name="knownTypes">Collection of types that might be present /// in REST service requests and responses.</param> /// <returns>The new instance of the REST service context.</returns> /// <exception cref="ESRI.ArcLogistics.AuthenticationException">Failed /// to authenticate within ArcGIS server providing REST service.</exception> /// <exception cref="ESRI.ArcLogistics.CommunicationException">Failed /// to establish connection to the server providing REST service.</exception> public RestServiceContext InitializeContext(IEnumerable<Type> knownTypes) { var context = new RequestContext(_server.OpenConnection(), knownTypes); var url = UriHelper.Concat(context.Connection.Url, _baseUrl); return new RestServiceContext(context, url); }
/////////////////////////////////////////////////////////////////////////////////////////// /////////////////////////////////////////////////////////////////////////////////////////// public RouteSolveResponse Solve( RouteSolveRequest request, IEnumerable<Type> knownTypes) { Debug.Assert(request != null); var context = new RequestContext(_server.OpenConnection(), knownTypes); var url = UriHelper.Concat(context.Connection.Url, _baseUrl); string query = RestHelper.BuildQueryString(request, knownTypes, false); HttpRequestOptions opt = new HttpRequestOptions(); opt.Method = HttpMethod.Post; opt.UseGZipEncoding = true; opt.Timeout = DEFAULT_REQ_TIMEOUT; return _restService.SendRequest<RouteSolveResponse>(context, url, query, opt); }