次の方法で共有


Creating Subscriptions Programmatically using different Local Settings (field separators)

If you want to create subscriptions programmatically, using the SOAP API, you would call the CreateSubscription method exposed by the API, through the proxy class created against the Web Service (ReportService.asmx; ReportService2005.asmx). However, you might have problems editing in Report Manager the subscriptions created this way, if the local settings on the client machines are not on English and the schedule of the subscription is done on Monthly recurrence with a list of days specified. Because the list separator on the client machine trying to edit the subscription is different, the deserialization of the Days list will fail with an error message similar to “The Days field contains a value that is not valid” (for example in French will be: “Le champ Days contient une valeur qui n'est pas valide.").

There is a fix already in place for this issue, however, an easy workaround that can be implemented in the mean time is to write your own class that inherits the proxy class (ReportService) which implements System.Web.Services.Protocols.SoapHttpClientProtocol and override the GetWebRequest method to accept your client machines’ language.

Example:

My proxy class against ReportService2005.asmx is ReportService2005.

My new class is RSWebService:

public class RSWebService: ReportingService2005

    {

protected override WebRequest GetWebRequest( Uri uri )

      {

WebRequest wr = base.GetWebRequest( uri );

      WebHeaderCollection headers = ((HttpWebRequest)wr).Headers;

      headers.Add("Accept-Language:fr");

      return wr;

      }

    }

After that, all I have to do is use my RSWebService class to call the Reporting Services SOAP API methods instead of the ReportingService2005 class’ methods.

Comments