Open LordVeovis opened 4 years ago
epregoy, please provide the steps to reproduce the error.
I am using this library for consuming odoo xml-rpc api. Odoo not return integer fault code. Even though I set the flag AllowStringFaultCode
, it keeps throwing the above error. This is because of this line. If AllowStringFaultCode
is true, exception should not be thrown. So the condition should be if(!AllowStringFaultCode) throw;
;
If AllowStringFaultCode
is set, XmlRpcSerializer
will try to extract string fault code again. But here is also another problem. There are two internal struct representing faultCode and faultString. internal struct Fault
is for integer fault code and private struct FaultStruct
is for string fault code. This two struct should have exact same property name. But faultCode
and faultString
property in Fault
struct start with small letter and FaultCode
and FaultString
property in FaultStructStringCode
start with capital letter. So when serializer can't exact faultCode
and faultString
, it throw exception because it can't find non optional member faultCode
and faultString
.
Finally with odoo, there is another problem. Odoo return detail error text as faultCode
with empty faultString
. When serializer try to parse faultCode
, it fails because faultCode
returned by odoo is a long text. So I conditionally set faultCode = -1
and set odoo returned faultCode to faultString
.
`
if (!AllowStringFaultCode) throw;
FaultStructStringCode faultStrCode;
faultStrCode = (FaultStructStringCode)ParseValue(structNode,typeof(FaultStructStringCode), parseStack, mappingAction);
int faultCode = -1;
if (!int.TryParse(faultStrCode.faultCode, out faultCode))
{
if (String.IsNullOrEmpty(faultStrCode.faultString))
{
fault.faultString = faultStrCode.faultCode;
}
else
{
fault.faultString = faultStrCode.faultString;
}
}
else
{
fault.faultString = faultStrCode.faultString;
}
fault.faultCode = faultCode;
`
Hello @chitswe, i have the same problem and I don't know enough about this part at the moment.
In my case, i'm trying some operation using this git repository to add some PoS Order : https://github.com/ieski/OdooXmlRpc
Actually, i would like to know where can I paste this code you wrote so I don't get this error anymore? Btw do you have any documentation on it ?
Gabin,
Hello @chitswe, i have the same problem and I don't know enough about this part at the moment.
In my case, i'm trying some operation using this git repository to add some PoS Order : https://github.com/ieski/OdooXmlRpc
Actually, i would like to know where can I paste this code you wrote so I don't get this error anymore? Btw do you have any documentation on it ?
Gabin,
UP, hope you can help me @ieski
Sorry for the late response, I wasn't looking at my notifications. My conclusion with all this was that Odoo was not consistent. I end up just retrying the request and most of the time it worked in the second request. I'm not working on that project anymore, so, I can't provide any steps right now. Hope it helps.
Same here!
Hello, this issue is still current and happens running a request on the latest version of Odoo (17). Is there any update on this?
@dinodipardo Please provide steps to reproduce it.
From what @chitswe said, there is two issue:
Hello,
I digged a bit deeper in the cause of the exception. This is what Odoo is returning as innerxml which is passed in structNode and causing the exception in this try block:
try { fault = (Fault)ParseValue(structNode, typeof(Fault), parseStack, mappingAction); }
If needed I can provide more details. Would be great to have this fixed ....
As you said yourself, Odoo is returning a string in the faultCode node, where XML-RPC is expecting a number (https://xmlrpc.com/spec.md). If someone has to fix this, it's on Odoo side. I notice that no such ticket has been open on their github.
You can also use the snippet proposed by @chitswe: https://github.com/LordVeovis/xmlrpc/issues/16#issuecomment-740363969
I'll log a ticket today for this and meanwhile I've implemented a temp fix for this myself. Once the ticket has been logged I'll update here with the ticket ref.
I set the flag to
AllowStringFaultCode
and it keeps throwing the errorException thrown: 'CookComputing.XmlRpc.XmlRpcTypeMismatchException' in Kveer.XmlRPC.dll: 'fault response contains string value where integer expected [fault response : struct mapped to type Fault : member faultCode mapped to type Int32]'
Originally posted by @epgeroy in https://github.com/LordVeovis/xmlrpc/issues/7#issuecomment-633566417