C#提供的URI方案';http';无效;预期';https';
我在调用web服务的一个方法时遇到这个错误,我不知道该怎么办:s 以下是例外情况的详细信息: {“提供的URI方案“http”无效;应为 “https”。\r\n参数名称:via”} 这是我的App.configC#提供的URI方案';http';无效;预期';https';,c#,uri,app-config,C#,Uri,App Config,我在调用web服务的一个方法时遇到这个错误,我不知道该怎么办:s 以下是例外情况的详细信息: {“提供的URI方案“http”无效;应为 “https”。\r\n参数名称:via”} 这是我的App.config <?xml version="1.0" encoding="utf-8" ?> <configuration> <connectionStrings> <add name="PowerWeb" connectionStri
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<connectionStrings>
<add name="PowerWeb" connectionString="Data Source=MYSERVER;Initial Catalog=MYTABLE;User ID=MYUSER;Password=MYPW" providerName="System.Data.SqlClient" />
</connectionStrings>
<startup>
<supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5" />
</startup>
<system.serviceModel>
<bindings>
<customBinding>
<binding name="ZWS_HARMONIZACAO">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:rfc:functions': -->
<!-- <wsdl:binding name='ZWS_HARMONIZACAO'> -->
<!-- <saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/">..</saptrnbnd:OptimizedXMLTransfer> -->
<!-- <saptrnbnd:OptimizedXMLTransfer xmlns:saptrnbnd="http://www.sap.com/webas/710/soap/features/transportbinding/">..</saptrnbnd:OptimizedXMLTransfer> -->
<!-- <sapattahnd:Enabled xmlns:sapattahnd="http://www.sap.com/710/features/attachment/">..</sapattahnd:Enabled> -->
<textMessageEncoding messageVersion="Soap11" />
<httpsTransport authenticationScheme="Basic" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://mydomain:8080/sap/bc/srt/rfc/sap/zws_harmonizacao/010/zws_harmonizacao/zws_harmonizacao"
binding="customBinding" bindingConfiguration="ZWS_HARMONIZACAO"
contract="ServiceReference1.ZWS_HARMONIZACAO" name="ZWS_HARMONIZACAO" />
</client>
</system.serviceModel>
</configuration>
有人能帮我吗?
非常感谢您在绑定中指定了一个
httpsTransport
,但是在端点定义中,您提供了http
作为协议。正如评论中所建议的,尝试更改我在一个项目中遇到了相同的问题。只需在配置文件中更改以下行:
<httpsTransport authenticationScheme="Basic" />
到
一切正常,因为您的端点是http 我更改了绑定的配置,如下所示:
var binding = new BasicHttpBinding(BasicHttpSecurityMode.None);
var address = new EndpointAddress(url);
var client = new MobileServiceClient.MobileServiceClient(binding, address);
端点地址类似于:
它是有效的。[Solved]从传输更改为无
如果配置是代码的一部分
BasicHttpSecurityMode.Transport到
BasicHttpSecurityMode.None
从传输更改为无
如果配置是代码的一部分
BasicHttpSecurityMode.Transport到BasicHttpSecurityMode.None
2.如果配置是web.config的一部分
至
<security mode="None">
</security>
您是否尝试更改地址=”http://mydomain:8080/sap/bc/srt/rfc/sap/zws_harmonizacao/010/zws_harmonizacao/zws_harmonizacao“
至地址=”https://mydomain:8080/sap/bc/srt/rfc/sap/zws_harmonizacao/010/zws_harmonizacao/zws_harmonizacao“
?(将s
添加到http)这会给我带来另一个错误:绑定失败-名称“$exception”在当前上下文中不存在使用此名称的代码是什么?上面的代码段中未定义名称异常
。它是在从web服务调用方法时定义的。。下面是代码片段,感谢您的回答,但给了我另一个错误:BindingFailure:名称“$exception”在当前上下文中不存在。我试图将httpsTransport更改为httpTransport,但错误相同。由于您发布了另一个更完整的答案,请删除此答案。
<security mode="None">
</security>