Mapping field in OTRS Web Service Provider

Moderator: crythias

Post Reply
trikhoi
Znuny newbie
Posts: 6
Joined: 17 Oct 2013, 10:23
Znuny Version: 3.3.1
Real Name: Khoi Nguyen

Mapping field in OTRS Web Service Provider

Post by trikhoi »

Hi all,

I have a OTRS system has been configed as SOAP Provider, and my creating phone ticket has a Dynamic Field named "MyDF", a text field.
Now I use otrs.SOAPRequest.pl to test if Provider can create a ticket with Dynamic Field. So I rewrite xml string in this pl file as below.

When I run this program, everything is OK, my OTRS create a ticket, but one thing: No Dynamic field is create.

Please help me!

Thank in davance.


otrs.SOAPRequest.pl code:

Code: Select all

#!/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: otrs.SOAPRequest.pl,v 1.2 2012/09/07 13:51:36 mb 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., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 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-genericinterface.pl/Webservice/KhoiWebProvider';

# this name space should match the specified name space in the SOAP transport for the web service
my $NameSpace = 'KhoiNamespace';

# 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 = 'KhoiCreateTicket';

# 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>khoi</UserLogin>
<Password>iloveyou</Password>
<Ticket>
    <CustomerUser>khoi@otrs.com</CustomerUser>
    <Title>Task is created from Khoi to Webservice</Title>
    <Queue>Raw</Queue>
    <State>Open</State>
    <Priority>3 normal</Priority>
    <TaskID>1221312</TaskID>
    <ExternalTaskID>tam nhan</ExternalTaskID>
    <Type>Info</Type>
    <CustomerID>2222</CustomerID>
   [b][color=#FF0000] <DynamicField>
	<Name>MyDF</Name>
	<Value>abc</Value>
    </DynamicField>[/color][/b]
</Ticket>
<Article>
    <Subject>thu</Subject>
    <Body>thu</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} );
    }
}
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Mapping field in OTRS Web Service Provider

Post by jojo »

did you check the history of the ticket? Did you configure your Ticket Zoom to show this field?
"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
skullz
Znuny superhero
Posts: 624
Joined: 24 Feb 2012, 03:58
Znuny Version: LTS and Features
Real Name: Mo Azfar
Location: Kuala Lumpur, MY
Contact:

Re: Mapping field in OTRS Web Service Provider

Post by skullz »

Hi,
did you already enabled DF "MyDF" in AgentTicketZoom??
Sysconfig>Ticket -> Frontend::Agent::Ticket::ViewZoom ===> Ticket::Frontend::AgentTicketZoom###DynamicField
trikhoi
Znuny newbie
Posts: 6
Joined: 17 Oct 2013, 10:23
Znuny Version: 3.3.1
Real Name: Khoi Nguyen

Re: Mapping field in OTRS Web Service Provider

Post by trikhoi »

Yes, I already do that, when i create phone ticket direct from OTRS, it show MyDF, but when I create from otrs.SOAPRequest.pl, it does not.
trikhoi
Znuny newbie
Posts: 6
Joined: 17 Oct 2013, 10:23
Znuny Version: 3.3.1
Real Name: Khoi Nguyen

Re: Mapping field in OTRS Web Service Provider

Post by trikhoi »

jojo wrote:did you check the history of the ticket? Did you configure your Ticket Zoom to show this field?
WhereI can check the history of ticket?

Thank you
trikhoi
Znuny newbie
Posts: 6
Joined: 17 Oct 2013, 10:23
Znuny Version: 3.3.1
Real Name: Khoi Nguyen

Re: Mapping field in OTRS Web Service Provider

Post by trikhoi »

Hi all,

Is the way I set Dynamic Field in xml string right or wrong?
<DynamicField>
<Name>MyDF</Name>
<Value>abc</Value>
</DynamicField>
trikhoi
Znuny newbie
Posts: 6
Joined: 17 Oct 2013, 10:23
Znuny Version: 3.3.1
Real Name: Khoi Nguyen

Re: Mapping field in OTRS Web Service Provider

Post by trikhoi »

Help me please!
jojo
Znuny guru
Posts: 15019
Joined: 26 Jan 2007, 14:50
Znuny Version: Git Master
Contact:

Re: Mapping field in OTRS Web Service Provider

Post by jojo »

read the wsdl file. You seem to expect enterprise grade support in a valuntary forum...
"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
Miskra
Znuny newbie
Posts: 3
Joined: 03 Sep 2013, 16:32
Znuny Version: 3.2.7
Real Name: Marcin Iskra

Re: Mapping field in OTRS Web Service Provider

Post by Miskra »

trikhoi wrote:Hi all,

Is the way I set Dynamic Field in xml string right or wrong?
<DynamicField>
<Name>MyDF</Name>
<Value>abc</Value>
</DynamicField>
Hi,

I found a problem in your XML data. You have placed the dynamic field data inside the <Ticket> tags. Dynamic fields tag should be after the Ticket and Article tags. Please move your Dynamic Field definition like this:

<Ticket>
</Ticket>
<Article>
</Article>
<DynamicField>
</DynamicField>

Here is the corrected XML data:

Code: Select all

my $XMLData = '
<UserLogin>khoi</UserLogin>
<Password>iloveyou</Password>
<Ticket>
   <CustomerUser>khoi@otrs.com</CustomerUser>
   <Title>Task is created from Khoi to Webservice</Title>
   <Queue>Raw</Queue>
   <State>Open</State>
   <Priority>3 normal</Priority>
   <TaskID>1221312</TaskID>
   <ExternalTaskID>tam nhan</ExternalTaskID>
   <Type>Info</Type>
   <CustomerID>2222</CustomerID>
</Ticket>
<Article>
   <Subject>thu</Subject>
   <Body>thu</Body>
   <ContentType>text/plain; charset=utf8</ContentType>
</Article>
<DynamicField>
   <Name>MyDF</Name>
   <Value>abc</Value>
</DynamicField>
trikhoi
Znuny newbie
Posts: 6
Joined: 17 Oct 2013, 10:23
Znuny Version: 3.3.1
Real Name: Khoi Nguyen

Re: Mapping field in OTRS Web Service Provider

Post by trikhoi »

Thank you very much.
It work.
Post Reply