tags:

views:

398

answers:

1

Hi,

Is someone able to assist in helping understand how to get this C# example working through my proxy server. I note there is a code sample at http://code.google.com/apis/gdata/articles/proxy%5Fsetup.html#dotnet, that provides some direction, however I'm having trouble regarding how to apply this to the DocListExporter example. In other words:

How do I apply the code concept here (with proxy):

  CalendarService service = new CalendarService("CalendarSampleApp");
  GDataRequestFactory requestFactory = (GDataRequestFactory)
  service.RequestFactory;
  WebProxy myProxy = new WebProxy("http://my.proxy.example.com:3128/",true);
  // potentially, setup credentials on the proxy here
  myProxy.Credentials = CredentialCache.DefaultCredentials;
  myProxy.UseDefaultCredentials = true;
  requestFactory.Proxy = myProxy;

To the following code from the example:

           GoogleClientLogin loginDialog = new GoogleClientLogin(new DocumentsService("GoogleDocumentsSample"), "[email protected]");
            if (loginDialog.ShowDialog() == DialogResult.OK)
            {
                RequestSettings settings = new RequestSettings("GoogleDocumentsSample", loginDialog.Credentials);
                settings.AutoPaging = true;
                settings.PageSize = 100;
                if (settings != null)
                {
                    this.request = new DocumentsRequest(settings);
                    this.Text = "Successfully logged in";

                    Feed<Document> feed = this.request.GetEverything();
                    // this takes care of paging the results in
                    foreach (Document entry in feed.Entries)
                    {
                        all.Add(entry);
                    }

Also if you know the syntax for how to include the actual proxy username/password that would be cool too.

thanks

+1  A: 

Have tried setting up the proxy in your app.config file ?

something like this -

<system.net>
  <defaultProxy enabled="true" useDefaultCredentials="true">
    <proxy/>
    <bypasslist/>
    <module/>
  </defaultProxy>
</system.net>
AB Kolan
no - so thanks for highlighting this approach - this would seem a better way to do it if it works no? That is, one wouldn't have to worry about how programmatically to achieve the result that meshes into the Google client library in the manner they've used .net HTTP classes. Are there any negatives to using this declaritive approach? Would it make it harder to swap between no proxy and with proxy, for say the case the program is running on a lap top that may be behind a proxy server sometimes but not always?thanks
Greg