问题描述
我尝试连接到开放的API:https://swea.riksbank.se/sweaWS/wsdl/sweaWS_ssl.wsdl
我在VS 2019 16.7.1中生成了很好的客户端并创建了Reference.cs文件
当我尝试执行远程功能时,我得到了404。
有了邮递员,我可以很好地执行远程功能,但是我注意到我需要使用此确切的Content-type并请求,否则我还会得到一个404
Content-Type:应用程序/肥皂+ xml; charset = UTF-8; action =“ urn:getCalendarDays”
请求
/META-INF/context.xml
使用上述邮递员设置,我得到的响应中包含正确的数据。
但是,如果我尝试通过客户端执行相同的操作,则会得到404。因此,尽管我将用提琴手调试WCF客户端,但是我似乎无法向其添加代理(我的代码)
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsd="http://swea.riksbank.se/xsd">
<soap:Header/>
<soap:Body>
<xsd:getCalendarDays>
<datefrom>2019-08-12</datefrom>
<dateto>2021-08-12</dateto>
</xsd:getCalendarDays>
</soap:Body>
</soap:Envelope>
调用client.getCalendarDaysAsync会生成此异常
“使用非空代理时,必须将WindowsProxyUsePolicy属性设置为WindowsProxyUsePolicy.UseCustomProxy。”
Google空手而归,请提出建议。谢谢
编辑:目前,我运行自己的客户端,但混乱的是,如果可能的话,我想使用内置的功能
var client = new SweaWebServicePortTypeClient(SweaWebServicePortTypeClient.EndpointConfiguration.SweaWebServiceHttpSoap12Endpoint,new EndpointAddress("https://swea.riksbank.se/sweaWS/services/SweaWebServiceHttpSoap12Endpoint"));
var binding = client.Endpoint.Binding as CustomBinding;
var htbe = binding.Elements.Find<HttpTransportBindingElement>();
var prox = WebRequest.GetSystemWebProxy();
htbe.ProxyAddress = new Uri("http://127.0.0.1:8866");
htbe.BypassProxyOnLocal = false;
htbe.UseDefaultWebProxy = false;
//htbe.ProxyAuthenticationScheme = AuthenticationSchemes.Anonymous;
var days = await client.getCalendarDaysAsync(DateTime.UtcNow.Date,DateTime.UtcNow.Date.AddDays(31));
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)