/// <summary>
        /// Process the $metadata request and return the xml description as per the sync protocol specification.
        /// </summary>
        /// <param name="incomingRequest">incoming request object.</param>
        /// <returns>WCF Message object that contains the output xml.</returns>
        public Message ProcessRequest(Request incomingRequest)
        {
            Debug.Assert(null != _configuration.ScopeNames);
            Debug.Assert(_configuration.ScopeNames.Count > 0);

            XDocument document = GetMetadataDocument();

            return WebUtil.CreateResponseMessage(document);
        }
        /// <summary>
        /// Process the GetScopes ($syncscopes) request and return the xml description as per the sync protocol specification.
        /// </summary>
        /// <param name="incomingRequest">incoming request object.</param>
        /// <returns>WCF Message object that contains the output xml.</returns>
        public Message ProcessRequest(Request incomingRequest)
        {
            Debug.Assert(null != _configuration.ScopeNames);
            Debug.Assert(_configuration.ScopeNames.Count > 0);
            Debug.Assert(null != incomingRequest);

            _incomingRequest = incomingRequest;

            // We currently support only 1 scope, so read it.
            XDocument document = GetScopeListInfo();

            return WebUtil.CreateResponseMessage(document);
        }
Example #3
0
        internal Request ParseIncomingRequest()
        {
            // Steps:
            // 1. Parse and validate request URI format (/syncscope/syncoperation)
            // 2. Validate QueryString using the HttpContextServiceHost.VerifyQueryParameters method.
            // 3. Parse and save query string parameters
            // 4. Identify and save request type, scopename, syncblob, request body.

            // throw BadRequest if duplicates are found.
            _serviceHost.VerifyQueryParameters();
            SyncSerializationFormat outputSerializationFormat = _serviceHost.GetOutputSerializationFormat(_configuration.SerializationFormat);
            SyncTracer.Verbose("Output Serialization format: {0}", outputSerializationFormat);

            RequestCommand requestCommand = GetRequestCommandType();
            SyncTracer.Verbose("RequestCommand type: {0}", requestCommand);

            List<IOfflineEntity> entities = null;
            Dictionary<CommandParamType, object> commandParameters = null;

            // Get command paramaters (filter params, scope name etc.) for all request types except $syncScopes
            if (requestCommand != RequestCommand.SyncScopes)
            {
                commandParameters = GetCommandParameters(_serviceHost.QueryStringCollection);
            }

            // Read the payload, headers etc for upload and download request types.
            if (requestCommand == RequestCommand.DownloadChanges || requestCommand == RequestCommand.UploadChanges)
            {
                ReadIncomingRequestDetails();
                entities = GetEntityListFromRequest(requestCommand);
            }

            var request = new Request(requestCommand, _serviceHost, commandParameters, _syncBlob, entities, outputSerializationFormat)
                              {
                                  IdToTempIdMapping = _idToTempIdMapping
                              };

            return request;
        }