问题
I'm behind a firewall at work at the moment and I was testing something that I had deployed to my website, and the work proxy seems to be blocking it somewhat.
Basically I am getting a message of:
Operation is not valid due to the current state of the object
I've got it down to my proxy interferring, but I can't see any advanced settings or anything I can set up to go through my proxy to get to my service.
I did a quick google for it, but no joy.
Anyone found a quick way to get around it?
回答1:
Edit, I forgot to write this part in the answer: You may need to add the web reference url to the safe list for your proxy. I am not sure what proxy you are using or if you have control of it, but this should solve your problem. If you don't have access to change the proxy, then I put a quick work around right below.
Here's a quick work around, just use the browser to navigate to the WSDL. Grab the xml and save it as a .wsdl file on your computer you would like to generate the client on. Then use the wsdl.exe to generate the client pointing it to the path you saved the wsdl file.
回答2:
Another option is to go to your application's web config or app config and add the following under the element:
<system.net>
<defaultProxy useDefaultCredentials="false">
<proxy usesystemdefault="true" proxyaddress="10.0.0.1" port="80" bypassonlocal="true" />
</defaultProxy>
</system.net>
You can then add the web reference in the normal way.
来源:https://stackoverflow.com/questions/42984/how-do-you-add-a-web-reference-through-a-proxy-firewall