Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

WCF WebService with warnings and InvalidOperationException

I am currently trying to connect my ASP-NET Core 2 application to Magento's API (WSDL v2), but keep receiving the following errors:
*Doesn't matter which method I call, even the new PortTypeClient().loginAsync(username, password); throws that, with this random endpoint name salesOrderShipmentAddComment.

InvalidOperationException: The operation 'salesOrderShipmentAddComment' could not be loaded because it specifies \"rpc-style\" in \"literal\" mode, but uses message contract types or the System.ServiceModel.Channels.Message. This combination is disallowed -- specify a different value for style or use parameters other than message contract types or System.ServiceModel.Channels.Message.

However, using SoapUI, postman or importing with framework 4.6, it works perfectly. Using the Magento v1 API it works too, but I don't want to use this version.

During the import in asp-net core, I also recieve those warnings (importing v1 doesn't shows any warning): enter image description here

I'm almost creating a new 4.6 application, hosting it separately to work as a bridge between my application and Magento, even if it hurts my performance and architeture.

This is how I'm doing the import: enter image description here *Obs: In Data Type Options, I also tried checking different options, and selecting other data types.

Anything would help...
Thanks in advance

like image 864
Bruno Miquelin Avatar asked Jul 03 '18 14:07

Bruno Miquelin


2 Answers

I had the same problem. Make sure you update your Nuget Packages to 4.5.3. After, works correctly for me.

like image 126
Chris Avatar answered Sep 29 '22 01:09

Chris


Indeed updating the following packages to version 4.5.3 seems to resolve the issue:

System.ServiceModel.Duplex

System.ServiceModel.Http

System.ServiceModel.NetTcp

System.ServiceModel.Security

Seems like 4.4.4 version of those packages are installed by default, while adding WCF service reference via VS 2017 15.9.4 UI

like image 31
Milen Avatar answered Sep 29 '22 02:09

Milen