WebService

Post Reply
alevital
Znuny newbie
Posts: 2
Joined: 03 May 2012, 23:43
Znuny Version: OTRS 3.1

WebService

Post by alevital »

Estou tentando utilizar a GenericInterface da versão 3.1.

Fiz um código em Perl, conforme o exemplo em http://doc.otrs.org/3.1/en/html/generic ... ctors.html, o código segue abaixo, porém recebo o erro Server Got no OperationType!

Alguém saberia me dizer se falta alguma configuração no WebService ou se falta passar algum parâmetro no código?

Grato,
Alessandro

#!/usr/bin/perl -w
# --
# otrs.SOAPRequest.pl - sample to send a SOAP request to OTRS Generic Interface Ticket Connector
# Copyright (C) 2001-2012 xxx, http://otrs.org/
# --
# $Id: genericinterface-connectors.xml,v 1.7 2012/03/27 05:49:33 cr Exp $
# --
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU AFFERO General Public License as published by
# the Free Software Foundation; either version 3 of the License, or
# any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program; if not, write to the Free Software
# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
# or see http://www.gnu.org/licenses/agpl.txt.
# --

use strict;
use warnings;

# use ../ as lib location
use File::Basename;
use FindBin qw($RealBin);
use lib dirname($RealBin);

use SOAP::Lite;
use Data::Dumper;

# ---
# Variables to be defined.

# this is the URL for the web service
# the format is
# <HTTP_TYPE>:://<OTRS_FQDN>/nph-genericinterface.pl/Webservice/<WEB_SERVICE_NAME>
# or
# <HTTP_TYPE>:://<OTRS_FQDN>/nph-genericinterface.pl/WebserviceID/<WEB_SERVICE_ID>
my $URL = 'http://localhost/otrs/nph-genericinterf ... tConnector';

# this name space should match the specified name space in the SOAP transport for the web service.
my $NameSpace = 'http://www.otrs.org/TicketConnector/';

# this is operation to execute, it could be TicketCreate, TicketUpdate, TicketGet, TicketSearch
# or SessionCreate. and they must to be defined in the web service.
my $Operation = 'TicketCreate';

# this variable is used to store all the parameters to be included on a request in XML format, each
# operation has a determined set of mandatory and non mandatory parameters to work correctly, please
# check OTRS Admin Manual in order to get the complete list.
my $XMLData = '
<UserLogin>some user login</UserLogin>
<Password>some password</Password>
<Ticket>
<Title>some title</Title>
<CustomerUser>some customer user login</CustomerUser>
<Queue>some queue</Queue>
<State>some state</State>
<Priority>some priority</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} );
}
}
alevital
Znuny newbie
Posts: 2
Joined: 03 May 2012, 23:43
Znuny Version: OTRS 3.1

Re: WebService

Post by alevital »

Srs.,

Ainda não consegui resolver este problema.

Mas estive pensando, se seria possível instalar o Core::SOAP nesta nova versão, a 3.1 ?

Eu utilizava a versão antiga da interface sem problemas, via rpc.pl, e se fosse possível utilizar nesta versão, resolveria o meu problema.

Grato,
Alessandro
richieri
Znuny newbie
Posts: 39
Joined: 18 Apr 2011, 19:29
Znuny Version: 3100000
Real Name: Ronaldo Richieri
Company: Complemento
Location: Brasil
Contact:

Re: WebService

Post by richieri »

Puxa, eu acho que o Core:Soap foi descontinuado mesmo...
Ronaldo Richieri
Analista de Sistemas, desenvolvedor de módulos OTRS e CEO na empresa Complemento
http://www.complemento.net.br
http://www.richieri.com
Post Reply