views:

35

answers:

0

Ok, so I'm new to SharePoint and my knowledge of how proxy servers work is not great, so that doesn't help. I've created a custom webpart that needs to be deployed in various client environments. One of my clients is having trouble connecting to a my web services form the webpart, and my assumption is that it's because he's using a proxy server. After doing some research and testing with Charles to mimic a proxy scenario on my own machine, I gave him this setting to add to his SharePoint config file:

<system.net>
  <defaultProxy>
   <proxy usesystemdefault="False" proxyaddress="http://127.0.0.1:8888" bypassonlocal="True" />
  </defaultProxy>
 </system.net>

He changed the address and port to his settings, of course.

Unfortunately, that didn't work. He then told me that his proxy server required authentication, so my next assumption is that since I'm not specifying a username or password anywhere, that's probably why he's not able to connect to my webservices.

By the way, my code looks like this:

public static HttpWebRequest CreateWebRequest(WebMethod method, string requestUrl, bool preAuth)
{     
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(requestUrl);   
request.Method = method.ToString();
request.PreAuthenticate = preAuth;
request.Proxy = HttpWebRequest.DefaultWebProxy;

return request
}

So, all this actually works on my machine. I ran Charles, and used the proxy address from Charles on my web config, and it worked. Just to double check, I modified the proxyaddress in the config to some bogus address, and sure enough, it did not work. But Charles Proxy does not need authentication, so it's a little different from my client's situation.

After researching more, I found a few more things I could try, but I was hoping if anyone could confirm these:

  1. Add useDefaultCredentials="true" attribute to the web.config.

  2. Add this.Proxy.Credentials = CredentialCache.DefaultCredentials in the code. (is this even different than option 1?)

  3. Do this

    NetworkCredential cred = new NetworkCredential(proxyUsername, proxyPassword, proxyDomain); this.Proxy.Credentials = cred;

  4. Do this:

    credCache = new CredentialCache();
    Uri uri = WebProxy.GetDefaultProxy().Address;
    
    
    if(uri!=null)
    
    
    {
    NetworkCredential cred = new NetworkCredential(proxyUserId, proxyPassword);
    
    
    // add all types of authentication you expect to be used
    credCache.Add(uri,"Digest", cred);
    credCache.Add(uri,"Basic",cred);
    credCache.Add(uri,"",cred);
    NetworkCredential credNTLM = new NetworkCredential(proxyUserId, proxyPassword, domain);
    credCache.Add(uri,"NTLM",credNTLM);
    this.Proxy.Credentials = cred;
    }
    

I must also mention all the requests are made out to a https address (https://www.[myaddress].com)

Any help would be greatly appreciated.

Thanks.