I am using the activity Http Request from the package Uipath.Web.Activities.HttpClient. I create the following XML Body, which contains german characters like umlaut äöü:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns="...">
<soapenv:Header/>
<soapenv:Body>
<ns:aendernKarte>
<credentials>
<clientApplikation>...</clientApplikation>
<kordobaApplikation>...</kordobaApplikation>
...
</credentials>
<karte>
<bemerkung>ö</bemerkung>
</karte>
</ns:aendernKarte>
</soapenv:Body>
</soapenv:Envelope>
Those are the properties for the activity:
The variable v_body (string variable) contains the XML Body that I showed before. There are no options configured in Attachments, Cookies, Headers, Parameters, and Url Segments, which means those fields are empty.
Once I execute the activity, I got the following error (500):
{
"message": "<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><soap:Fault><faultcode>soap:Server</faultcode><faultstring>\nInhalt= \"ö\"\nCIFeld: KV2ENAME1\nFollowing Field contains invalid sign: Name </faultstring><detail><ns1:... xmlns:ns1=\"...\"><errorCode xmlns:ns2=\".../\">UNKNOWN MESSAGE</errorCode><details xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:ns2=\"..../\" xsi:nil=\"true\"/><fehlerliste
...
}
My understanding is that the activity encodes the body incorrectly and changes the german characters with other symbols (for example ö --> ö). I do not know how this activity was built inside and I do not know how to tell to encode the body with UTF-8. I tried the following, but those are not working:
- Add "
<?xml version="1.0" encoding="UTF-8"?>
" in the XML Body at the beginning - Add in the property BodyFormat: application/xml;encoding=UTF8
- Add in the property Options/Headers: Content-Type = application/xml;encoding=UTF8
I really appreciate it if someone could give me a hand with this issue because I deal with it for a long time and I could not find a way with this activity.
CodePudding user response:
My guess would be that actual encoding of the file is iso-8859-1 or windows-1252, but the parser is trying to decode it as utf-8.
The key thing is that the parser can't read the file unless it knows how it is encoded.
Declaring the encoding as utf-8 when it is actually something different can only make matters worse.
To fix this you either need to discover what encoding is being used and add an XML declaration to declare the encoding correctly, or you need to modify the XML content so that it is in UTF-8.
To discover the actual encoding, you need to make a hex dump of the file and find out what binary values are being used to encode non-ASCII characters such as ö
.
CodePudding user response:
I finally came across the solution. I want to post here to help someone with the same issue.
You should add in the "BodyFormat" property the following value: application/soa xml;charset=utf-8. It is working like a charm.
Tks anyway @Michael Kay for the analysis and suggestion.