📜 ⬆️ ⬇️

Step-by-step configuration of web services in OTRS 5

In this article I will tell you how to set up a web service in OTRS 5, where and what to enter and how to check the functionality of the service through SoapUI. We will configure SOAP, not REST. We configure OTRS as a provider, i.e. the system will give data on demand. If interested, then I ask under the cat.


So, we installed a wonderful OTRS, started working in it. And here the management required the reporting. And not some, but rather complicated. Instead of deeply sawing internal reports, we decided to simply take data from the system via the web service and build reports in a separate program.

So, go to the administration → web services.
')



Create a new web service:

1) Enter the name of the interface
2) Select the HTTP :: SOAP network transport
3) Click “Save”.



After saving, it is possible to select Operations .

We needed only three to work with tickets:

SessionCreate - allows you to create a session and continue to use its ID, rather than transfer the login password every time.
TicketSearch - allows you to find tickets by specified criteria (in our case, open and closed for a certain period). Returns a list of ticket IDs (with ID, not numbers).
TicketGet - allows you to get a specific ticket (or several) by ticket ID.



When you create an Operation, you specify the name by which you will call it later.



And the final touch - go to configuring network transport and set the namespace and message length. The length of 1000 is fine with us.





The namespace is the following link:

example.com/otrs/nph-genericinterface.pl/Webservice/InterfaceName

Where example.com is your domain, InterfaceName is your interface name. If encryption is configured, then https, not http.

All, from the OTRS all settings are made. Now how to access the service outside? To do this, put SoapUI, take the wsdl scheme and give it to SoapUI.

On the Internet, many have complained that OTRS does not itself give up the WSDL scheme, and this is, in fact, a problem.

Thanks to the kind people who shared it.

github.com/OTRS/otrs/tree/master/development/webservices

So we slightly alter the file they have proposed for us.

In the headers of the GenericTicketConnectorSOAP.wsdl file, we change the definitions name to the name of your web service.

<?xml version="1.0" encoding="UTF-8"?><wsdl:definitions name="GenericTicketConnectorSOAP" targetNamespace="http://www.otrs.org/TicketConnector/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://www.otrs.org/TicketConnector/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"> <wsdl:documentation> 

Then in all soap: operation in soapAction, change http: //www.otrs.org/TicketConnector to your NameSpace.

 <soap:operation soapAction="http://www.otrs.org/TicketConnector/TicketCreate" /> 

And at the very end of the document in wsdl: port you specify your NameSpace in location .

 <wsdl:port name="GenericTicketConnector_Port" binding="tns:GenericTicketConnector_Binding"> <soap:address location="http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorSOAP" /> </wsdl:port> 

Start the Soap UI, create a new SOAPProject, specify the file with the scheme.

The result should be something like this. Basic SoapUI requests are automatically generated.



And the final chord - check service performance. The service returned to us the SessionID, which can already be used in other requests, without transferring a login and password each time.



Some nuances:

1) As already mentioned, OTRS does not return the WSDL scheme, which is very inconvenient.
2) Upon request, TicketSearch will send no more than 500 ID-Schnick. So if more than 500 should come to you, then all the same you will receive only 500. I did not find how to get around this.
3) In TicketGet, to give SolutionDiffInMin (how much time the application decides differs from the SLA target), you need to send something to Extended in the request.

If someone has interesting comments, comments - welcome :)

PS about the fact that the search gave no more than 500 messages helped increase the parameter "GenericInterface :: Operation :: TicketSearch ### SearchLimit".
Thanks eisaev for help.
PPS Here is the second article on how to configure OTRS in the role of asking.

Source: https://habr.com/ru/post/319552/


All Articles