我对网络服务很陌生,所以我正在与一些奇怪的行为作斗争。在我通过VS2010导入WSDL xml文件后,我得到了这些无法识别的策略断言。 WSDL文件是由SAP团队创建的,所以我不确定他们到底做了什么。
当我无视这些纪念时尝试使用网络服务我得到了这些代价: 提供的URI方案“https”无效;预期'http'。
我知道这个错误消息意味着我有一个与URI定义不同的传输逻辑,但我不确定我是应该对它做些什么还是更新WSDL文件。
<system.serviceModel>
<bindings>
<customBinding>
<binding name="binding">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:soap:functions:mc-style': -->
<!-- <wsdl:binding name='binding'> -->
<!-- <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> -->
<mtomMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Soap11WSAddressing10" maxBufferSize="65536"
writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</mtomMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false" />
</binding>
<binding name="binding_SOAP12">
<!-- WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:soap:functions:mc-style': -->
<!-- <wsdl:binding name='binding_SOAP12'> -->
<!-- <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> -->
<mtomMessageEncoding maxReadPoolSize="64" maxWritePoolSize="16"
messageVersion="Default" maxBufferSize="65536" writeEncoding="utf-8">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
</mtomMessageEncoding>
<httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard"
keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
useDefaultWebProxy="true" requireClientCertificate="false" />
</binding>
</customBinding>
</bindings>
<client>
<endpoint address="http://{HOSTNAME}/sap/bc/srt/rfc/sap/zicert_kunden_auslesen/010/005056a5007b1ee2a5da43a20303be2b/binding"
binding="customBinding" bindingConfiguration="binding" contract="ServiceReference.ZICERT_KUNDEN_AUSLESEN"
name="binding" />
<endpoint address="http://{HOSTNAME}/sap/bc/srt/rfc/sap/zicert_kunden_auslesen/010/005056a5007b1ee2a5da43a20303be2b/binding"
binding="customBinding" bindingConfiguration="binding_SOAP12"
contract="ServiceReference.ZICERT_KUNDEN_AUSLESEN" name="binding_SOAP12" />
</client>
答案 0 :(得分:1)
您的端点具有http
方案,但绑定仅定义httpsTransport
。您可以尝试将绑定更改为httpTransport
,或者查看您的端点是否也可以使用https
协议。
答案 1 :(得分:0)
请尝试使用TransportCredentialOnly
作为安全模式,不需要HTTPS协议(当您需要提供用户名和密码时)。
<bindings>
<basicHttpBinding>
<binding name="NewBinding">
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Basic" />
</security>
</binding>
</basicHttpBinding>
</bindings>
您可以在.NET代码中设置用户名和密码,如下所示:
sapService.ClientCredentials.UserName.UserName = "UserName";
sapService.ClientCredentials.UserName.Password = "Password";