I have a list that is attached to a workflow (State machine, VS2010, SP2010). There is an OnWorkflowItemChanged activity that will check if a column of the list has been changed. If it changed, it will consume an external webservice.
I have also a TimerJob that will be triggered every day. It will edit the item, so the workflow will have to consume the external service.
However, When the TimerJob edit the column using SOM, there is a problem with the proxy:
System.Net.WebException: Unable to connect to the remote server ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because con...
I got the same problem at first with my workflow (without using the TimerJob) because I didn't edit the web config properly (in order to my workflow to use another proxy in the webconfig from inetpub/wwwroot/wss/virtualdirectories/80).
<system.net>
<defaultProxy useDefaultCredentials="true"> <proxy usesystemdefault="False" proxyaddress="http://ip:8081" bypassonlocal="True" /> </defaultProxy>
</system.net>
If I add the same code in the config of the timerJob _\Common Files\Microsoft Shared\Web Server Extensions\14\BIN\OWSTIMER.EXE.CONFIG), it will work. But the TimerJob will never consume a werbservice. What is the problem here?
public override void Execute(Guid targetInstanceId)
{
try
{
SPWebApplication webApplication = this.Parent as SPWebApplication;
SPWeb web = webApplication.Sites["/teamsites/FI"].RootWeb;
SPList listJob = web.Lists.TryGetList("Task List");
foreach (SPListItem item in listJob.Items)
{
if (item.Workflows.Count > 0 && !item.Workflows[item.Workflows.Count - 1].IsCompleted)
{
item["WorkflowStatus"] = UpdateValue;
item.Update();
}
}
} catch(Exception ex)
{
Log("TimerJob Action exception", TraceSeverity.High, EventSeverity.Error, ex.ToString());
}
}
The other fix is for the TimerJob to call listdata.svc service in order to edit the field. The workflow will not have any problem to consume the service (without editing the TimerJob config).
So my question is, why does the timerJob need to use an open proxy in order to the workflow to successfully consume the external service ? It does not make change.