IsContentTypeSupported方法已正确实施

时间:2017-09-05 11:58:47

标签: c# web-services wcf

我已经实现了一个WCF服务,用于将c#项目与SAP连接。 但是当我尝试启动服务时收到以下错误。错误如下

内容类型text / html;响应消息的charset = iso-8859-1与绑定的内容类型不匹配(multipart / related; type =" application / xop + xml")。如果使用自定义编码器,请确保正确实现IsContentTypeSupported方法。响应的前442个字节是:

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
    <soap:Body>
        <soap:Fault>
            <faultcode> soap:Server </faultcode>
            <faultstring xml:lang="en"> RABAX occurred on server side </faultstring>
            <detail>
                <sap:Rabax xmlns:sap="http://www.sap.com/webas/710/soap/runtime/abap/fault/generic">
                    <SYDATUM>20170904</SYDATUM>
                    <SYUZEIT>152028</SYUZEIT>
                    <ERRORCODE>SYNTAX_ERROR</ERRORCODE>
                </sap:Rabax>
            </detail>
        </soap:Fault>
    </soap:Body>
</soap:Envelope>

以下是我的WCF服务的IIS配置文件。

<?xml version="1.0" encoding="utf-8"?>
<configuration>
  <configSections>
    <section name="log4net" type="log4net.Config.Log4NetConfigurationSectionHandler, log4net" />
  </configSections>
  <system.web>
    <compilation targetFramework="4.5" />
    <pages controlRenderingCompatibilityVersion="4.0" />
  </system.web>
  <system.serviceModel>
    <behaviors>
      <endpointBehaviors>
        <behavior name="CustomBehavior">
          <clientCredentials>
            <httpDigest impersonationLevel="None" />
          </clientCredentials>
        </behavior>
      </endpointBehaviors>
      <serviceBehaviors>
        <behavior name="">
          <serviceMetadata httpGetEnabled="true" />
          <serviceDebug includeExceptionDetailInFaults="true" />
        </behavior>
      </serviceBehaviors>
    </behaviors>
    <bindings>
      <customBinding>
        <binding name="CustomBinding_HTTP">
          <binaryMessageEncoding maxReadPoolSize="64" maxWritePoolSize="64" maxSessionSize="2147483647">
            <readerQuotas maxDepth="300" maxStringContentLength="2147483647" maxArrayLength="2147483647" maxBytesPerRead="2147483647" maxNameTableCharCount="2147483647" />
          </binaryMessageEncoding>
          <httpTransport manualAddressing="false" maxBufferPoolSize="2147483647" maxReceivedMessageSize="2147483647" allowCookies="false" authenticationScheme="Anonymous" bypassProxyOnLocal="false" decompressionEnabled="true" hostNameComparisonMode="StrongWildcard" keepAliveEnabled="true" maxBufferSize="2147483647" proxyAuthenticationScheme="Anonymous" realm="" transferMode="Buffered" unsafeConnectionNtlmAuthentication="false" useDefaultWebProxy="true" />
        </binding>
        <binding name="bindingBAPI" receiveTimeout="00:10:00" sendTimeout="00:05:00">
          <mtomMessageEncoding messageVersion="Soap11"></mtomMessageEncoding>
          <httpTransport authenticationScheme="Basic" realm="SAP NetWeaver Application Server[SC3/900]"></httpTransport>
        </binding>
      </customBinding>
    </bindings>
    <client>
      <endpoint address="my end point address" binding="customBinding" bindingConfiguration="bindingBAPI" contract="ServiceReferenceBAPI.z_bedmanagement" name="BAPIEndpoint" />
    </client>
    <services>
      <service name="Cerner.BM.Outbound.Service.BM_OutboundService">
        <endpoint address="" binding="customBinding" bindingConfiguration="CustomBinding_HTTP" name="BM_OutboundService" contract="Cerner.BM.Outbound.Service.IBM_OutboundService">
          <identity>
            <dns value="localhost" />
          </identity>
        </endpoint>
        <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" />
      </service>
    </services>
    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="true" />
  </system.webServer>

  <!-- Client and institution value for successful BAPI Connection. -->
  <appSettings>

    <add key="BAPI_Client" value="" />
    <add key="BAPI_Institution" value="" />
    <add key="BAPI_UserName" value=""/> 
    <add key="BAPI_Password" value=""/>
  </appSettings>
</configuration>

0 个答案:

没有答案