Marcin
Marcin

Reputation: 1

Consuming SAP web service via .net

i am pretty new to web service so i am fighting with some strange behavior. After i have imported the WSDL xml file via VS2010 i get these unrecognized policy assertions. The WSDL file was created by the SAP team, so i am not sure what they exactly did.

When i am ignoring these commets an try to consume the web service i get this expections: The provided URI scheme 'https' is invalid; expected 'http'.

I know that this errormessage means that i have a different transport logic as the URI defines, but i am not sure if i should do something about it or renew the WSDL file.

    <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>

Upvotes: 0

Views: 1945

Answers (2)

Weifeng
Weifeng

Reputation: 799

Please try using TransportCredentialOnly as the security mode, which not requires HTTPS protocol (while you need to provide user name and password).

<bindings>
  <basicHttpBinding>
    <binding name="NewBinding">
      <security mode="TransportCredentialOnly">
        <transport clientCredentialType="Basic" />
      </security>
    </binding>
  </basicHttpBinding>
</bindings>

You can set the user name and password in .NET code as below:

sapService.ClientCredentials.UserName.UserName = "UserName";
sapService.ClientCredentials.UserName.Password = "Password";

Upvotes: 0

w5l
w5l

Reputation: 5746

Your Endpoint has the http scheme, but the binding only defines httpsTransport. You could try changing the binding to httpTransport, or see if your endpoints are available with the https protocol too.

Upvotes: 1

Related Questions