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.
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.
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’.
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.
Not sure if it's best practise or not to put it in Owstimer.exe.config, but it should be possible.
There is anyther way of doing this where uou don't have to use a .config file to connect to a webservice. What you get in your .config file could be written in pure .NET code instead. Have a look at this post.
Basically, instead of using the empty constructor when you instantiate your service reference, you use the constructor that takes a binding and an endpoint as paramters.
- Marked as answer by Qiao WeiMicrosoft contingent staff, Moderator Friday, January 25, 2013 2:59 AM