从InfoPath提交到WCF服务的奇怪错误消息

时间:2012-06-04 17:40:39

标签: .net wcf infopath2010

我正在构建一个InfoPath表单(InfoPath 2010),并且在自定义代码中我以编程方式调用WCF服务,作为提交操作的一部分,如下所示:

DriverHours.DriverHours allHours = new DriverHours.DriverHours();         bool spec;

    XPathNavigator myNav = this.MainDataSource.CreateNavigator();

    string allData = myNav.OuterXml;
    allData = allData.Replace("my:", "");

   result = allHours.SaveDriverHoursByString(allData);

SaveDriverHoursByString只接受一串XML数据,通过WCF将其保存到后端的数据库中。

执行提交块时,最后一行显示以下错误:

System.Web.Services.Protocols.SoapHeaderException
The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://tempuri.org/:Xml. The InnerException message was 'There was an error deserializing the object of type System.String. The maximum string content length quota (8192) has been exceeded while reading XML data. This quota may be increased by changing the MaxStringContentLength property on the XmlDictionaryReaderQuotas object used when creating the XML reader. Line 208, position 21.'.  Please see InnerException for more details.
   at System.Web.Services.Protocols.SoapHttpClientProtocol.ReadResponse(SoapClientMessage message, WebResponse response, Stream responseStream, Boolean asyncCall)
   at System.Web.Services.Protocols.SoapHttpClientProtocol.Invoke(String methodName, Object[] parameters)
   at HrsServicetemplate.DriverHours.DriverHours.SaveDriverHoursByString(String Xml)
   at HrsServicetemplate.FormCode.FormEvents_Submit(Object sender, SubmitEventArgs e)
   at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnSubmit(DocReturnEvent pEvent)
   at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnSubmitRequest(DocReturnEvent pEvent)

现在我知道解决方案是增加WCF服务的web.config上的内容长度。下面是我的web.config文件,错误仍然存​​在:

<?xml version="1.0"?>
<configuration>
  <connectionStrings>
   <!--<add name="IFMS_Connection" connectionString="Data Source=aaaa;User Id=aaaa;Password=abcdefg;"/>    -->
    <add name="IFMS_Connection" connectionString="Data Source=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=aaaa)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME = ORCLDEVL)));User Id=aaa;Password=aaaa;"/>

  </connectionStrings>
  <system.web>
   <httpRuntime maxRequestLength="2147483647" />
   <compilation debug="true" targetFramework="4.0" />
  </system.web>
  <system.serviceModel>

    <bindings>
      <wsHttpBinding>

        <binding name="NoSecurityBinding"  maxReceivedMessageSize="2147483647">
          <readerQuotas
             maxDepth="2147483647"
             maxStringContentLength="2147483647"
             maxArrayLength="2147483647"
             maxBytesPerRead="2147483647"
             maxNameTableCharCount="2147483647" />

          <security mode="None">
            <transport clientCredentialType="None"/>
            <message establishSecurityContext="false"/>
          </security>


        </binding>
      </wsHttpBinding>



    </bindings>


    <services>

    </services>
    <behaviors>      
      <serviceBehaviors>
        <behavior>
          <!-- To avoid disclosing metadata information, set the value below to false and remove the metadata endpoint above before deployment -->
          <serviceMetadata httpGetEnabled="true" />         
        </behavior>
        <behavior name="metadataAndDebug">
          <serviceMetadata httpGetEnabled="true" />

          <serviceDebug
            includeExceptionDetailInFaults="true"/>

        </behavior>
      </serviceBehaviors>
    </behaviors>

    <serviceHostingEnvironment multipleSiteBindingsEnabled="true" />
  </system.serviceModel>
 <system.webServer>
    <modules runAllManagedModulesForAllRequests="true"/>
  </system.webServer>

</configuration>

有什么想法吗?特别是我想知道丢失配置条目,谢谢!

1 个答案:

答案 0 :(得分:0)

可能是您更新了服务器端的配置,但没有更新客户端的配置。