#!/usr/bin/perl -w
#
# Testfunktion, um unser Soap-Backend zu testen
#    (simuliert einen SOAP-Call von Telefonica)
#
use strict;
use LWP::Debug;
use Data::Dumper;
use Encode;

use Getopt::Std;
use vars qw/ $opt_d /;
$opt_d=0;
getopts('d') || die "$0: [-d]\n";

LWP::Debug::level('+') if $opt_d;

my $wsdl_file = "./local-SelfTest.wsdl";
use XML::Compile::WSDL11;
use XML::Compile::SOAP11;
use XML::Compile::Transport::SOAPHTTP;
my $wsdl = XML::Compile::WSDL11->new($wsdl_file) || die "1";

my $call = $wsdl->compileClient('OpSelfTest');

my %request =
    ( parameters => {userName => 'user',
                     password => 'pass'},
      WEBINT_TICKETID     => 'C0815-4711-xxx',
      WEBINT_CUSTTICKETID => '200711250087',
    );

print Dumper( \%request );

my ( $answer, $trace ) = $call->(%request);

$|=1;
print Dumper(\$answer);
print Dumper(\$trace) if $opt_d;

if ( defined $answer->{Fault} )
{
    print "FAULIG:\n  $answer->{Fault}->{faultcode}\n  $answer->{Fault}->{faultstring}\n";
}

if ( defined $answer->{parameters} )
{
    print "\nIN_OUT: $answer->{parameters}->{IN_OUT}\n";
}
