3

我正在尝试设置将由 .NET 应用程序使用的 SAP Web 服务。认为这很简单,我在 SAP 中设置了服务以使用 HTTP。我在 .NET 项目树中右键单击“服务引用”,然后选择“添加服务引用...”,输入本地托管在我们服务器上的 WSDL URL,然后按 Go,然后选择端点,然后按 OK .

我打开 app.config 文件发现它说<httpsTransport>而不是<httpTransport>,尽管我将它设置为使用 HTTP。

<system.serviceModel>
      <bindings>
           <customBinding>
               <binding name="ZHR_RECRUITNEW1">
                    <!--WsdlImporter encountered unrecognized policy assertions in ServiceDescription 'urn:sap-com:document:sap:soap:functions:mc-style':-->
                    <!--    <wsdl:binding name='ZHR_RECRUITNEW'>    -->
                    <!--        <wsaw:UsingAddressing xmlns:wsaw="http://schemas.xmlsoap.org/ws/2004/08/addressing">..</wsaw:UsingAddressing>    -->
                    <!--        <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 maxReadPoolSize="64" maxWritePoolSize="16"
                        messageVersion="Soap11" writeEncoding="utf-8">
                        <readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
                            maxBytesPerRead="4096" maxNameTableCharCount="16384" />
                    </textMessageEncoding>
                    <httpsTransport manualAddressing="false" maxBufferPoolSize="524288"
                        maxReceivedMessageSize="65536" allowCookies="false" authenticationScheme="Anonymous"
                        bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
                        keepAliveEnabled="true" maxBufferSize="65536" proxyAuthenticationScheme="Anonymous"
                        realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false"
                        useDefaultWebProxy="true" requireClientCertificate="false" />
                </binding>
            </customBinding>
        </bindings>
        <client>
            <endpoint address="http://<host>:8000/sap/bc/srt/rfc/sap/zhr_recruitnew/300/zhr_recruitnew/zhr_recruitnew"
                binding="customBinding" bindingConfiguration="ZHR_RECRUITNEW1"
                contract="ServiceReference2.ZHR_RECRUITNEW" name="ZHR_RECRUITNEW1" />
        </client>
    </system.serviceModel>

因此,为了“正常”工作,我必须将该 xml 标记从 httpsTransport 重命名为 httpTransport 并删除属性 requireClientCertificate="false"

因此,我进入 SAP 设置服务以使用 HTTPS,然后返回 .NET 项目并重新添加该服务,以获取以下错误消息:

Could not establish trust relationship for the SSL/TLS secure channel with authority '<host>:<portnumber>'.

我很好奇配置文件中的评论“WsdlImporter 遇到无法识别的策略断言”是否与从 SAP 误读的信息有关

4

1 回答 1

3

无法为具有权限“:”的 SSL/TLS 安全通道建立信任关系。

你得到这个是因为服务提供商的证书不在你本地受信任的根证书中。

您可以将此添加到您的代码中(在其他任何内容之前)以忽略它:

System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
于 2010-03-04T12:09:01.937 回答