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 · 48 comments
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development

Comments

@manhao-chen
Copy link

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
Copy link
Author

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
Copy link

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

@manhao-chen
Copy link
Author

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

baseDiscountTaxCompensationInvoiced
baseDiscountTaxCompensationRefunded
discountTaxCompensationInvoiced
discountTaxCompensationRefunded
discountTaxCompensationCanceled

@manhao-chen
Copy link
Author

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

@vivekadvsol
Copy link

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
Copy link
Author

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

@manhao-chen
Copy link
Author

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
Copy link

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

@NadiyaS NadiyaS added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Jun 8, 2016
@davidverholen
Copy link
Member

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
Copy link
Member

davidverholen 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
Copy link

KrystynaKabannyk 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
Copy link

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
Copy link
Author

any ideas of when the next release will be?

magento-cicd2 pushed a commit that referenced this issue Jul 14, 2016
@manhao-chen
Copy link
Author

bump for updates?

@elenleonova
Copy link

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

@SerhiyShkolyarenko
Copy link
Contributor

@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
Copy link
Author

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

@SerhiyShkolyarenko
Copy link
Contributor

@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
Copy link
Contributor

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!

@SerhiyShkolyarenko SerhiyShkolyarenko added Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development and removed Progress: needs update labels Sep 20, 2016
@manhao-chen
Copy link
Author

@SerhiyShkolyarenko i will test the next release and report back

@davidverholen
Copy link
Member

davidverholen 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
Copy link
Contributor

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

@manhao-chen
Copy link
Author

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

double
or
nullable

@davidverholen
Copy link
Member

davidverholen 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
Copy link
Contributor

Reopened issue to clarify compatibility.

@SerhiyShkolyarenko SerhiyShkolyarenko added Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog and removed Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development labels Sep 22, 2016
@MarkB42
Copy link

MarkB42 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
Copy link
Contributor

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

@SerhiyShkolyarenko SerhiyShkolyarenko added the Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development label Oct 5, 2016
@manhao-chen
Copy link
Author

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

@epson121
Copy link

epson121 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
Copy link

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
Copy link
Contributor

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.

@rezapasha
Copy link

Hi, I'm getting the same issue when using Mage 2.3.4 for SalesOrderRepositoryV1GetList
the fix you had just implemented, is it out in 2.3.4 or it will be in the next release?

@rezapasha
Copy link

I checked and salesInvoiceRepositoryV1GetList works fine but the same issue with SalesOrderRepositoryV1GetList on 2.3.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug report Component: Framework/Webapi USE ONLY for FRAMEWORK RELATED BUG! E.g If bug related to Catalog WEB API use just Catalog Issue: Ready for Work Gate 4. Acknowledged. Issue is added to backlog and ready for development
Projects
None yet
Development

No branches or pull requests