I'm trying to use a proxy configuration script (Web Proxy Auto-Discovery (WPAD)) together with the WCF-WebHttp adapter. As it is not possible to configure the url to the script directly on the adapter properties dialog I defined a default proxy in BizTalks config file.
<defaultProxy useDefaultCredentials="true">
<proxy usesystemdefault="False" scriptLocation="http://<server>:9001/proxy.pac" />
</defaultProxy>
But it seems that the proxy is never configured.
I was thinking that maybe that setting "Do not use proxy" on the adapter causes the UseDefaultWebProxy property to be set to false? But it is not possible to set anything else since that requires that we set a uri directly to the proxy server.
Has anyone used proxy scripts together with BizTalk and WCF-WebHttp adapter?
Seems like the WCF-WebHttp adapter for some reason sets the UseDefaultWebProxy to false. It works as expected when I added an endpoint behavior that just sets that property to true.
var binding = endpoint.Binding as WebHttpBinding;
if (binding != null)
{
binding.UseDefaultWebProxy = true;
}
Related
I'm trying to pass my elasticsearch calls from NEST through Fiddler so I can see actual json requests and responses.
I've done the following to create my client, but the requests are not being pushed through the proxy (it doesn't matter if Fiddler is on or off, request still gets to elasticsearch).
ConnectionSettings cs = new ConnectionSettings(uri);
cs.SetProxy(new Uri("http://localhost:8888"),"username", "password");
elasticClient = new ElasticClient(cs);
Fiddler has no username/password requirements so I just pass random text.
I can confirm that at the point just before executing request my elasticClient has the proxy property filled in with Uri specified above, though with a trailing slash added by NEST.
Thanks
Okay, so, I gave up on the NEST proxy settings - they didn't seem to make any difference.
However, setting host on the NEST client to "http://ipv4.fiddler:9200" instead of localhost routes the call through Fiddler and achieved the desired result of allowing me to see both requests and responses from Elasticsearch.
If you want to see the requests a that .net application makes in fiddler you can specify the proxy in the web/app.config
As documented on fiddler's website
http://docs.telerik.com/fiddler/configure-fiddler/tasks/configuredotnetapp
<system.net>
<defaultProxy>
<proxy
autoDetect="false"
bypassonlocal="false"
proxyaddress="http://127.0.0.1:8888"
usesystemdefault="false" />
</defaultProxy>
</system.net>
Handy if changing the hostname to ipv4.fiddler is not an option.
Above code didn't help me.
So, here is my variant
var node = new Uri("http://localhost.fiddler:9200");
var settings = new ConnectionSettings(node)
.DisableAutomaticProxyDetection(false)
This should make it work:
var settings = new ConnectionSettings(...)
.DisableAutomaticProxyDetection(false);
See this answer.
Combining all the suggestions, the working solution is:
var node = new Uri("http://myelasticsearchdomain.com:9200");
var settings = new ConnectionSettings(node)
.DisableAutomaticProxyDetection(false)
.SetProxy(new Uri("http://localhost:8888"), "", "");
This works on NEST ver 7.6.1, and it's not necessary to toggle:
DisableAutomaticProxyDetection
var settings = new ConnectionSettings(...);
settings.Proxy(new Uri(#"http://proxy.url"), "username", "password");
I have a WCF webservice that can be accessed via a http endpoint. Now, this service shall be published with a load balancer via https. Clients are created in .Net via svcutil.exe but the WSDL is also needed for a Java client.
What I understand is:
Internally the webservice is a http service and nothing needs to be changed. The address is http://myserver.com/example.svc with WSDL ..?wsdl
Externally the service has to show up as a https service with address https://loadbalancer.com/example.svc and WSDL ..?wsdl
From other posts I have learned that the load balancer problem can be solved with following behaviour configuration:
<behavior>
<!-- To avoid disclosing metadata information, set the value below to false before deployment -->
<serviceMetadata httpGetEnabled="true"/>
<useRequestHeadersForMetadataAddress>
<defaultPorts>
<!-- Use your own port numbers -->
<add scheme="http" port="81" />
<add scheme="https" port="444" />
</defaultPorts>
</useRequestHeadersForMetadataAddress>
</behavior>
Using this workaround I get both URLs resolved to the services help page, but calling
https://loadbalancer.com/example.svc the page leads me to http://loadbalancer.com/example.svc?wsdl. When I replace the http by https I can load the wsdl but it has all internal links as http and not https.
Trying to switch httpsGetEnabled="true" leads me to a lot of https related issues and I don't know if this can help me as my server itself only knows http.
So, my problem is the https for the load balanced URL. Can I tell WCF that it shall show https in the WSDL meta data instead of http and how can I do this?
I have had this issue before and the fix pretty much was overriding the SoapExtensionReflector method name: ReflectDescription.
using System.Web.Services.Description;
namespace LoadBalancer
{
public class HttpsSoapExtensionReflector : SoapExtensionReflector
{
public override void ReflectMethod()
{
//no-op
}
public override void ReflectDescription()
{
ServiceDescription description = ReflectionContext.ServiceDescription;
foreach (Service service in description.Services)
{
foreach (Port port in service.Ports)
{
foreach (ServiceDescriptionFormatExtension extension in port.Extensions)
{
SoapAddressBinding binding = extension as SoapAddressBinding;
if (null != binding)
{
binding.Location = binding.Location.Replace("http://", "https://");//Updating the soap address binding location to use https
}
}
}
}
}
}
}
Once you create the above class into a new or an existing dll project (In my example the dll name is LoadBalancer) you just need to invoke our new extension from the server web config like:
<webServices>
<soapExtensionReflectorTypes>
<add type="LoadBalancer.HttpsSoapExtensionReflector, LoadBalancer"/>
</soapExtensionReflectorTypes>
</webServices>
If it is under LoadBalancer then it will go ahead and modify the binding location and it will be generate the WSDL with the HTTPS url.
Tested on SoapUI and from Visual Studio adding service references (app.config will reflect https).
Thanks
no, no way to tell the WCF to show the https in WSDL meta data instead of http.
our solution is, create both http and https endpointbindings, check if the incoming request is http or https, the incoming request type determine which endpointbindings will be used.
WCF service is hosted in IIS and uses netTCPRelayBinding.
At some locations the TCP ports are blocked and HTTP must be used. Other times TCP ports are open and this mode is preferred.
Thus, I'd like to be able to set the ConnectivityMode to AutoDetect (or to just HTTP) declaratively in the web.config file.
For self hosted WCF, this is easily done:
ServiceBusEnvironment.SystemConnectivity.Mode = ConnectivityMode.AutoDetect;
How is this done declaratively in web.config?
At the moment there is no configuration element for this setting however in your web.config you could use AppSettings to set the value
<appSettings>
<add key="ServiceBusConnectivityMode" value="Http" />
</appSettings>
In the code you would then read the key value and parse it into enum value
ServiceBusEnvironment.SystemConnectivity.Mode = (ConnectivityMode)Enum.Parse(typeof(ConnectivityMode), ConfigurationManager.AppSettings["ServiceBusConnectivityMode"])
I've created simple WinForms app that uses free webservice http://www.webservicemart.com/uszip.asmx. But this app fails to use service operation with error:
The remote server returned an unexpected response: (407) Proxy Authentication Required (The ISA Server requires authorization to fulfill the request. Access to the Web Proxy service is denied)
Code that creates proxy and triggers service operation:
ChannelFactory<ServiceReference1.USZipSoap> proxy = new ChannelFactory<ServiceReference1.USZipSoap>("USZipSoap");
ServiceReference1.USZipSoap client = proxy.CreateChannel();
string str = client.ValidateZip("12345");
MessageBox.Show(str);
Is this problem with a network of my company or this is a proxy on the side of webservicemart.com?
I've googled a lot of information on changing configuration files, creating a custom binding, etc. But I feel the lack of more basic understanding... If this error is about ISA server of our corporate network then what configuration should I make to ISA Server to not restrict me from using external webservices?
In your binding configuration make sure that useDefaultWebProxy is set to true - it will use configuration you have found in IE. In your configuration file add following snippet to ensure default your credentials are used for authentication on the proxy server:
<system.net>
<defaultProxy useDefaultCredentials="true" />
</system.net>
This worked for me... replacing 10.1.0.50 and the port number with your proxy server's IP
<system.net>
<defaultProxy useDefaultCredentials="true">
<proxy usesystemdefault="False" proxyaddress="http://10.1.0.50:8080" bypassonlocal="True" />
</defaultProxy>
</system.net>
Seems like all the traffic in your company is being redirected through a proxy. Can you browse to the web service from your IE and see its wsdl and invoke the test page to see some results. If that is the case then try adding the below section into your web.config:
<system.net>
<defaultProxy>
<proxy proxyaddress="<your proxy address>" bypassonlocal="true" />
</defaultProxy>
</system.net>
You can find the proxy address from the settings of your IE.
NOTE: When you move to different environments then you need to make sure that its the same case else you need to remove the above configuration.
You can set the web.config of the service to allow to use the proxy settings as defined in Internet Explorer.
Sometime in the future.
WebRequest.DefaultWebProxy.Credentials = CredentialCache.DefaultNetworkCredentials;
I need to consume a WCF service but I'm behind a proxy server and this proxy server requires a username and password.
I can't find a way to set it, if it was a Web Service, I could just do something like
ws.Proxy = myProxyServer;
How can I do this with a WCF service?
In the WCF binding config, use the useDefaultWebProxy property to make WCF use the windows default proxy (which can be set from IE network config):
<bindings>
<basicHttpBinding>
<binding name="ESBWSSL" ...everything... useDefaultWebProxy="true">
Then in the code, before you use the connection, do this:
WebProxy wproxy = new WebProxy("new proxy",true);
wproxy.Credentials = new NetworkCredential("user", "pass");
and with your webrequest object, before you execute the call:
WebRequest.DefaultWebProxy = wproxy;
I have not tested the code, but I believe this should work.
Note replaced previous answer based on comment
There was actually another stackoverflow answer that covered setting credentials on a proxy.
Is it possible to specify proxy credentials in your web.config?