0

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.

1 Answer 1

0

Well I guess you need to think about how the workflow is running. A workflow when triggered by a list item change is going to be executed within the SharePoint Timer Service process. So the change to the processes proxy settings is affecting both the Timer Service and also the Workflow process.

When you say the web service is external, is it outside of your network or is it just a machine that is running within the domain? Is the address you are accessing a fully qualified domain name or a partial address? e.g. FQDN=webservice.contoso.com or Partial=webservice.

If its FQDN that address will be treated by IE as in the Internet Zone so then you can have issues with authentication etc.

So check the IE settings that are setup for the Timer Service by logging in as the account that runs the SharePoint Timer Service and running IE.

4
  • Sorry, I am not sure to understand correctly your answer. If I edit the item through the SharePoint Site, the workflow will work fine and can consume the external service. The service is outside our network. If the TimerJob edit the same item with SOM, the workflow will be unable to consume the werservice, unless if : 1/The TimerJob edit the item through a SharePoint default service 2/If I edit the config of the TimerJob to use another proxy.
    – lotusight
    Commented Apr 21, 2013 at 15:26
  • Sorry I have misunderstood your issue. If you edit the item this kicks off the workflow. If the workflow can run straight away then it will run in the context of the web application's application pool account which will pick up the proxy settings from the web.config. Therefore the call to the external web service works. When the item is updated by the timer service then the workflow will run in the context of the timer service and needs the configuration that you have to be able to talk to the proxy and the external web service. Does that help?
    – Simon Doy
    Commented Apr 30, 2013 at 10:14
  • Yes I understand now... but is it SharePoint normal behavior? The Workflow needs to consume external service. I will have to add the WCF config twice? (in the webconfig and timer job config?)
    – lotusight
    Commented May 7, 2013 at 7:32
  • Yes however this is a .net configuration setting you are telling the executing process how to access the internet. Because there are two processes that need access to the internet you need to include the config for both.
    – Simon Doy
    Commented May 10, 2013 at 21:41

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.