Web Service в OTRSе настроен
При запуске скрипта получаю сообщение 401 Autorization Required at create-ticket2.pl line 78
Скрипт пробовал запускать от пользователей root, так и от otrs
В UserLogin и Password указываю логин и пароль из Framework -> Core::SOAP
Код: Выделить всё
#!/usr/bin/perl -w
use strict;
use warnings;
use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);
use SOAP::Lite;
use Data::Dumper;
my $URL = 'http://otrs.trololo.com/otrs/nph-genericinterface.pl/Webservice/soapme' ;
my $NameSpace = '/otrs/nph-genericinterface.pl/Webservice/soapme';
my $Operation = 'TicketCreate';
my $XMLData = '
<UserLogin>mysoap</UserLogin>
<Password>mysoap</Password>
<Ticket>
<Title>some title</Title>
<CustomerUser>service_account</CustomerUser>
<Queue>first_line</Queue>
<State>new</State>
<Priority>3 normal</Priority>
</Ticket>
<Article>
<Subject>some subject</Subject>
<Body>some body</Body>
<ContentType>text/plain; charset=utf8</ContentType>
</Article>
';
# create a SOAP::Lite data structure from the provided XML data structure
my $SOAPData = SOAP::Data
->type( 'xml' => $XMLData );
my $SOAPObject = SOAP::Lite
->uri($NameSpace)
->proxy($URL)
->$Operation($SOAPData);
# check for a fault in the soap code
if ( $SOAPObject->fault ) {
print $SOAPObject->faultcode, " ", $SOAPObject->faultstring, "\n";
}
# otherwise print the results
else {
# get the XML response part from the SOAP message
my $XMLResponse = $SOAPObject->context()->transport()->proxy()->http_response()->content();
# deserialize response (convert it into a perl structure)
my $Deserialized = eval {
SOAP::Deserializer->deserialize($XMLResponse);
};
# remove all the headers and other not needed parts of the SOAP message
my $Body = $Deserialized->body();
# just output relevant data and no the operation name key (like TicketCreateResponse)
for my $ResponseKey ( keys %{$Body} ) {
print Dumper( $Body->{$ResponseKey} );
}
}