Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

C# - magento 2.0.2 - error deserialsing SOAP call salesInvoiceRepositoryV1GetList #3605

Closed
manhao-chen opened this Issue Mar 2, 2016 · 46 comments

Comments

Projects
None yet
@manhao-chen
Copy link

commented Mar 2, 2016

details here

https://community.magento.com/t5/Programming-Questions/C-magento-2-0-2-error-deserialsing-SOAP-call/m-p/30859

Release: 2.0.2 Community Version.

writing a service by adding the magento soap url as a service reference,
when calling the salesInvoiceRepositoryV1GetList i get an error with the framework tries to deserialise the data

Error in deserializing body of reply message for operation 'salesInvoiceRepositoryV1GetList'.

fiddler returns the data correctly, but unable to deserialize

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Mar 2, 2016

found the culprits

the 3 properties being returned are null,

baseShippingDiscountTaxCompensationAmnt
baseDiscountTaxCompensationAmount
discountTaxCompensationAmount

the datatype is a float not nullable float data type, so either don't return the property in the soap xml if there is no value,

please fix this in the next version release

@choukalos choukalos added PS bug report and removed PS labels Mar 2, 2016

@choukalos

This comment has been minimized.

Copy link

commented Mar 2, 2016

Created internal bug ( MAGETWO-50026 ) to track. Flagged architect to ensure we behave consistently with other services for this scenario.

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Mar 5, 2016

add a few more to the list, these return and fails deserailsation

baseDiscountTaxCompensationInvoiced
baseDiscountTaxCompensationRefunded
discountTaxCompensationInvoiced
discountTaxCompensationRefunded
discountTaxCompensationCanceled

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Apr 3, 2016

do we have some sort of idea when this will be fixed and which release will have the fix?

@vivekadvsol

This comment has been minimized.

Copy link

commented Apr 7, 2016

I am also having similar problem "Error in deserializing body of reply message for operation 'catalogProductRepositoryV1Get' " magento version 2.0.4. How do i fix this? could someone please help with this.

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Apr 17, 2016

any ideas if this will be patch up in the next release?

@manhao-chen

This comment has been minimized.

Copy link
Author

commented May 24, 2016

could we get some updates regarding this bug? this should of been resolved for all people who wanting to use soap integration with other applications/services, but we can't cause of the serialization...

@vivekadvsol

This comment has been minimized.

Copy link

commented May 24, 2016

Now I gone back to 1.9 and the main reason being not able to use the soap.

@davidverholen

This comment has been minimized.

Copy link
Member

commented Jun 14, 2016

just testet this example for baseShippingDiscountTaxCompensationAmnt.

To ensure that the correct type is returned it is mandatory to type cast the value when it is retrieved from the data model. I think this has to be added in many places but is quite easy to fix.

type casting this to float results in 0 beeing returned instead of null which shoul solve the problem

@davidverholen

This comment has been minimized.

Copy link
Member

commented Jun 22, 2016

ok, the problem simply seems to be, that null is never type casted here: https://github.com/magento/magento2/blob/develop/lib/internal/Magento/Framework/Reflection/TypeCaster.php#L25

This is a Problem in languages with strict types since the scalar types are not allowed to be null, instead they have to be casted to "", 0 or 0.0 for example

@KrystynaKabannyk

This comment has been minimized.

Copy link

commented Jun 23, 2016

Hello @lindows-xx, this issue has been fixed in the 2.1.0 Release, that's why I'm closing it. If you have any questions or additional information regarding the issue feel free to reopen it or create a new one.

@KrystynaKabannyk

This comment has been minimized.

Copy link

commented Jun 24, 2016

Sorry for the confusion, we double checked, and unfortunately this issue didn't go to the 2.1.0 release, it will come to the next possible release.

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Jul 6, 2016

any ideas of when the next release will be?

magento-cicd2 pushed a commit that referenced this issue Jul 14, 2016

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Aug 4, 2016

bump for updates?

@vkorotun vkorotun removed the CS label Aug 4, 2016

okorshenko pushed a commit to isitnikov/magento2 that referenced this issue Aug 10, 2016

okorshenko pushed a commit to isitnikov/magento2 that referenced this issue Aug 10, 2016

okorshenko pushed a commit to isitnikov/magento2 that referenced this issue Aug 10, 2016

@elenleonova

This comment has been minimized.

Copy link

commented Aug 10, 2016

The fix has been provided as a part of 2.0.9 release.

@davidverholen

This comment has been minimized.

Copy link
Member

commented Sep 19, 2016

in the example above, one of multiple examples would be the baseShippingDiscountTaxCompensationAmnt. This is a float field but a null value is provided. This should be 0.

@SerhiyShkolyarenko

This comment has been minimized.

Copy link
Contributor

commented Sep 19, 2016

@manhao-chen I checked all the fields that are marked as float not nullable on the Magento/Sales/Api/Data/InvoiceInterface.php, but all of them are filled with numbers in your example. Could you check again on Magento 2.1.1 or latest develop branch, if SoapUI is able to unserialize the server response?

@SerhiyShkolyarenko

This comment has been minimized.

Copy link
Contributor

commented Sep 19, 2016

@davidverholen now that field is declared as
/** * Gets the base shipping discount tax compensation amount for the invoice. * * @return float|null Base shipping discount tax compensation amount. */ public function getBaseShippingDiscountTaxCompensationAmnt();
so, it's implied to be null or float.

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Sep 19, 2016

@SerhiyShkolyarenko the fix you had just implemented, is it out in 2.1.1 or it will be in the next release?

@SerhiyShkolyarenko

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2016

@manhao-chen I figured out that the fix is not included in 2.1.1 release. As far as it's present on develop branch, it will be a part of the following release.

@SerhiyShkolyarenko

This comment has been minimized.

Copy link
Contributor

commented Sep 20, 2016

I am closing the issue on github now as far as the fix is delivered to develop branch, but feel free to leave comments if it won't work for you after update. Thank you for collaboration!

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Sep 20, 2016

@SerhiyShkolyarenko i will test the next release and report back

@davidverholen

This comment has been minimized.

Copy link
Member

commented Sep 20, 2016

@SerhiyShkolyarenko the problem is, that in strict typed languages, null is not allowed for float. It's not possible to define a value as float or null when you create a WSDL.

Even in php with strict mode enabled a float value must not be null. Here is an example (for php7) with strict mode enabled

<?php
declare(strict_types=1);

function returnFloat() : float
{
    return null;
}

var_dump(returnFloat());

This throws an error since the function is not allowed to return null when strict typed to float.

So when you create a SOAP Client in strict typed languages and a field typed as float is null, this throws an error.

@SerhiyShkolyarenko

This comment has been minimized.

Copy link
Contributor

commented Sep 21, 2016

@davidverholen AFAIK C# supports nullable double. https://msdn.microsoft.com/en-us/library/2cf62fcy.aspx
Will it help?

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Sep 21, 2016

@SerhiyShkolyarenko the problem is when the wsdl is generated, would the property datatype be in c#

double
or
nullable

@davidverholen

This comment has been minimized.

Copy link
Member

commented Sep 21, 2016

the point is, wsdl definition does not support null for float types and yet there are null values in fields that are of type float

Only supported non numeric values are INF, -INF, and NaN

http://books.xmlschemata.org/relaxng/ch19-77095.html
https://www.w3.org/2001/XMLSchema.xsd

@SerhiyShkolyarenko

This comment has been minimized.

Copy link
Contributor

commented Sep 22, 2016

Reopened issue to clarify compatibility.

@MarkB42

This comment has been minimized.

Copy link

commented Oct 4, 2016

Hi, I'm getting the same issue when using Mage 2.1.1 catalogProductRepositoryV1Get to pull a product down to Visual Studio via WSDL SOAP. The pull worked fine then stopped working all of a sudden. Tracked it down to the Quantity against the product being "empty". Set the Qty to 0 and it started working. #davidverholen is correct in that the system is returning non-standard acceptable data.

The nullable float in C# is technically a different type to float, it's effectively a wrapper around float.

Edit: Also causing issues in catalogProductRepositoryV1Save. As the returned object doesn't have its quantity set it causes the method to throw a deserilization error.

@SerhiyShkolyarenko

This comment has been minimized.

Copy link
Contributor

commented Oct 5, 2016

Internal issue for investigation(and fixing) is MAGETWO-59017.

@manhao-chen

This comment has been minimized.

Copy link
Author

commented Oct 12, 2016

is there any idea as to when this will be fixed?

@epson121

This comment has been minimized.

Copy link
Collaborator

commented Dec 20, 2016

In addition to the fields mentioned above, we've experienced issues with <isCustomerNotified> field in salesOrderRepositoryV1's getList method (2.1.2. Magento)

In <statusHistories> node for orders being paid with Authorize.net, response contained empty field, when it should have been int.
<isCustomerNotified /> returned instead of <isCustomerNotified>0<isCustomerNotified> .

Casting to int fixed the issue (just like the float casting above).

@Nicelabsrl

This comment has been minimized.

Copy link

commented Dec 29, 2016

I solved issue exposed by @epson121 editing the file History.php in /vendor/magento/module-sales/Model/Order/Status

I have modified the following function:

 public function setIsCustomerNotified($flag = null)
    {
        if ($flag === null) {
            $flag = 0; 
        }
        return $this->setData('is_customer_notified', $flag);
    }
public function getIsCustomerNotified()
    {
        $ret = $this->getData(OrderStatusHistoryInterface::IS_CUSTOMER_NOTIFIED);
		if($ret) === null)
			return 0;
		else return $ret;
    }
@veloraven

This comment has been minimized.

Copy link
Contributor

commented Jun 19, 2017

I'm closing this report as the issue has been fixed.
If you can still reproduce this issue, please create a new GitHub issue report.

@veloraven veloraven closed this Jun 19, 2017

magento-engcom-team pushed a commit that referenced this issue Jan 18, 2019

Lysenko Olexandr
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.