WCF SOAP XML作为SSRS的数据源

时间:2015-06-04 07:28:37

标签: c# xml wcf soap reporting-services

我有一个WCF服务,它返回SSRS的数据。因为我无法在SSRS rdl中调用我的接口方法。

Error in deserializing body of request message for operation 'CatReport'. OperationFormatter encountered an invalid Message body. Expected to find node type 'Element' with name 'ParameterClass' and namespace 'http://tempuri.org/'. Found node type 'Element' with name 'CatReport' and namespace 'http://tempuri.org/' (mscorlib)

WCF中的接口代码

[ServiceContract]
public interface IService1
{
    [OperationContract]
    ResponseContr CatReport(ParameterClass bbb);
}

ParameterClass

[MessageContract(IsWrapped = true)]
public class ParameterClass
{
    [MessageBodyMember]
    public string InformationType { get; set; }
    [MessageBodyMember]
    public string ItemLocation { get; set; }
    [MessageBodyMember]
}

ResponseContr

[MessageContract(IsWrapped = true)]
public class ResponseContr
{
    [MessageBodyMember]
    public List<Book> Books { get; set; }
}

图书类

[DataContract]
public class Book
{
    [DataMember]
    public string Type { get; set; }

    [DataMember]
    public int NoOfCopies { get; set; }
}

的Web.config

  <system.serviceModel>
<client>
  <endpoint address="" binding="basicHttpBinding" bindingConfiguration="BasicHttpBinding" contract="ReportingService.IService1" name="BasicHttpBinding" />
</client>
<diagnostics>
  <messageLogging logEntireMessage="true"
                  logMessagesAtServiceLevel="false"
                  logMessagesAtTransportLevel="false"
                  logMalformedMessages="true"
                  maxMessagesToLog="5000"
                  maxSizeOfMessageToLog="2000">
  </messageLogging>
</diagnostics>
<behaviors>
  <serviceBehaviors>
    <behavior name="ReportingService.LibraryServiceBehavior">
      <serviceMetadata httpGetEnabled="true" />
      <serviceDebug includeExceptionDetailInFaults="true" />
    </behavior>
  </serviceBehaviors>
</behaviors>
<bindings>
  <basicHttpBinding>
    <binding name="BasicHttpBinding" allowCookies="true" maxBufferPoolSize="2147483647"
      maxBufferSize="2147483647" maxReceivedMessageSize="2147483647">
      <readerQuotas maxDepth="2147483647" maxStringContentLength="2147483647"
        maxArrayLength="2147483647" />
    </binding>
  </basicHttpBinding>
</bindings>
<services>
  <service behaviorConfiguration="ReportingService.LibraryServiceBehavior"
   name="ReportingService.Service1">
    <endpoint address=""
    binding="basicHttpBinding" name="BasicHttpBinding" bindingConfiguration="BasicHttpBinding"
    contract="ReportingService.IService1">
      <identity>
        <dns value="localhost" />
      </identity>
    </endpoint>
    <endpoint address="mex"
    binding="mexHttpBinding"
    contract="IMetadataExchange" />
  </service>
</services>




<!--<behaviors>
  <serviceBehaviors>
    <behavior>
      -->
<!-- To avoid disclosing metadata information, set the values below to false before deployment -->
<!--
      <serviceMetadata httpGetEnabled="true" httpsGetEnabled="true" />
      -->
<!-- To receive exception details in faults for debugging purposes, set the value below to true.  Set to false before deployment to avoid disclosing exception information -->
<!--
      <serviceDebug includeExceptionDetailInFaults="false" />
    </behavior>
  </serviceBehaviors>
</behaviors>-->
<protocolMapping>
  <add binding="basicHttpsBinding" scheme="https" />
</protocolMapping>
<serviceHostingEnvironment aspNetCompatibilityEnabled="true" multipleSiteBindingsEnabled="true" />

实施界面

public class Service1 : IService1
{
    public ResponseContr CatReport(ParameterClass bbb)
    {
        return _clc.CatalogueList(bbb);
    }
}

Rdl DataSet查询

<Query>
<Method Namespace="http://tempuri.org/" Name="CatReport">
</Method>
<SoapAction>http://tempuri.org/IService1/CatReport</SoapAction>
</Query>

对此问题的任何帮助都将受到高度赞赏。

1 个答案:

答案 0 :(得分:0)

将错误消息按句子细分 A-明显反序列化错误! B-好的。邮件正文无效。 C-这告诉我们尚未将ParameterClass添加到层次结构中。 D-找到了CatReport,因此它在此下方。

看ParameterClass,似乎有一个序列化指令,但下面没有指定任何元素。建议的修改:

[MessageContract(IsWrapped = true)]
public class ParameterClass
{
    [MessageBodyMember]
    public string InformationType { get; set; }
    [MessageBodyMember]
    public string ItemLocation { get; set; }
}