Watch, Follow, &
Connect with Us

For forums, blogs and more please visit our
Developer Tools Community.

Welcome, Guest
Guest Settings

Thread: Problem with encoding in string returned by THTTPRIO

Permlink Replies: 0
Milan Bačík

Posts: 10
Registered: 2/4/11
Problem with encoding in string returned by THTTPRIO
Click to report abuse...   Click to reply to this thread Reply
  Posted: Mar 20, 2015 7:24 AM
I have WebService client using HTTPRIO. It works, but returned XML has wrong encoding. Each non ascii character ocupies 4 bytes. It looks like its two times encoded to UTF8. When I do following workaround, I get correct result:
char* data = ResultString.t_str();
ResultString = UTF8Decode(data);

Service was generated from wizard(some time ago by another employe).
_di_SomeWebservice GetSomeWebservice(bool useWSDL=false, AnsiString addr="", THTTPRIO* HTTPRIO=0)
  static const char* defWSDL= "";
  static const char* defURL = "";
  static const char* defSvc = "SomeWebserviceservice";
  static const char* defPrt = "SomeWebservicePort";
  if (addr=="")
	 addr = useWSDL ? defWSDL : defURL;
  if (useWSDL) {
	 rio->WSDLLocation = addr;
	 rio->Service = defSvc;
	 rio->Port = defPrt;
  } else {
	 rio->URL = addr;
  _di_SomeWebservice service;
  if (!service && !HTTPRIO)
    delete rio;
  return service;
// ************************************************************************ //
// This routine registers the interfaces and types used by invoke the SOAP
// Service.
// ************************************************************************ //
static void RegTypes()
  /* SomeWebservice */
  InvRegistry()->RegisterInterface(__interfaceTypeinfo(SomeWebservice), L"urn:someadressWebservice", L"utf-8");
  InvRegistry()->RegisterDefaultSOAPAction(__interfaceTypeinfo(SomeWebservice), L"urn:someadressWebservice#%operationName%");
  InvRegistry()->RegisterExternalParamName(__interfaceTypeinfo(SomeWebservice), "EchoString", "return_", L"return");

And used it like this:
		rio = new THTTPRIO(this);
		rio->OnBeforeExecute = HttpRionBeforeExecute;
		rio->OnAfterExecute = HttpRionAfterExecute;
		_di_SomeWebservice service = SomeWebservice(false, RTVURL, rio);
		  service->GetFaktura(Dealer, RTVPassw, EmptyStr, txtKomise_nr->Field->GetAsString(), txtVyrobekvoz_ozn->Field->GetAsString(), ErrorResult, EDLIVGResult);
		char* data = EDLIVGResult.t_str();
		EDLIVGResult = UTF8Decode(data);

Edited by: Milan Bačík on Mar 23, 2015 2:04 AM
Helpful Answer (5 pts)
Correct Answer (10 pts)

Server Response from: ETNAJIVE02