OTRS SOAP charset problem [SOLVED]

Moderator: crythias

Locked
sfeher
Znuny newbie
Posts: 3
Joined: 20 Jul 2010, 11:08
Znuny Version: 2.4.7

OTRS SOAP charset problem [SOLVED]

Post by sfeher »

Hi,

It seems that OTRS SOAP interface only accepts text in utf8 charset.
My database is in iso-8859-2 and it is set in Config.pm as default char set.
I don't know how can I set this in soap.

Code: Select all

Fatal error: Uncaught SoapFault exception: [Client] SOAP-ERROR: Encoding: string '\xe9...' is not a valid utf-8 string in /var/www/ff/api.php:64 Stack trace: #0 /var/www/ff/api.php(64): SoapClient->__soapCall('Dispatch', Array) #1 /var/www/ff/ff.php(40): create_ticket('T?j?koztat?s le...', NULL, NULL, NULL, '?<html meta htt...') #2 /var/www/ff/ff.php(74): tetel_feld('78', 'F1', NULL, NULL, NULL) #3 /var/www/ff/ff.php(214): send_felszolitas(Array) #4 {main} thrown in /var/www/ff/api.php on line 64
Thanks in advance.

Regards., Sandor
Last edited by sfeher on 22 Jul 2010, 00:28, edited 1 time in total.
jojo
Znuny guru
Posts: 15020
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: OTRS SOAP charset problem

Post by jojo »

As I remember this is an issue in the used PHP Class (in your script)
"Production": OTRS™ 8, OTRS™ 7, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) and git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com
sfeher
Znuny newbie
Posts: 3
Joined: 20 Jul 2010, 11:08
Znuny Version: 2.4.7

Re: OTRS SOAP charset problem

Post by sfeher »

Thanks. I spent two days for digging google :(. I throwed the whole php mess away and completely rewrote the code in perl.
I still have troubles :(.
Now I can launch ArticleSend and receive the mail (create the ticket succesfully) but there is a charset conversion problem with the ticket's subject. Whatever I set it always handled as in utf8 charset.
The body is perfect.
This makes me totally crazy. I suspect it's a kind of otrs problem because I have some tickets I received external sources and if they have written in utf8 then the from field and the title field are wrong as well.

So here is my concept and code.

There is a php script calls a perl script a passes it some params. Perl script handles the request and opens a ticket in OTRS.

The relevant parts:

OTRS 2.4.7
Oracle 10g with ISO-8859-2 charset

Config.pm
$Self->{'DefaultCharset'} = 'iso-8859-2';

Apache log: http://pastebin.com/SifxwyV8

I realy appreciate any help. Thank you in advance.

Code: Select all

#!/usr/bin/perl -w

use Encode;
use MIME::Base64;
use SOAP::Lite('autodispatch', proxy => 'http://192.168.1.10/otrs/rpc.pl', 
encoding => 'iso-8859-2', trace =>'all');
use CGI qw(:standard);
use CGI::Carp qw(warningsToBrowser fatalsToBrowser);

			   
my $User = 'api';
my $Pw   = 'api';


sub create_ticket {
local ($subject,$email1,$email2,$otrs_ticket_nr,$body) = (@_);  
 
 
my $RPC = Core->new() || die;
my $from = "support\@bluesystem.hu";
my $to = "sfeher\@bluesystem.hu";


my $TicketNumber = $RPC->Dispatch( $User, $Pw, 'TicketObject', 'TicketCreateNumber' );

my %TicketData = (
    Title        => $subject,
    Queue        => 'Junk',
    Lock         => 'unlock',
    Priority     => '3 normal',
    State        => 'new',
	CustomerUser => $email1, 
    OwnerID      => 21,
    UserID       => 21,
	Charset     => 'ISO-8859-2',
);

my $TicketID = $RPC->Dispatch( $User, $Pw, 'TicketObject', 'TicketCreate', %TicketData => 1 ) || die "$!";
my %ArticleData = (
				    TicketID         => $TicketID,
			        ArticleType      => "email-external",
			        SenderType       => "agent",
			        From             => $from,
			        To               => $to,
					Subject          => "[Ticket#:".$TicketNumber."] ".$subject,
					Charset          => 'ISO-8859-2',
					MimeType         => "text/html",
			        Body             => $body,
			        HistoryType      => "EmailCustomer",
			        HistoryComment   => "generated by OTRSInterface-Class",
			        UserID           => 21,
			        NoAgentNotify    => 0,
			        Loop             => 0);

my $ArticleID = $RPC->Dispatch( $User, $Pw, 'TicketObject', 'ArticleCreate', %ArticleData => 1 ) || die "$!";

};
print header;

my %form;
my $subject;
my $email1;
my $email2;
my $otrs_ticket_nr;
my $body;

foreach my $p (param()) {
        $form{$p} = param($p);
        #print "$p = $form{$p}<br>\n";
		if($p eq 'body') {
		  $body = $form{$p};
		};
		if($p eq 'subject') {
		  $subject=$form{$p};
		};
		if($p eq 'email1') {
		  $email1=$form{$p};
		};
		if($p eq 'email2') {
		   $email2=$form{$p};
		 };
		 if($p eq 'otrs_ticket_nr') {
		   $otrs_ticket_nr=$form{$p};
		 };
}
&create_ticket($subject,$email1,$email2,$otrs_ticket_nr,$body); 
print end_html;


sfeher
Znuny newbie
Posts: 3
Joined: 20 Jul 2010, 11:08
Znuny Version: 2.4.7

Re: OTRS SOAP charset problem

Post by sfeher »

Just for the archive.
If I remove the [Ticket#] tag from the beginning of the subject then there is no charset problem.
There was a long way to get here but it work fine now.
Locked