2012-06-04 70 views
0

我建立InfoPath表單(InfoPath中2010)和自定義代碼我打電話WCF服務編程爲如下提交行動的一部分:奇怪的錯誤消息,從提交到的InfoPath 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> 

任何想法?特別是我想知道丟失配置條目,謝謝!

回答

0

這可能是因爲您已經更新了服務器端的配置,但沒有更新客戶端的配置。