[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: http_url_post_xml and utf-8 encoding
Hi Magne,
I don't see anything wrong with your code. Though, I notice that you
don't specify a content-type that identifies the CCSID of your data.
This is something of a shot-in-the-dark, but... you might try it. Take
a look at the 9th parameter to http_url_post_xml():
rc = http_url_post_xml(
%trim(WsTffUrl)
: %addr(SOAP) + 2
: %len(SOAP)
: *NULL
: %paddr(Incoming)
: *NULL
: HTTP_TIMEOUT
: HTTP_USERAGENT
: 'text/xml; encoding=utf-8' );
If that doesn't help, perhaps you need to explicitly tell HTTPAPI which
CCSID your data is in? Right now, you're telling HTTPAPI to translate
from CCSID 0 to CCSID 1208. 0=The job's default CCSID. 1208=UTF-8.
Perhaps you need to tell it the exact CCSID of your data instead of
relying on the Job's CCSID?
http_setCCSIDs(1208: xxx);
If that still doesn't work, I think you need to narrow things down by
looking at the exact hex values that the HTTP server is receiving. Are
they the correct values for UTF-8? IF not, then the problem must be in
HTTPAPI somewhere. If they ARE, then the problem must be in the web
service.
Or perhaps you need to put them in a CDATA wrapper? or escape the XML?
That seems unlikely since they're text ordinary characters, not used by
the XML format... but might be worth trying if all else fails.
magne@xxxxxxxxx wrote:
> Hi Scott,
>
> I am using the httpapi and it works greate!
>
> But I am having trouble with http_url_post_xml and norwegian
> characters (æøå���).
>
> Can you please guide me in the right direction? Do I have to do some
> encoding on the Soap variable?
>
> Her is some of the code:
>
> (the characters æøå��� will sometimes appear in variable CNAVN and
> I only gets a parse error message from the server when these
> characters appears)
>
> SOAP =
> '<?xml version="1.0" encoding="UTF-8"?>'
> +'<soap:Envelope xmlns:soap='
> +'"[1]http://schemas.xmlsoap.org/soap/envelope/" '
> +'xmlns:brukersesjon='
> +'"' + %trim(WsBrukerNs) + '" '
> +'xmlns:transaksjon='
> +'"' + %trim(WsTransNs) + '" '
> +'xmlns:wa='
> +'"' + %trim(WsTffAutoNs) + '">'
> +'<soap:Header>'
> +'<brukersesjon:Brukersesjon>'
> +'<sesjonsid>' + %trim(session) + '</sesjonsid>'
> +'</brukersesjon:Brukersesjon>'
> +'</soap:Header>'
> +'<soap:Body>'
> +'<wa:hentOppdater xmlns:wa=' +'"' +
> %trim(WsTffAutoNs) + '">'
> +'<transkode>' + %trim(CTransK) + '</transkode>'
> +'<transkilde>0</transkilde>'
> +'<kjennemerke>' + %trim(CBILNR) + '</kjennemerke>'
> +'<avtaledato>' + %trim(Wadato) + '</avtaledato>'
> +'<erkleringsnr>' + %trim(Cenr) + '</erkleringsnr>'
> +'<navn>' + %trim(Cnavn) + '</navn>'
> +'<fodselOrgnr>' + %trim(Cpnr) + '</fodselOrgnr>'
> +'<regaar>' + %trim(Craar) + '</regaar>'
> +'<merkekode>' + %trim(Cfabr) + '</merkekode>'
> +'<merkenavn>' + %trim(Cmodel) + '</merkenavn>'
> +'<postnr>' + %trim(Cpost) + '</postnr>'
> +'<adresse>' + %trim(Cadr) + '</adresse>'
> +'<nasjonalitet>NOR</nasjonalitet>'
> +'<understellsnr>' + %trim(Custnr) + '</understellsnr>'
> +'<kjoeretoeyGruppe>' + %trim(Cktgrp) + '</kjoeretoeyGruppe>'
> +'<modell/>'
> +'<type/>'
> +'</wa:hentOppdater>'
> +'</soap:Body>'
> +'</soap:Envelope>';
>
> HTTP_setCCSIDs(1208: 0); // CCSID 1208 = UTF-8
>
> // Send Soap xml til InfoTorg Person.
> rc = http_url_post_xml(
> %trim(WsTffUrl)
> : %addr(SOAP) + 2
> : %len(SOAP)
> : *NULL
> : %paddr(Incoming)
> : *NULL
> : HTTP_TIMEOUT
>
>
> Best regards,
>
> Magne
>
> References
>
> 1. http://schemas.xmlsoap.org/soap/envelope/
>
>
>
> ------------------------------------------------------------------------
>
> -----------------------------------------------------------------------
> This is the FTPAPI mailing list. To unsubscribe, please go to:
> http://www.scottklement.com/mailman/listinfo/ftpapi
> -----------------------------------------------------------------------
-----------------------------------------------------------------------
This is the FTPAPI mailing list. To unsubscribe, please go to:
http://www.scottklement.com/mailman/listinfo/ftpapi
-----------------------------------------------------------------------