0

我对网络服务很陌生,所以我正在与一些奇怪的行为作斗争。通过 VS2010 导入 WSDL xml 文件后,我得到了这些无法识别的策略断言。WSDL 文件是由 SAP 团队创建的,所以我不确定他们到底做了什么。

当我忽略这些评论并尝试使用 Web 服务时,我得到了这样的期望: 提供的 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>

4

2 回答 2

1

您的端点具有http方案,但绑定仅定义httpsTransport. 您可以尝试将绑定更改为httpTransport,或者查看您的端点是否也可用于https协议。

于 2013-04-09T07:34:16.463 回答
0

请尝试使用TransportCredentialOnlyas 安全模式,不需要 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";
于 2016-08-25T08:18:48.880 回答