09-11-2008 07:56 AM
I want to create Web Service for creating new contact with attached document. Implemented Web Service is working properly as part of VS 2008 development environment. But publishing Web Service on IIS and and attaching Document to newly created Contact cause problems . Here is a code:
string attachmentName = "cv" + System.DateTime.Now.ToShortDateString() + ".html";
attachmentName = attachmentName.Replace("/", "_");
string fullAttachmentName = "c:\\ActWs\\" + attachmentName;
FileInfo f = new FileInfo(fullAttachmentName);
StreamWriter w = f.CreateText();
Attachment attachment = ActFrameworkFactory.getAct().SupplementalFileManager.CreateAttachment(AttachmentMate.History, fullAttachmentName, attachmentName, false);
HistoryType historyType = new HistoryType(SystemHistoryType.Library);
History newHistory = ActFrameworkFactory.getAct().Histories.CreateHistory(cContact, Guid.Empty, historyType, false, System.DateTime.Now, System.DateTime.Now, "proba history type", "", attachment);
As message I've got following stacktrace:
2008-06-23 16:28:22,265  ERROR ActWs.ActWs - at Act.Framework.Histories.HistoryManagerDB.InsertHistoryItem(History history, CommandProcessor processor)
at Act.Framework.Histories.HistoryManagerDB.CreateHistory(History history)
at Act.Framework.Histories.HistoryManager.CreateHistory(Guid contactKeys, Guid opportunityKeys, Guid groupKeys, Guid activityClearedId, HistoryType histType, Boolean isPrivate, DateTime displayDate, DateTime endDate, String regarding, String details, Attachment att, Guid createUserID, Guid manageUserID)
at Act.Framework.Histories.HistoryManager.CreateHistory(Guid contactKeys, Guid activityClearedId, HistoryType histType, Boolean isPrivate, DateTime displayDate, DateTime endDate, String regarding, String details, Attachment att)
at Act.Framework.Histories.HistoryManager.CreateHistory(Contact contact, Guid activityOccurID, HistoryType histType, Boolean isPrivate, DateTime displayDate, DateTime endDate, String regarding, String details, Attachment att)
at ActWs.ActWs.addToAct(String personDetails, String cv) in C:\Documents and Settings\Loder\My Documents\Visual Studio 2008\Projects\ActWs\ActWs\ActWs.asmx.cs:line
1422008-06-23 16:28:22,265  ERROR ActWs.ActWs - Unable to insert a history
I was trying to fix problem with changing privileges to folder where attached document is temporary created, but with no results.
Thanks in advance.
12-01-2009 06:54 AM
did you manage to find solution for this problem, because iam having the same problem where in i can attach documents to document tab through web services from vs 2008, but when deploying to IIS it gives an error " unable to insert history"
Thanks for your help
09-01-2011 01:49 PM - edited 09-01-2011 02:05 PM
Now this is just a quick thought, but whenever you deal with web services (basically a special web page), you need to make sure the permissions are set properly to the folders. I'm not sure on the process that Act is using with the web service, but I suggest looking that the ASP.NET "user" has read/write permissions to the folder where the file will be (not just your temporary store).
Another thing to look at is how Act is storing the file. Is it storing the file in the file system, or as a BLOB (Binary Large OBject) in SQL Server? If it is in the file system, on the web server, then the user account that is "running" Act will need permissions to write to the destination folder.
In short, make sure Act and the ASP.NET user account all have read/write permissions to all folders that you are utilizing. I hope that helps.
Edit: I just noticed, this thread was resurrected from a few years ago. So, dbenglund, could you please provide some information specific to your issue?
09-01-2011 01:49 PM
I'm asking this question because I didn't not see it as part of the code snippet. But is the newly created contact being updated prior to adding the attachment?
And a follow up question, does it throw the same exception for contacts that are already created?