1 package OpenILS::Application::Acq::EDI::Translator;
10 my $proto = 'http://';
11 my $host = $proto . 'localhost';
17 my ($class, %args) = @_;
18 my $self = bless(\%args, $class);
30 my $target = $self->{host} || $host;
31 $target =~ /^\S+:\/\// or $target = ($self->{proto} || $proto) . $target;
32 $target =~ /:\d+$/ or $target .= ':' . ($self->{port} || $port);
33 $target .= ($self->{path} || $path);
34 $self->{verbose} and print "Cleanup: $self->{host} ==> $target\n";
35 $self->{host} = $target;
41 return $self->{client} ||= RPC::XML::Client->new($self->{host}); # TODO: auth
47 my $filename = @_ ? shift : ('/tmp/' . __PACKAGE__ . '_unknown.tmp');
48 unless (open (TMP_EDI, ">$filename")) {
49 warn "Cannot write $filename: $!";
52 print TMP_EDI $text, "\n";
60 $self->debug_file($text, '/tmp/perl_json2edi.tmp');
61 my $client = $self->client();
62 $self->{verbose} and print "Trying json2edi on host: $self->{host}\n";
63 $client->request->header('Content-Type' => 'text/xml;charset=utf-8');
64 my $resp = $client->send_request('json2edi', $text);
65 $self->{verbose} and print Dumper($resp);
72 $self->debug_file($text, '/tmp/perl_edi2json.tmp');
73 my $client = $self->client();
74 $self->{verbose} and print "Trying edi2json on host: $self->{host}\n";
75 $client->request->header('Content-Type' => 'text/xml;charset=utf-8');
76 my $resp = $client->send_request('edi2json', $text);
77 $self->{verbose} and print Dumper($resp);