c# - Getting WSHttpBinding working through an http proxy -


i have wcf service , client uses service. use wshttpbinding mtom message encoding. client doesn't use app.config file, , of endpoint configuration in code. works rather nicely in normal environment, have users attempting connect service behind http proxy. whenever try connect, 407 (proxy authentication required) warning.

i've managed set own testing environment using virtual machine private network connects proxy, can simulate seeing. i've tried setting system.net usedefaultcredentials property in app.config, doesn't seem have effect. i've examined packets being sent, , don't contain proxy-authentication headers. looking @ web traffic through proxy, use header.

i've tried hard coding proxy server client, gives "cannot connect server" exception. examining packets, client sends out 3 small ones proxy, none of http request, , that's it. i'm not sure it's doing there.

i went far add message inspector client, , manually inject required header requests, that's not showing in header.

i'm hitting end of rope here, , need solution. ideas on i'm missing here, or solution?

this ( wcf service wshttpbinding - manipulating http request headers ) seems promising, i'm still stuck.

edit: here's portion of code.

            var binding = new wshttpbinding();             binding.maxreceivedmessagesize = 100000000;             binding.messageencoding = wsmessageencoding.mtom;             binding.readerquotas.maxarraylength = 100000000;             binding.opentimeout = new timespan(0, 2, 0);             binding.receivetimeout = new timespan(0, 2, 0);             binding.sendtimeout = new timespan(0, 2, 0);             binding.security.message.clientcredentialtype = messagecredentialtype.username;              binding.usedefaultwebproxy = true;             // i've tried setting false, , manually specifying binding.proxyaddress              binding.security.transport.proxycredentialtype = httpproxycredentialtype.basic;             var endpointaddress = new endpointaddress(new uri(hosturl));             clientproxy_ = new updaterserviceproxy(binding, endpointaddress);              // behavior attempt manually add proxy-authentication header             //clientproxy_.endpoint.behaviors.add(new myendpointbehavior());              clientproxy_.clientcredentials.username.username = username;             clientproxy_.clientcredentials.username.password = password;             clientproxy_.clientcredentials.servicecertificate.authentication.certificatevalidationmode =                     system.servicemodel.security.x509certificatevalidationmode.chaintrust;             // stuff... 

after lot of experimentation i've made progress. turns out can manually specify proxy, , work.

webproxy proxy = new webproxy("http://x.x.x.x:3128", false); proxy.credentials = new networkcredential("user", "pass"); webrequest.defaultwebproxy = proxy; 

that code appears before instantiate clientproxy_. had tried previously, silently failed because hadn't specified port. still cannot pick proxy settings specified in windows internet settings. tried setting proxy.credentials = credentialcache.defaultnetworkcredentials; seemed have no effect.

i'm running problem client trying validate service's certificate using chaintrust, requests chained certificates not using proxy settings. since more specific question, wrote separately here: certificate validation doesn't use proxy settings chaintrust

so i'm still hoping more help.

update: ended adding network configuration dialog application user specify proxy settings. i've been unable automatic proxy settings work properly.


Comments

Popular posts from this blog

jquery - Invalid Assignment Left-Hand Side -

java - Play! framework 2.0: How to display multiple image? -

gmail - Is there any documentation for read-only access to the Google Contacts API? -