SOAP Create Article on a Ticket - Request sample Please?

English! place to talk about OTRS development, programming and coding
Post Reply
sshenoy
OTRS newbie
Posts: 5
Joined: 25 Jul 2019, 10:39
OTRS Version?: OTRS 6
Real Name: sushmitha shenoy

SOAP Create Article on a Ticket - Request sample Please?

Post by sshenoy » 25 Jul 2019, 11:32

Hi Folks,
I m new to OTRS and SOAP. I m coding in Java and using SOAP. Everthing works fine in OTRS 4.
and now while upgrading From OTRS 4 to 6 api ; certian things like $TicketObject -> ArticleCreate doesnt work anymore.
According to the Api documentaion which is only in Perl (I dont know Perl) ,
$ArticleBackendObject->ArticleCreate .I tried to implement the same.

My soap request 1->
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:env="http://schemas.xmlsoap.org/soap/envelop/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<Dispatch
xmlns="/Core">
<Username xsi:type="xsd:string">user_name</Username>
<Password xsi:type="xsd:string">password</Password>
<Object xsi:type="xsd:string">ArticleBackendObject</Object>
<Method xsi:type="xsd:string">ArticleCreate</Method>
<Param1_Name xsi:type="xsd:string">TicketID</Param1_Name>
<Param1_Value xsi:type="xsd:long">5220222</Param1_Value>
<Param2_Name xsi:type="xsd:string">SenderType</Param2_Name>
<Param2_Value xsi:type="xsd:string">Customer</Param2_Value>
<Param3_Name xsi:type="xsd:string">IsVisibleForCustomer</Param3_Name>
<Param3_Value xsi:type="xsd:int">1</Param3_Value>
<Param4_Name xsi:type="xsd:string">From</Param4_Name>
<Param4_Value xsi:type="xsd:string">some-string</Param4_Value>
<Param5_Name xsi:type="xsd:string">To</Param5_Name>
<Param5_Value xsi:type="xsd:string">some-string</Param5_Value>
<Param6_Name xsi:type="xsd:string">Subject</Param6_Name>
<Param6_Value xsi:type="xsd:string">some-string</Param6_Value>
<Param7_Name xsi:type="xsd:string">Body</Param7_Name>
<Param7_Value xsi:type="xsd:string">some-string</Param7_Value>
<Param8_Name xsi:type="xsd:string">Charset</Param8_Name>
<Param8_Value xsi:type="xsd:string">ISO-8859-15</Param8_Value>
<Param9_Name xsi:type="xsd:string">MimeType</Param9_Name>
<Param9_Value xsi:type="xsd:string">text/plain</Param9_Value>
<Param10_Name xsi:type="xsd:string">HistoryType</Param10_Name>
<Param10_Value xsi:type="xsd:string">FollowUp</Param10_Value>
<Param11_Name xsi:type="xsd:string">HistoryComment</Param11_Name>
<Param11_Value xsi:type="xsd:string">some-string</Param11_Value>
<Param12_Name xsi:type="xsd:string">UserID</Param12_Name>
<Param12_Value xsi:type="xsd:long">1</Param12_Value>
<Param13_Name xsi:type="xsd:string">UnlockOnAway</Param13_Name>
<Param13_Value xsi:type="xsd:long">1</Param13_Value>
</Dispatch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

Soap Response ->
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<soap:Fault>
<faultcode>soap:Server</faultcode>
<faultstring>Virtual method in base class must not be called. at /opt/otrs/Kernel/System/Ticket/Article/Backend/Base.pm line 89.
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>


From the Perl documentaion in otrs 6 :

OTRS 6.0 API Reference Perl > Perl Modules > Kernel::System::Ticket::Article::Backend::Base

Do not instantiate this class, instead use the real article backend classes. Also, don't use the constructor directly, use the ObjectManager instead:

my $ArticleBackendObject = $Kernel::OM->Get('Kernel::System::Ticket::Article::Backend::MyBackend');


Create an article. Override this method in your class.

my $ArticleID = $ArticleBackendObject->ArticleCreate(
TicketID => 123,
SenderType => 'agent', # agent|system|customer
IsVisibleForCustomer => 1,
UserID => 123,

# Backend specific parameters:
# From => 'Some Agent <email@example.com>',
# To => 'Some Customer A <customer-a@example.com>',
# Subject => 'some short description',
# ...
);
Events: ArticleCreate


OTRS 6.0 API Reference Perl > Perl Modules > Kernel::System::Ticket::Article

NAME
Kernel::System::Ticket::Article - functions to manage ticket articles

DESCRIPTION
Since OTRS 6, article data is split in a neutral part for all articles (in the article database table), and back end specific data in custom tables (such as article_data_mime for the MIME based back ends).

This class only manages back end neutral article data, like listing articles with "ArticleList()" or manipulating article metadata like "ArticleFlagSet()".

For all operations involving back end specific article data (like ArticleCreate and ArticleGet), please call "BackendForArticle()" or "BackendForChannel()" to get to the correct article back end. See "ArticleList()" for an example of looping over all article data of a ticket.

See Kernel::System::Ticket::Article::Backend::Base for the definition of the basic interface of all article back ends.


Don't use the constructor directly, use the ObjectManager instead:

my $ArticleObject = $Kernel::OM->Get('Kernel::System::Ticket::Article');

BackendForChannel()
Returns the correct back end for a given communication channel, or the Invalid back end, so that you can always expect a back end object instance that can be used for chain-calling.

my $ArticleBackendObject = $ArticleObject->BackendForChannel( ChannelName => 'Email' );


Not sure how to implemet this in soap . I still tried to get ArticleBackendObject as follows:

Soap Request 2->
<?xml version="1.0" encoding="UTF-8" ?>
<SOAP-ENV:Envelope
xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:enc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:env="http://schemas.xmlsoap.org/soap/envelop/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" SOAP-ENV:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<SOAP-ENV:Header/>
<SOAP-ENV:Body>
<Dispatch
xmlns="/Core">
<Username xsi:type="xsd:string">user_name</Username>
<Password xsi:type="xsd:string">password</Password>
<Object xsi:type="xsd:string">ArticleObject</Object>
<Method xsi:type="xsd:string">BackendForChannel</Method>
<Param1_Name xsi:type="xsd:string">ChannelName</Param1_Name>
<Param1_Value xsi:type="xsd:string">Email</Param1_Value>
</Dispatch>
</SOAP-ENV:Body>
</SOAP-ENV:Envelope>

SOAP Response ->

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope
xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:namesp3="http://namespaces.soaplite.com/perl"
xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soap:Body>
<DispatchResponse
xmlns="/Core">
<Kernel__System__Ticket__Article__Backend__Email xsi:type="namesp3:Kernel__System__Ticket__Article__Backend__Email">
<ArticleStorageModule xsi:type="xsd:string">Kernel::System::Ticket::Article::Backend::MIMEBase::ArticleStorageFS</ArticleStorageModule>
<Debug xsi:type="xsd:int">0</Debug>
<EventHandlerInit>
<Config xsi:type="xsd:string">Ticket::EventModulePost</Config>
</EventHandlerInit>
</Kernel__System__Ticket__Article__Backend__Email>
</DispatchResponse>
</soap:Body>
</soap:Envelope>

I am not sure how or which part of the above reponse to be used as the object string in my "My soap request 1" above to create an article.

appreciate any help or code samples.Thanks in Advance.

jojo
Moderator
Posts: 14569
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: SOAP Create Article on a Ticket - Request sample Please?

Post by jojo » 25 Jul 2019, 13:20

Please use the GenericInterface SOAP or REST API and not the rpc.pl
"Production": OTRS™ 6, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

sshenoy
OTRS newbie
Posts: 5
Joined: 25 Jul 2019, 10:39
OTRS Version?: OTRS 6
Real Name: sushmitha shenoy

Re: SOAP Create Article on a Ticket - Request sample Please?

Post by sshenoy » 27 Jul 2019, 15:33

jojo wrote:
25 Jul 2019, 13:20
Please use the GenericInterface SOAP or REST API and not the rpc.pl
Could you please give me some examples preferably in Java. Thank you.

jojo
Moderator
Posts: 14569
Joined: 26 Jan 2007, 14:50
OTRS Version?: Git Master
Contact:

Re: SOAP Create Article on a Ticket - Request sample Please?

Post by jojo » 28 Jul 2019, 10:45

you'll find the API description for TicketGet here: https://doc.otrs.com/doc/api/otrs/stabl ... et.pm.html

The WSDL files can be found here: https://github.com/OTRS/otrs/blob/rel-6 ... rSOAP.wsdl
"Production": OTRS™ 6, STORM powered by OTRS
"Testing": ((OTRS Community Edition)) git Master

Never change Defaults.pm! :: Blog
Professional Services:: http://www.otrs.com :: enjoy@otrs.com :: Share your ideas

sshenoy
OTRS newbie
Posts: 5
Joined: 25 Jul 2019, 10:39
OTRS Version?: OTRS 6
Real Name: sushmitha shenoy

Re: SOAP Create Article on a Ticket - Request sample Please?

Post by sshenoy » 30 Jul 2019, 07:48

Thanks a lot :)

Post Reply