locked
Async WCF service calling WCF service RRS feed

  • Question

  • User1068204517 posted

    I have the following scenario

    client (asyn call) -> wcf service (async) -> wcf

    I have create an Async method to upload files. When I run the client and fire 2 or more fileupload requests I get an error "On or more occuerences .... File or Folder already exists...." and it only creates the first file with folder structure. After the folder structure is created the same code runs successfully to upload multiple files.

    How can I make sure that each incoming request calls the clientContext.UploadDocumentAsync
    after the first request has returned the results.

          public async Task<UploadResult> UploadAsyncDocument(Document document)
                {
                    var r = await Task.Run(
                         () =>
                            {
                                var doc = Mapper.Map(document, new DocumentPOCO());
                                using (var clientContext = new MyServiceClient())
                                {
                                    var uploadResult = clientContext.UploadDocumentAsync(doc);
                                    return uploadResult;
                                }
                            });
        
                    var result = Mapper.Map(r, new UploadResult());
                    return result;            
                }

    Wednesday, September 18, 2013 11:29 AM

Answers

  • User-488622176 posted

    Can't you simply check of the folder or folder structure exists before creating it? I think this will solve your issue.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 19, 2013 7:29 AM
  • User-1000095884 posted

    Hi Angad,

    I have create an Async method to upload files. When I run the client and fire 2 or more fileupload requests I get an error "On or more occuerences .... File or Folder already exists...." and it only creates the first file with folder structure.

    From the error message, you may need to detect whether the file or folder already exists, utilize Directory.Exists Method, also check http://stackoverflow.com/questions/791468/how-to-get-working-path-of-a-wcf-application

    Hope it helps.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 9:51 PM

All replies

  • User-488622176 posted

    Can't you simply check of the folder or folder structure exists before creating it? I think this will solve your issue.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, September 19, 2013 7:29 AM
  • User-1000095884 posted

    Hi Angad,

    I have create an Async method to upload files. When I run the client and fire 2 or more fileupload requests I get an error "On or more occuerences .... File or Folder already exists...." and it only creates the first file with folder structure.

    From the error message, you may need to detect whether the file or folder already exists, utilize Directory.Exists Method, also check http://stackoverflow.com/questions/791468/how-to-get-working-path-of-a-wcf-application

    Hope it helps.

    Best Regards.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Tuesday, September 24, 2013 9:51 PM