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

I set the flag to AllowStringFaultCode and it keeps throwing the error Exception 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]' #16

Open
LordVeovis opened this issue Jun 18, 2020 · 11 comments
Labels
bug Something isn't working

Comments

@LordVeovis
Copy link
Owner

I set the flag to AllowStringFaultCode and it keeps throwing the error Exception 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 #7 (comment)

@LordVeovis
Copy link
Owner Author

epregoy, please provide the steps to reproduce the error.

@chitswe
Copy link

chitswe commented Dec 8, 2020

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;

`

@LordVeovis LordVeovis self-assigned this Feb 27, 2021
@LordVeovis LordVeovis added the bug Something isn't working label Feb 27, 2021
@Gabinrn
Copy link

Gabinrn commented May 19, 2021

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,

@Gabinrn
Copy link

Gabinrn commented Jul 21, 2021

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

@epgeroy
Copy link

epgeroy commented Jul 26, 2021

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.

@ezarzone
Copy link

Same here!

@dinodipardo
Copy link

Hello, this issue is still current and happens running a request on the latest version of Odoo (17). Is there any update on this?

@LordVeovis LordVeovis removed their assignment May 9, 2024
@LordVeovis
Copy link
Owner Author

@dinodipardo Please provide steps to reproduce it.

From what @chitswe said, there is two issue:

  • one is a case issue and I can fix that,
  • the other one is odoo not respecting the xml-rpc spec. I will not make a specific odoo fix on this library

@dinodipardo
Copy link

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);
}



faultCode
warning -- AccessError

You are not allowed to access 'Website Visitor' (website.visitor) records.

This operation is allowed for the following groups:
- Administration/Settings
- Website/Editor and Designer

Contact your administrator to request access if necessary.


faultString


If needed I can provide more details. Would be great to have this fixed ....

@LordVeovis
Copy link
Owner Author

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: #16 (comment)

@dinodipardo
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants