This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

DEVELOPERS FORUM - "Unable to connect to the remote server" on Item.apply

imitchell - Friday, September 30, 2011 10:37 AM:

Folks,

I am getting the error "Unable to connect to the remote server" when updating a Document item.

I believe that the actual connection is ok because during test/debug of this issue, the first thing I do is upload the initial file and create the Doc-File relationship, see the file in the vault, etc.  The error always occurs when I do the "update" in which I am updating the file that is associated with the document.  The first thing logic does is lock the Document which I see does actually happen Aras.

I can reliably repeat the process of successfully creating a new Document/File but failing on updating the file

Any thought would be greatly appreciated! - Thanks, Ian

Below is the update logic:

      public String updateArasDocumentFile(String documentNumber, String inFileName)
       {
           // given an Aras document Number, update the attached file that resides in C:Temp

           if (SetupArasConnection())
           {

               MyInnovator = new Aras.IOM.Innovator(MyConnection);

               Item documentRequest = MyInnovator.newItem("document", "get");
               documentRequest.setProperty("item_number", documentNumber);

               Item documentResult = documentRequest.apply();
               if (documentResult.isError())
               {
                   return ("Document get Query Error: " + documentResult.getErrorDetail());

               }

               // first, lock the document
               documentResult = documentResult.lockItem();
               if (documentResult.isError())
               {
                   return ("ERROR: failed to lock the document: " + documentResult.getErrorDetail());
               }

               Item doc_file = documentResult.fetchRelationships("Document File").getRelationships("Document File").getItemByIndex(0);

               // delete this doc-file as we will create a new one for the updated file
               doc_file.setAction("delete");

               // get existing File so we can use the same name
               Item existingFile = doc_file.getRelatedItem();

               String fileName = existingFile.getProperty("keyed_name");

               Console.WriteLine("Existing Filename: " + fileName);

             

               // add a new Document-File relationship

               // Create new item "File" and attach physical file to it for version 2
               Item file2 = MyInnovator.newItem("File", "add");
               file2.setProperty("filename", fileName);
               file2.attachPhysicalFile(inFileName);

               // Create relationship between document and file
               Item doc_file2 = MyInnovator.newItem("Document File", "add");
               doc_file2.setRelatedItem(file2);
               documentResult.addRelationship(doc_file2);

               // Set action "edit" on the top Document
               documentResult.setAction("edit");
               Console.WriteLine("About to update Aras Doc :" + documentResult.ToString());

               // Submit top item with all subtree. This creates the next generation of the document.
               Item updated_doc = documentResult.apply();    /*******************ERROR HAPPENS HERE
               if (updated_doc.isError())
               {
                   return ("ERROR:  document: " + updated_doc.getErrorDetail());
               }
               else
               {
                   return "SUCCESS " + updated_doc.getProperty("major_rev") + "." + updated_doc.getProperty("generation");
               }          

           }
           else
               return "Aras login error";

       }



imitchell - Tuesday, October 4, 2011 6:12 AM:

Folks,

It looks like it is not a code issue since it also happens using the Aras Client.

It seems to be an install/config/network issue.

Here is a thread that is more on target: http://www.aras.comhttp://www.aras.com/Community/forums/p/1928/6352.aspx#6352