jsgoupil/quickbooks-sync

QuickBooks Sync does not work with .NET 7

G19m99 opened this issue · 9 comments

I built the sample application to connect with Quick books.
i am getting "Authentication failed" back from the webConnector when it tries to connect with the application.

here's the logs from the WebConnector

20221114.18:53:19 UTC : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session locked *********************
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : Initiated connection to the following application.
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppName: My App
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppUniqueName (if available): My App
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.instantiateWebService() : AppURL: http://localhost:64642/QBConnectorAsync.asmx
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_serverVersion() : *** Calling serverVersion().
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_serverVersion() : Received from serverVersion() following parameter:<serverVersionRet="3.0.2.0">
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : *** Calling clientVersion() with following parameter:<productVersion="2.3.0.215">
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : Received from clientVersion() following parameter:<clientVersionRet="">
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_clientVersion() : This application agrees with the current version of QBWebConnector. Allowing update operation.
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_authenticate() : Authenticating to application 'My App', username = 'username'
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_authenticate() : *** Calling authenticate() with following parameters:<userName="username"><password=
20221114.18:53:19 UTC : QBWebConnector.SOAPWebService.do_authenticate() : QBWC1012: Authentication failed due to following error message.
Object reference not set to an instance of an object.
More info:
StackTrace = at QBWebConnector.WebService.do_authenticate(String& ticket, String& companyFileName)
Source = QBWebConnector
20221114.18:53:20 UTC : QBWebConnector.RegistryManager.setUpdateLock() : HKEY_CURRENT_USER\Software\Intuit\QBWebConnector\UpdateLock has been set to False
20221114.18:53:20 UTC : QBWebConnector.RegistryManager.setUpdateLock() : ********************* Update session unlocked *********************
20221114.18:53:20 UTC : QBWebConnector.WebServiceManager.DoUpdate() : Update completed with errors. See log (QWClog.txt) for details.
20221114.18:53:20 UTC : UpdateThisScheduledApp() : QBWC1031: Update completed with some error. Application has been notified of the error accordingly. See QWCLog for further information.

This is the log files coming from the Web Connector. Do you have an error on your server side?

I'm having the exact same logging errors in the web connector as above and yes, there is an error in the server logs. This began happening after upgrading my project from .NET 6 to .NET 7

SoapCore.SoapEndpointMiddleware[0]
An error occurred when trying to service a request on SOAP endpoint: /QBConnectorAsync.asmx
System.InvalidOperationException: Reading is not allowed after reader was completed.
at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_NoReadingAllowed()
at System.IO.Pipelines.StreamPipeReader.ReadAsync(CancellationToken cancellationToken)
at SoapCore.MessageEncoder.PipeStream.Read(Span1 buffer) at System.Xml.EncodingStreamWrapper.Read(Span1 buffer)
at System.Xml.XmlBufferReader.TryEnsureBytes(Int32 count)
at System.Xml.XmlUTF8TextReader.BufferElement()
at System.Xml.XmlUTF8TextReader.ReadStartElement()
at System.Xml.XmlUTF8TextReader.Read()
at System.ServiceModel.Channels.Message.ReadStartBody(XmlDictionaryReader reader, EnvelopeVersion envelopeVersion, Boolean& isFault, Boolean& isEmpty)
at System.ServiceModel.Channels.ReceivedMessage.ReadStartBody(XmlDictionaryReader reader)
at System.ServiceModel.Channels.StreamedMessage..ctor(XmlDictionaryReader reader, Int32 maxSizeOfHeaders, MessageVersion desiredVersion)
at System.ServiceModel.Channels.Message.CreateMessage(XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders, MessageVersion version)
at System.ServiceModel.Channels.Message.CreateMessage(XmlReader envelopeReader, Int32 maxSizeOfHeaders, MessageVersion version)
at SoapCore.MessageEncoder.SoapMessageEncoder.ReadMessageAsync(Stream stream, Int32 maxSizeOfHeaders, String contentType)
at SoapCore.MessageEncoder.SoapMessageEncoder.ReadMessageAsync(PipeReader pipeReader, Int32 maxSizeOfHeaders, String contentType)
at SoapCore.SoapEndpointMiddleware.ProcessOperation(HttpContext httpContext, IServiceProvider serviceProvider)
at SoapCore.SoapEndpointMiddleware.Invoke(HttpContext httpContext, IServiceProvider serviceProvider)
fail: Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddleware[1]
An unhandled exception has occurred while executing the request.
System.InvalidOperationException: Reading is not allowed after reader was completed.
at System.IO.Pipelines.ThrowHelper.ThrowInvalidOperationException_NoReadingAllowed()
at System.IO.Pipelines.StreamPipeReader.ReadAsync(CancellationToken cancellationToken)
at SoapCore.MessageEncoder.PipeStream.Read(Span1 buffer) at System.Xml.EncodingStreamWrapper.Read(Span1 buffer)
at System.Xml.XmlBufferReader.TryEnsureBytes(Int32 count)
at System.Xml.XmlUTF8TextReader.BufferElement()
at System.Xml.XmlUTF8TextReader.ReadStartElement()
at System.Xml.XmlUTF8TextReader.Read()
at System.ServiceModel.Channels.Message.ReadStartBody(XmlDictionaryReader reader, EnvelopeVersion envelopeVersion, Boolean& isFault, Boolean& isEmpty)
at System.ServiceModel.Channels.ReceivedMessage.ReadStartBody(XmlDictionaryReader reader)
at System.ServiceModel.Channels.StreamedMessage..ctor(XmlDictionaryReader reader, Int32 maxSizeOfHeaders, MessageVersion desiredVersion)
at System.ServiceModel.Channels.Message.CreateMessage(XmlDictionaryReader envelopeReader, Int32 maxSizeOfHeaders, MessageVersion version)
at System.ServiceModel.Channels.Message.CreateMessage(XmlReader envelopeReader, Int32 maxSizeOfHeaders, MessageVersion version)
at SoapCore.MessageEncoder.SoapMessageEncoder.ReadMessageAsync(Stream stream, Int32 maxSizeOfHeaders, String contentType)
at SoapCore.MessageEncoder.SoapMessageEncoder.ReadMessageAsync(PipeReader pipeReader, Int32 maxSizeOfHeaders, String contentType)
at SoapCore.SoapEndpointMiddleware.ProcessOperation(HttpContext httpContext, IServiceProvider serviceProvider)
at SoapCore.SoapEndpointMiddleware.Invoke(HttpContext httpContext, IServiceProvider serviceProvider)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.SpaServices.Webpack.ConditionalProxyMiddleware.Invoke(HttpContext context)
at Microsoft.AspNetCore.Diagnostics.DeveloperExceptionPageMiddlewareImpl.Invoke(HttpContext context)
info: SoapCore.SoapEndpointMiddleware[0]
Request for operation IQbManager.clientVersion received

Thanks for the update! It seems to be a problem with .net 7.
I will have a look next week if nobody has found a solution.

@jsgoupil, @G19m99, QbSync.WebConnector.AspNetCore is using SoapCore 1.0.0 which is quite old, the latest version is 1.1.0.36 unfortunately it is not binary compatible. I replaced QbSync.WebConnector.AspNetCore with my custom code and updated SoapCore, all my tests passed however I have not tried it in production yet.

Also, it makes sense to provide singleton service that implements IFaultExceptionTransformer otherwise actual error is hidden.

@kemsky I welcome a PR here, I am swamped at the moment and do not have any cycle until mid January 2023.
If updating SoapCore (which is most likely the culprit), it would be great to avoid updating the minimal version of this library here.

Thanks for your findings!

@jsgoupil, I've just tested my fix on production system and it worked, I'll try to make a PR.

@jsgoupil, I've created merge request #64.

Thank you @kemsky
I'm in vacation in India, this is why it took a bit longer.

OK, I had time to handle this, I also added tests to target framework 6.0 since it's LTS, then just published.