jsgoupil / quickbooks-sync

Sync Quickbooks Desktop
MIT License
89 stars 40 forks source link

Unable to add a new Application to the Web Connector in 3.1.0 #66

Closed yudielcurbelo closed 1 year ago

yudielcurbelo commented 1 year ago

I'm not able to add new applications using version 3.1.0

I'm getting the following error image

Downgrading to version 3.0.0 is working but then I have to go back to version 3.1.0 for it to work in dotnet 7.

jsgoupil commented 1 year ago

I won't be able to help on this This is a certificate issue, you might need to provide more details to the QWC file. Could you share that?

yudielcurbelo commented 1 year ago

The issue is when adding it using version 3.1.0. The same QWC file works by adding it on version 3.0.0.

yudielcurbelo commented 1 year ago

Here is the file just in case.

<?xml version="1.0"?><QBWCXML><AppDescription>Sync QuickBooks with (redacted)</AppDescription><AppID></AppID><AppName>(redacted) (Development)</AppName><AppSupport>https://(redacted).ngrok.io/support</AppSupport><AppURL>https://(redacted).ngrok.io/QBConnectorAsync.asmx</AppURL><FileID>{547a6423-fce2-4ca7-82a4-cc237cb50564}</FileID><OwnerID>{77b5d44f-be10-4144-86a2-6e7ff02beb05}</OwnerID><QBType>QBFS</QBType><Scheduler><RunEveryNMinutes>30</RunEveryNMinutes></Scheduler><UserName>(redacted)</UserName></QBWCXML>

For it to work, I have to add the QWC file using version 3.0.0 and then upgrade to 3.1.0 then everything works on dotnet 7.

This is the error

 SoapCore.SoapEndpointMiddleware[0]
      An error occurred when trying to service a request on SOAP endpoint: /QBConnectorAsync.asmx
      System.Collections.Generic.KeyNotFoundException: The given key 'QBConnectorAsync.asmx' was not present in the dictionary.
         at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
         at SoapCore.SoapEndpointMiddleware`1.ProcessMetaFromFile(HttpContext httpContext, Boolean showDocumentation) in /_/src/SoapCore/SoapEndpointMiddleware.cs:line 964
         at SoapCore.SoapEndpointMiddleware`1.Invoke(HttpContext httpContext, IServiceProvider serviceProvider) in /_/src/SoapCore/SoapEndpointMiddleware.cs:line 168
jsgoupil commented 1 year ago

Maybe your server is misconfigured. Have you followed the documentation? Are you using UseWebConnector ?

jsgoupil commented 1 year ago

Oh are you saying using 3.1.0 on something else than .NET 7 is not working?

yudielcurbelo commented 1 year ago

Everything works fine for me using 3.1.0 and dotnet 7. The issue is at the time of adding a new QWC file. The only way that I can add a new file is by using version 3.0.0.

yudielcurbelo commented 1 year ago

Besides all the updates that were merged on Dec 15 for the dotnet 7. This is the one that caught my attention.

image

jsgoupil commented 1 year ago

Sorry I am still not following. Everything works fine with 3.1.0 and dotnet 7, but you say it doesn't work then?

@kemsky what do you think here? do you have a reason why this changed? I would probably be in favor to reverting that line.

yudielcurbelo commented 1 year ago

I'm sorry for my explanation.

Everything related to Syncing information to QuickBooks using 3.1.0 and dotnet 7 works. The only thing that does not work is adding a new file to the web connector.

The only way to add a new file to the web connector without getting the error is by downgrading to 3.0.0, still using dotnet 7.

kemsky commented 1 year ago

@jsgoupil , it looks like wsdl became required in SoapCore, @yudielcurbelo, you can try to copy extension method UseWebConnector from this package and try to provide something in WsdlFileOptions, maybe empty wsdl would suffice.

yudielcurbelo commented 1 year ago

I will try it. Are you able to add a new file using 3.1.0 in dotnet 7?

jsgoupil commented 1 year ago

Previously it was using this one:

public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, SoapEncoderOptions encoder, SoapSerializer serializer = SoapSerializer.DataContractSerializer, bool caseInsensitivePath = false, ISoapModelBounder soapModelBounder = null, Binding binding = null)
{
    return builder.UseSoapEndpoint(type, path, new SoapEncoderOptions[1] { encoder }, serializer, caseInsensitivePath, soapModelBounder, binding);
}

The closest new one is:

public static IApplicationBuilder UseSoapEndpoint(this IApplicationBuilder builder, Type type, string path, SoapEncoderOptions encoder, SoapSerializer serializer, bool caseInsensitivePath, ISoapModelBounder soapModelBounder, Binding binding, bool indentXml, bool omitXmlDeclaration)

And this calls other UseSoapEndpoint... I just spent the past 25 minutes trying to call the non obsolete version but I think Visual Studio Navigate to Definition is not picking the right one. I believe you'll have to call the SoapCoreOptions and use the

image

I'm currently working on other things, if you can handle this, it would be awesome @yudielcurbelo

yudielcurbelo commented 1 year ago

Sure. Soap was before my time and I have not work on it but will give it a try.

jsgoupil commented 1 year ago

@yudielcurbelo it was before everybody's time 😅 The only thing to do is to call the right method.

I believe @kemsky have tried the "basic" and the communication worked, but he probably didn't try to add a new Web Connector entry. He picked the one that matched the most of what we had before but the WSDLOptions can stay null. The BasicHttpBinding is 100% required. I have coded this years and years ago as well.

yudielcurbelo commented 1 year ago

Do you think that not using that parameter will work?

image

<PackageReference Include="SoapCore" Version="1.1.0.36" />
<!--    <PackageReference Include="SoapCore" Version="[1.1.0.36, 1.1.1.0)" />-->

All tests passed. I will have to setup a local NuGet repository to publish and test in my app.

jsgoupil commented 1 year ago

I'll think you'll have the same issue. The csproj probably shouldn't change

jsgoupil commented 1 year ago

You should make sure the fix you find works. You can create nuget packages with the bat file and load local repo from your code. You can do 3.1.0-alpha.1 and .2 etc. To keep trying.

yudielcurbelo commented 1 year ago

The solution is simple. Using the latest version of SoapCore.

<PackageReference Include="SoapCore" Version="1.1.0.36" />

Use another overload of UseSoapEndpoint

omitting BasicHttpBinding

app
      .UseSoapEndpoint(
          typeof(EndPoint),
          options.SoapPath,
          new SoapEncoderOptions()
          {
              ReaderQuotas = XmlDictionaryReaderQuotas.Max,
              WriteEncoding = Encoding.UTF8,
              MessageVersion = MessageVersion.Soap11
          },
          SoapSerializer.XmlSerializer,
          false,
          null
      );

All tests passed and I was able to add new QWC files and sync with QuickBooks 2023.

image

jsgoupil commented 1 year ago

I have proposed a fix. Will wait for the day and submit. Thanks everybody for the help.

FYI, the bug you were facing could only repro if you are not using localhost. So using ngrok would do the trick. Also, it was only during the addition of the QWC.

yudielcurbelo commented 1 year ago

I have proposed a fix. Will wait for the day and submit. Thanks everybody for the help.

FYI, the bug you were facing could only repro if you are not using localhost. So using ngrok would do the trick. Also, it was only during the addition of the QWC.

If you used Ngrok with the fix and it worked should be fine. I was using Ngrok too.

jsgoupil commented 1 year ago

3.1.1 is now released.