I am using the 2010 SharePoint Lists web service to return a Content Type and it's fields through a c# application. The Library is in a web whose language is set to welsh, but with an alternate language of english set. This means if the internet options in the browser are set to english, the library displays in English. I have been able to set the Accepts-Language header for requests made using the client object but have not been able to do so for the web service.
Is it possible to see a header on requests made through the SharePoint Web Services, and if so, how?
In case of ASMX web services you could consider the following approach. SoapHttpClientProtocol Class contains GetWebRequest Method
that could be used for specifying a custom headers.
Once the proxy class is generated, create a class that derives from it and set custom header as shown below:
public class ListsEx : Lists
{
protected override WebRequest GetWebRequest(Uri uri)
{
var request = base.GetWebRequest(uri);
//Add the Accept-Language header (for Danish) in the request.
request.Headers.Add("Accept-Language:da");
return request;
}
}
where Lists
is the name of generated proxy class.
Usage
using (var client = new ListsEx())
{
client.Url = webUri + "/_vti_bin/Lists.asmx";
var reult = client.GetList("Pages");
//...
}
Result