Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

SOAP::LITE and umlauts = Binary??

by DreamT (Pilgrim)
on Sep 02, 2009 at 12:18 UTC ( #792894=perlquestion: print w/replies, xml ) Need Help??
DreamT has asked for the wisdom of the Perl Monks concerning the following question:

I've created a webservice solution for placing orders in a system. It works well, except for that i can't get umlauts (å,ä,ö) to work correctly. SOAP::Lite creates the field
<City xsi:type="xsd:base64Binary">SnVra2FzasOkcnZp</City>
from the code
... $City = "Säffle"; ... push @AdressValues, SOAP::Data->name('City' => "$City"); ...

(Actually, the $City value is first fetched from a text file, but I get the same result when simplifying it as above)
So, of course this is an encoding problem. But, how do I solve it? The original encoding of the $City-string is probably latin1.

Replies are listed 'Best First'.
Re: SOAP::LITE and umlauts = Binary??
by Anonymous Monk on Sep 02, 2009 at 12:39 UTC
    perl |xml_pp
    #!/usr/bin/perl -- use strict; use warnings; use SOAP::Lite; use SOAP::Lite 0.65 +trace => 'debug'; use Encode; print SOAP::Lite->new->serializer->envelope( method => 'DreamT', ## xsd:base64Binary # SOAP::Data->new(City => q!Säffle!), # SOAP::Data->name( "City" => encode('UTF-8',q!Säffle!)), ## not well-formed (invalid token) # SOAP::Data->type("xsd:string")->name( "City" => q!Säffle!), ## perfect SOAP::Data->type("xsd:string")->name( "City" => encode('UTF-8', +q!Säffle!)), ); __END__ <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope soap:encodingStyle=" +oding/" xmlns:soap="" xmlns: +soapenc="" xmlns:xsd="http:/ +/" xmlns:xsi=" +ma-instance"> <soap:Body> <DreamT> <City xsi:type="xsd:string">Säffle</City> </DreamT> </soap:Body> </soap:Envelope>
      Thank you! That ALMOST made my day..:-)
      I'm outputting the debug data to a textfile. When I use the utf-8 encoding i Get
      <City xsi:type="xsd:string">Säffle</City>

      and when I disable it I get this
      <City xsi:type="xsd:string">Säffle</City>

      Is this because of the logfile itself, or will it look like this when I post it into the webservice? The Logfile itself is created with Perl and gets populated with CGI::Carp.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://792894]
Approved by almut
Front-paged by bart
Jar. Jar!...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (5)
As of 2018-07-15 23:37 GMT
Find Nodes?
    Voting Booth?
    It has been suggested to rename Perl 6 in order to boost its marketing potential. Which name would you prefer?

    Results (328 votes). Check out past polls.