none
SharePoint TimerJob for Webservice.

    Question

  • Hi, I have a requirement that consume sales data from a sales service and show it sharepoint list.  So I would want to implement using sharepoint timer job to get certain data.   So I  created the service Proxy file using the Svcutil/Visual Studio, and able to consume the service if the platform type is ‘x86’. But not able to consume the service if it set to ‘AnyCPU’. I believe ,we should select 'Platform Target Type' AnyCPU if its SharePoint 2010 project.  

    I have done following few scenarios.

    Scenario1:

    1.Generate Proxy file using Svcutil.exe which is located in Program Files(86) folder.

    2.Create Console/SharePoint project

    3.Add this file as a reference to the Console/Sharepoint project.

    4.Make sure Platform Target type will be ‘Any CPU’ for this project.

    5.Create Client programmatically.

    6. Error “Could not find default endpoint element that references contract …”  is coming and not able to call the service.

    Scenario2:

    1.Create one sample Web Application project and add Service Reference with the service url.

    2.Visual Studio automatically generates proxy file(References.cs).

    3.Create Console/SharePoint project

    4.Add this file as a reference to the Console/Sharepoint project.

    5.Make sure Platform Target type will be ‘Any CPU’ for this project.

    6.Create Client programmatically.

    Error “Could not find default endpoint element that references contract …”  is coming and not able to call the service.

    Its consuming the service if I give the Platform Target type as ‘x86’. But SharePoint application Platform Target type is ‘Any CPU’.

     

    Scenario3:

    Create Console application

    Platform Target type will be ‘Any CPU’ by default.

    Add the Service reference to the project, Visual Studio automatically creates the proxy.

    It reads App.config values while creating the client.

    Its working fine while running locally.

    But App.config is not available in Timer Job. Hence not able to call the service.

    Its consuming the service if I give the Platform Target type as ‘x86’

    The issue is.  Service end point is there in app.config but SharePoint timer job looks for the same in 'Owstimer.confi' . But my question is,

    1) Can we keep service end point in Owstimer.config, Is it best practice .

    2) As altarnative , Do we need to write normal console application and create windows shcedule for the same.  ( is this best approach) 

    what are the pros and cons of Windows schedule Job Vs Sharepoint timer job.

    3) What should be done for sharepoint timer jobs to work which should consume a web service.

    please share your thoughts.

    Wednesday, January 16, 2013 12:08 PM

Answers