开发者

Web Service hosted by SAP and consumed by a .NET Application

I'm trying to setup an SAP Web Service that would be consumed by a .NET application. Thinking it was simple, I had set the Service up in SAP to use HTTP. I right-click on the "Service References" in the .NET Project Tree, and choose "Add Service Reference...", Enter the WSDL URL locally hosted on our servers, and press Go, then select the endpoint, then press OK.

I opened up the app.config file to find that it says <httpsTransport> instead of <httpTransport>, although I set it up to use 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"
                        ma开发者_运维知识库xReceivedMessageSize="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>

So, for it to work "properly", I have to rename that xml tag from httpsTransport to httpTransport and remove the attribute requireClientCertificate="false"

So, I go into SAP to set up the Service to use HTTPS, and then go back to the .NET project and re-add that service, to get this error message:

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

I'm curious as to whether that comment "WsdlImporter encountered unrecognized policy assertions" in the config file has to do anything with that info being misread from SAP


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

You get this because the certificate on the service provider isn't in your trusted root certificates locally.

You can add this to your code(before anything else) to ignore it:

System.Net.ServicePointManager.ServerCertificateValidationCallback = ((sender, certificate, chain, sslPolicyErrors) => true);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜