Open
Description
Requirement
I tested the proxy settings of the communication control function due to the another matter.
As a result of the following settings, proxy setting in XML was possible except for WCF.
This result was verified using fiddler http debug proxy (127.0.0.1:8888).
<?xml version="1.0" encoding="utf-8" ?>
<!DOCTYPE TMD[
<!ELEMENT TMD (Prop*, Url*, Transmission*)>
<!ELEMENT Url EMPTY>
<!ELEMENT Prop EMPTY>
<!ELEMENT Transmission EMPTY>
<!ATTLIST Url id ID #REQUIRED value CDATA #REQUIRED>
<!ATTLIST Prop id ID #REQUIRED value CDATA #REQUIRED>
<!ATTLIST Transmission id ID #REQUIRED protocol (1 | 2) #REQUIRED
url CDATA #IMPLIED url_ref IDREF #IMPLIED timeout CDATA #IMPLIED prop_ref IDREF #IMPLIED>
]>
<!-- idの先頭には、数字を使用できない。 -->
<!-- protocol:1=InProcess、2=WebService -->
<TMD>
<!-- マスタ データ -->
<!-- 接続URL(asmx単位に定義する) -->
<Url id="url_a" value="http://xxx.xxx.xxx.xxx/ASPNETWebService/ServiceForFx.asmx"/>
<Url id="url_b" value="http://xxx.xxx.xxx.xxx/ASPNETWebService/WCFHTTPSvcForFx.svc"/>
<Url id="url_c" value="net.tcp://localhost:7777/WCFService/WCFTCPSvcForFx/"/>
<Url id="url_d" value="http://xxx.xxx.xxx.xxx/ASPNETWebService/DotNETOnlineWebAPI"/>
<!-- 接続オプション(必要に応じて) -->
<Prop id="prop_a" value="ProxyUrl=http://127.0.0.1:8888;"/>
<!-- 接続先 データ -->
<!-- インプロセス -->
<Transmission id="testInProcess" protocol="1"/>
<!-- サービス -->
<!-- サービス(マスタ データを活用)-->
<Transmission id="testWebService" protocol="2" url_ref="url_a" timeout="60" prop_ref="prop_a" />
<Transmission id="testWebService2" protocol="3" url_ref="url_b" timeout="60" prop_ref="prop_a" />
<Transmission id="testWebService3" protocol="4" url_ref="url_c" timeout="60" prop_ref="prop_a" />
<Transmission id="testWebService4" protocol="5" url_ref="url_d" timeout="60" prop_ref="prop_a" />
</TMD>
In the current specification, this setting is done in the binding section for WCF.
However, I found the following information to which XML settings can be applied.
- WCFでのProxyの設定 | Windows - オレのメモ(仮)
http://community.giga-works.com/windows/wcfproxy.html
BasicHttpBinding binding = (BasicHttpBinding)service.Endpoint.Binding;
binding.BypassProxyOnLocal = true;
binding.UseDefaultWebProxy = false;
binding.ProxyAddress = new Uri(proxyServer);
- c# - How to set proxy credentials to specific wcf client? - Stack Overflow
https://stackoverflow.com/questions/17968307/how-to-set-proxy-credentials-to-specific-wcf-client
void SetProxySettings<TChannel>(ClientBase<TChannel> client,
bool useProxy, string address, int port, string login, string password)
where TChannel : class
{
if (!useProxy) return;
var b = client.Endpoint.Binding as BasicHttpBinding;
if (b == null)
{
System.Diagnostics.Debug.WriteLine("Binding of this endpoint is not BasicHttpBinding");
return;
}
b.ProxyAddress = new Uri(string.Format("http://{0}:{1}", address, port));
b.UseDefaultWebProxy = false; // !!!
b.Security.Mode = BasicHttpSecurityMode.Transport;
b.Security.Transport.ClientCredentialType = HttpClientCredentialType.None; // !!!
b.Security.Transport.ProxyCredentialType = HttpProxyCredentialType.Basic; // !!!
if (client.ClientCredentials == null) return;
client.ClientCredentials.UserName.UserName = login;
client.ClientCredentials.UserName.Password = password;
}
- <basicHttpBinding> | Microsoft Docs
https://docs.microsoft.com/ja-jp/dotnet/framework/configure-apps/file-schema/wcf/basichttpbinding
<basicHttpBinding>
<binding
allowCookies="Boolean"
bypassProxyOnLocal="Boolean"
closeTimeout="TimeSpan"
envelopeVersion="None/Soap11/Soap12"
hostNameComparisonMode="StrongWildCard/Exact/WeakWildcard"
maxBufferPoolSize="Integer"
maxBufferSize="Integer"
maxReceivedMessageSize="Integer"
messageEncoding="Text/Mtom"
name="string"
openTimeout="TimeSpan"
proxyAddress="URI"
receiveTimeout="TimeSpan"
sendTimeout="TimeSpan"
textEncoding="UnicodeFffeTextEncoding/Utf16TextEncoding/Utf8TextEncoding"
transferMode="Buffered/Streamed/StreamedRequest/StreamedResponse"
useDefaultWebProxy="Boolean"
<security mode="None/Transport/Message/TransportWithMessageCredential/TransportCredentialOnly">
<transport clientCredentialType="None/Basic/Digest/Ntlm/Windows/Certificate"
proxyCredentialType="None/Basic/Digest/Ntlm/Windows"
realm="string" />