OTRS Webservice as Requestor Test

English! place to talk about development, programming and coding
Post Reply
andys
Znuny newbie
Posts: 7
Joined: 18 Aug 2014, 22:48
Znuny Version: 3.2.6

OTRS Webservice as Requestor Test

Post by andys »

I'm new to OTRS (3.2) and also new to PERL but I have been given the task of setting up OTRS so that it will make a call to our remote webservice so a record can be created on our end when a ticket is set as "Closed". I set up various dynamic fields so the customer service rep can fill in additional data that will be passed into the webservice call along with ticket details. I couldn't get the webservice call to trigger when the ticket was "Closed" but I did get it to trigger when the "priority" was changed so I'm just using that now to test the webservice. I'm just using the Test.pm and TestSimple.pm files that were included with OTRS.

When I look at the Debugger for the Webserice, I can see that the calls were being made:

$VAR1 = {
'TicketID' => '6'
};

My webservice currently just has one method "create" which just returns true for testing.

however I get the following from the Test.pm

"Got no TicketNumber (2014-09-02 09:20:42, error)"

and the following from the TestSimple.pm

"Error in SOAP call: 404 Not Found at /TARGET/SHARE/var/otrs/Kernel/GenericInterface/Transport/HTTP/SOAP.pm line 578 (2014-09-02 09:20:43, error)

I've spent countless hours on Google but couldn't find anything on this. All I could find is code for the Test.pm and TestSimple.pm but nothing really helpful to help me create a custom invoker for my needs and configure the webservice in OTRS to get it to work.

Does anyone have any sample invokers that I can look at to see how to set it up?

Basically I need to pass the ticket information along with my custom dynamic fields to my webservice. From there I can create the record on my end and do whatever processing. I'm not sure how to setup the Invoker to pass the necessary ticket fields and dynamic fields and how to make it call a specific method in my remote webservice.

I guess getting the Test.pm and TestSimple.pm to work is the first step then I can modify those for my needs. I have not used PERL at all so any help is greatly appreciated.
milhi
Znuny newbie
Posts: 6
Joined: 15 Aug 2014, 14:08
Znuny Version: OTRS 3.3
Company: OnTec Software Solutions AG

Re: OTRS Webservice as Requestor Test

Post by milhi »

Hi man, I'm also struggling with similar set of requirements. I've also never programmed in PERL, but I can tell you at least that the "Got no TicketNumber" in the Test.pm is right from the PrepareRequest method, there you can see this block of code:

Code: Select all

# we need a TicketNumber
    if ( !IsStringWithData( $Param{Data}->{TicketNumber} ) ) {
        return $Self->{DebuggerObject}->Error( Summary => 'Got no TicketNumber' );
    }
You should change all references to TicketNumber to TicketID, or remove the validation whatsoever (also there is mapping to ReturnedData variable).

Invoking specific methods on your WS interface is quite simple (but poorly documented). The Invoker name that you specify in the "OTRS as requester" section of web service configuration corresponds to the WS method that will be called. So if you have WS interface with a method called "create" just name the Invoker "create" too.

So far I'm proceeding with trial and error approach. Would be nice if you could post your findings and solutions back to the forum, if you manage to gather the dynamic fields information and send it via WS.

Cheers
JanM
andys
Znuny newbie
Posts: 7
Joined: 18 Aug 2014, 22:48
Znuny Version: 3.2.6

Re: OTRS Webservice as Requestor Test

Post by andys »

Thanks for the tip Jan. I'm also going with the "Trial and error" approach because I can't seem to find any documentation on how custom requestors should be set up or how to pass dynamic variables in the webservice.
I'm pretty sure there's someone out there who has already done something similar to what we need. Just hope they would share their knowledge and help us get it working.
I will post if I get anything else working.
andys
Znuny newbie
Posts: 7
Joined: 18 Aug 2014, 22:48
Znuny Version: 3.2.6

Re: OTRS Webservice as Requestor Test

Post by andys »

With the modifications of renaming TicketNumber to TicketID in Test.pm, I now get ""Error in SOAP call: 404 Not Found at /TARGET/SHARE/var/otrs/Kernel/GenericInterface/Transport/HTTP/SOAP.pm line 578 (2014-09-02 09:20:43, error)" in the debugger which is the same error I was getting for TicketSimple.pm
Were you able to get the Test.pm or TestSimple.pm invokers to work successfully?
milhi
Znuny newbie
Posts: 6
Joined: 15 Aug 2014, 14:08
Znuny Version: OTRS 3.3
Company: OnTec Software Solutions AG

Re: OTRS Webservice as Requestor Test

Post by milhi »

Yes, I was able to trigger the request and receive it on my JBoss instance. The error you are getting mentions 404 Not Found, which is standard HTTP error code. I would suspect that you are trying to send the request to wrong URL? Probably the server is running, so it can make a response with 404 but wrong context path? The 578 line in SOAP.pm does exactly this:

Code: Select all

SOAPHandle->call(@CallData)
So I think that is consistent with my hypothesis. Please check once again your Endpoint configuration in the WS trasport configuration section. You should provide the whole URL just stripped of the Invoker name (method name).

If that doesn't help I would suggest trying to capture some packets from OTRS if that is possible in your infrastructure, to see if it is really sending something, what and where. Otherwise you have to sift through the logs/code and try to figure out what is going on.
andys
Znuny newbie
Posts: 7
Joined: 18 Aug 2014, 22:48
Znuny Version: 3.2.6

Re: OTRS Webservice as Requestor Test

Post by andys »

You were right, the link to my webservice wasn't set up correctly.
The Test.pm works now.
Trying to figure out how to pass the Ticket fields via the webservice.
I tried:

$ReturnData{Owner} = $Param{Data}=>{Owner};

and a variety of other variables but that didn't work. The only one that worked was the TicketID.
I also tried adding in the TicketObject and seeing if I can load it by the TicketID but that wouldn't work either.
Were you able to push Ticket variables?
milhi
Znuny newbie
Posts: 6
Joined: 15 Aug 2014, 14:08
Znuny Version: OTRS 3.3
Company: OnTec Software Solutions AG

Re: OTRS Webservice as Requestor Test

Post by milhi »

Not really push, no. But currently I use the TicketID which I'm able to receive to send a TicketGet request.

I basically have TicketGet operation defined in "OTRS as provider" web service section, mapped to Ticket::TicketGet controller and I am querying that one using TicketID which I receive from events triggered by OTRS.
andys
Znuny newbie
Posts: 7
Joined: 18 Aug 2014, 22:48
Znuny Version: 3.2.6

Re: OTRS Webservice as Requestor Test

Post by andys »

I added TicketGet for the OTRS as provider.
Can you show me some code on how to call this from the Invoker?
I tried:
TicketGet($Param{Data}->TicketID);
But that doesn't work.
i'm not sure how to call the OTRS webservice from within the invoker.
milhi
Znuny newbie
Posts: 6
Joined: 15 Aug 2014, 14:08
Znuny Version: OTRS 3.3
Company: OnTec Software Solutions AG

Re: OTRS Webservice as Requestor Test

Post by milhi »

Oh, I'm sorry, probably wasn't completely clear about that. I don't invoke a request to the OTRS WS from the OTRS Invoker... I do it from my application which acts as a web service adapter between two issue tracking systems.

So basically the flow is:

1. OTRS notifies (sends the TicketID) my WS Adapter (java app deployed on Wildfly server)
2. WS Adapter in turn requests the OTRS for ticket based on TicketID received in step 1.
3. OTRS sends a response with the ticket information through it's bundled Ticket::TicketGet controller
4. WS Adapter now has all the ticket information and can process them

Hope it helps. Cheers
andys
Znuny newbie
Posts: 7
Joined: 18 Aug 2014, 22:48
Znuny Version: 3.2.6

Re: OTRS Webservice as Requestor Test

Post by andys »

Ahh I see, so there's a lot of back and forth going on. Thanks for the flow, I understand what you're doing now.
I was hoping to be able to get the ticket details from the invoker since we already have the TicketID there and pass it back in one shot.
I'm sure it's possible but I'm just not sure how to do it. I've been looking at all the other .pm files in OTRS to see if I can figure it out but nothing seems to work.
Hopefully someone with experience with OTRS and PERL can help? I'm sure both milhi and I will greatly appreciate it.
Sascha79
Znuny newbie
Posts: 38
Joined: 23 Jul 2009, 09:21
Znuny Version: 5.0.22 (GIT)
Real Name: Sascha

Re: OTRS Webservice as Requestor Test

Post by Sascha79 »

Hi,

no way to put more data in the first call than just the TicketID?

Thanks for your answer,
Sascha
milhi wrote:Oh, I'm sorry, probably wasn't completely clear about that. I don't invoke a request to the OTRS WS from the OTRS Invoker... I do it from my application which acts as a web service adapter between two issue tracking systems.

So basically the flow is:

1. OTRS notifies (sends the TicketID) my WS Adapter (java app deployed on Wildfly server)
2. WS Adapter in turn requests the OTRS for ticket based on TicketID received in step 1.
3. OTRS sends a response with the ticket information through it's bundled Ticket::TicketGet controller
4. WS Adapter now has all the ticket information and can process them

Hope it helps. Cheers
"Production": OTRS5 (Ubuntu 16.04.4 Server (LTS) / Apache2 / MySQL 5+
kishormali
Znuny newbie
Posts: 12
Joined: 20 Jan 2020, 12:12
Znuny Version: 6.0
Real Name: Kishor Mali

Re: OTRS Webservice as Requestor Test

Post by kishormali »

Hi Everyone,

I am also fighting with this from last couple of hours. No help on Google.
I am getting data in Debugger but not getting it in OTRS handleResponse method.
The log of debugger given below.
response.png

Code: Select all

JSON data received from remote system (02/03/2020 11:12:47 (Asia/Kolkata), debug)

{"ResponseSuccess":1,"ResponseErrorMessage":"","Data":{"TicketID":63,"OTRS":"Example of REST"}}

Incoming data before mapping (02/03/2020 11:12:47 (Asia/Kolkata), debug)

$VAR1 = {
  'Data' => {
    'OTRS' => 'Example of REST',
    'TicketID' => 63
  },
  'ResponseErrorMessage' => '',
  'ResponseSuccess' => 1
};

Incoming data after mapping (02/03/2020 11:12:47 (Asia/Kolkata), debug)

$VAR1 = {
  'Data' => {
    'OTRS' => 'Example of REST',
    'TicketID' => 63
  },
  'ResponseErrorMessage' => '',
  'ResponseSuccess' => 1
};

Got no TicketID! (02/03/2020 11:12:47 (Asia/Kolkata), error)

No data provided

Got no TicketID! (02/03/2020 11:12:47 (Asia/Kolkata), error)

Got no TicketID!
You do not have the required permissions to view the files attached to this post.
Post Reply