Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't seem to get full text search working using SOAP #10

Closed
frdmn opened this issue Mar 21, 2016 · 27 comments
Closed

Can't seem to get full text search working using SOAP #10

frdmn opened this issue Mar 21, 2016 · 27 comments

Comments

@frdmn
Copy link

frdmn commented Mar 21, 2016

Hello,

i struggle since about 3 months to get the full text search working via SOAP.

Already tried asking for help in the official otterhub forum, but noone seems to be able to help me here: OtterHub - OTRS Community | Full text search via SOAP and GenericTicketConnector

Here's what I use at the moment:

tickets = client.ticket_search(
    ContentSearch = 'OR',
    From = '%' + args['input'] + '%',
    To = '%' + args['input'] + '%',
    Cc = '%' + args['input'] + '%',
    Subject = '%' + args['input'] + '%',
    Body = '%' + args['input'] + '%',
    Title = '%' + args['input'] + '%'
)

... based on the example code in the Ticket.pm file in the OTRS source: https://github.com/OTRS/otrs/blob/1e908159a5dbdcfb94cc35d13bf15b04ac3e6a24/Kernel/System/LinkObject/Ticket.pm#L271-L282, but for some reason it always returns an empty array.

However, it works fine when I try a more simple search like:

tickets = client.ticket_search(
    Title = '%' + args['input'] + '%'
)

I want to search like the full text search in the web ui though. Any ideas?

@ewsterrenburg
Copy link
Owner

As far as I can see, ContentSearch = 'OR' is being ignored by the OTRS Generic Ticketconnector.

When I do some testing, the results appear as if only results are given back for which each of the conditions specified is True. This behavior occurs both calling the TicketConnector from Python and when testing the GenericTicket connector directly using SoapUI.

@frdmn could you do some testing if you agree with me that the ticket connector checks for each condition regardless of the value supplied for ContentSearch? If so, we could file a bug report with OTRS itself.

@frdmn
Copy link
Author

frdmn commented Mar 21, 2016

@ewsterrenburg I would love to debug/test this with you! I already spent several months trying to get a proper response from the OTRS team, but no-one really could help me out yet.

Let me know when and how you need my help 👍

@ewsterrenburg
Copy link
Owner

Doesn't sound really hopeful, since I suspect the issue is located within OTRS itself...

@frdmn Could you please check if a request of the following nature only returns you the tickets for which the string being searched for (I used "test", use something that is present in your tickets ;)) occurs both in the subject and body of the ticket. If so, I will put it up on the OTRS mailing list

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
                  xmlns="http://www.otrs.org/TicketConnector/">
  <soapenv:Header/>
  <soapenv:Body>
  <TicketSearch>
           <UserLogin>username</UserLogin>
         <Password>password</Password>
  <Body>test</Body>
  <Subject>test</Subject>
  <ContentSearch>OR</ContentSearch>
</TicketSearch>
  </soapenv:Body>
</soapenv:Envelope>

@frdmn
Copy link
Author

frdmn commented Mar 21, 2016

Not sure if I do this right, but I setup SoapUI, downloaded the WSDL, imported it and tried the following request:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns="http://www.otrs.org/TicketConnector/">
  <soapenv:Header/>
  <soapenv:Body>
    <TicketSearch>
     <UserLogin>jonas.friedmann</UserLogin>
     <Password>[password]</Password>
     <Body>RapidSSL</Body>
     <Subject>RapidSSL</Subject>
     <ContentSearch>OR</ContentSearch>
   </TicketSearch>
 </soapenv:Body>
</soapenv:Envelope>

Which returns the following (error) response:

<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 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>
      <Fault xmlns="http://www.otrs.org/TicketConnector/">
         <faultcode>Server</faultcode>
         <faultstring>Namespace from SOAPAction 'http://www.otrs.org/TicketConnector' does not match namespace from configuration 'http://www.otrs.org/TicketConnector/'</faultstring>
      </Fault>
   </soap:Body>
</soap:Envelope>

Did I miss anything?

@ewsterrenburg
Copy link
Owner

Don't know, it's working for me. But you could also test it using your python code I guess...

@frdmn
Copy link
Author

frdmn commented Mar 21, 2016

Interesting, works for me via python-otrs but not via raw SOAP. I'm going to take a look in the Webservice Debugger and try to compare both requests to see the differences. Stay tuned :)

@frdmn
Copy link
Author

frdmn commented Mar 21, 2016

Here's the request received from the debugger:

Comparison:

2,3c2,3
<   'CONTENT_LENGTH' => '422',
<   'CONTENT_TYPE' => 'text/xml;charset=UTF-8',
---
>   'CONTENT_LENGTH' => '388',
>   'CONTENT_TYPE' => 'text/xml;charset=utf-8',
7,8c7,8
<   'HTTP_ACCEPT_ENCODING' => 'gzip,deflate',
<   'HTTP_CONNECTION' => 'Keep-Alive',
---
>   'HTTP_ACCEPT_ENCODING' => 'identity',
>   'HTTP_CONNECTION' => 'close',
10,11c10
<   'HTTP_SOAPACTION' => '"http://www.otrs.org/TicketConnector/TicketSearch"',
<   'HTTP_USER_AGENT' => 'Apache-HttpClient/4.1.1 (java 1.5)',
---
>   'HTTP_USER_AGENT' => 'Python-urllib/2.7',
19c18
<   'REMOTE_PORT' => '56885',
---
>   'REMOTE_PORT' => '56379',
30c29,30
<   'SERVER_SOFTWARE' => 'Apache/2.2.16 (Debian)'
---
>   'SERVER_SOFTWARE' => 'Apache/2.2.16 (Debian)',
>   'SSL_TLS_SNI' => 'ticket.intern.company.de'

My guess is that the HTTP_SOAPACTION makes the request invalid out of SoapUI. I have no clue how that got in there though - I assume because I imported the WSDL?

@frdmn
Copy link
Author

frdmn commented Mar 21, 2016

@ewsterrenburg Finally got it working! Apparently the SOAPACTION is a SoapUI-specific behaviour(?). I just tried to send the raw HTTP request using Postman and that immediately worked like a charm.

Regarding your actual question: I've picked a ticket which contains a really unique ticket number from a remote ticket system (2016031410000296) only in the subject, but not in the body.

Now I tried a SOAP request like this:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
  xmlns="http://www.otrs.org/TicketConnector/">
  <soapenv:Header/>
  <soapenv:Body>
    <TicketSearch>
     <UserLogin>jonas.friedmann</UserLogin>
     <Password>[password]</Password>
     <Body>2016031410000296</Body>
     <Subject>2016031410000296</Subject>
     <ContentSearch>OR</ContentSearch>
   </TicketSearch>
 </soapenv:Body>
</soapenv:Envelope>

And this is what I've received:

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope soap:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" 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>
        <TicketSearchResponse xmlns="http://www.otrs.org/TicketConnector/" xsi:nil="true" />
    </soap:Body>
</soap:Envelope>

Ergo, the response is completely empty even though, it should actually list at least one ticket ID.

To cross check this problem I removed either <Body> or <Subject>, and it returned the proper ticket ID as expected.

I guess this confirms our assumptions, right?

@ewsterrenburg
Copy link
Owner

@frdmn I agree.
Will you report this to the OTRS development team or should I do so?

@frdmn
Copy link
Author

frdmn commented Mar 21, 2016

@ewsterrenburg I am not really familiar with mailing lists, so it would be nice if you could submit it. If you have more important stuff to do right now, I can also try to o it :)

@ewsterrenburg
Copy link
Owner

Posted it on the OTRS mailinglist

@frdmn
Copy link
Author

frdmn commented Mar 22, 2016

Thank you! Now let's wait patiently for a response :)

@ewsterrenburg
Copy link
Owner

@frdmn
no reaction on the mailing list. Reported it with the otrs bugtracker:
http://bugs.otrs.org/show_bug.cgi?id=11981

@frdmn
Copy link
Author

frdmn commented Apr 4, 2016

🙂👍

Von meinem iPhone gesendet

Am 04.04.2016 um 15:43 schrieb ewsterrenburg notifications@github.com:

@frdmn
no reaction on the mailing list. Reported it with the otrs bugtracker:
http://bugs.otrs.org/show_bug.cgi?id=11981


You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub

@frennkie
Copy link

I have been working on a Python implementation for the OTRS API over the last few days which - I'll have to admit - actually does the same thing as you have done here. But I really did not want to touch that SOAP stuff and am using the REST interface.
i believe I have run into the same issue with my project as you have:

In [10]: client.ticket_search(Subject="%worldwide%")
DEBUG:pyotrs.client:{}
DEBUG:pyotrs.client:search found no results
Out[10]: []

In [11]: client.ticket_search(Body="%worldwide%")
DEBUG:pyotrs.client:{u'TicketID': [u'1']}
Out[11]: [u'1']

In [12]: client.ticket_search(Body="%worldwide%",Subject="%worldwide%",ContentSearch="OR")
DEBUG:pyotrs.client:{}
DEBUG:pyotrs.client:search found no results
Out[12]: []

The only ticket I have in my system is the initial "Welcome to OTRS" which has "worldwide" in it's body, so the ticket should also be found in my [12] example, right?!

@ewsterrenburg
Copy link
Owner

ewsterrenburg commented Apr 14, 2016

@frennkie
I agree with you on this one and expect that ticket to be found...
It keeps being quiet on both OTRS mailinglist and Bugtracker though.

Since @frdmn has similar experiences of proper responses lacking, priority for the dev team seems to be low. Fortunately, I am not using full text searches anyway.

@frennkie
Copy link

@ewsterrenburg I assume you have absolutely no intention on using/switch to REST as you already have a full SOAP implementation, right? I have not yet published my code but am planning to do so (possibly as "PyOTRS"). Any objections from your side?

@ewsterrenburg
Copy link
Owner

ewsterrenburg commented Apr 14, 2016

@frennkie

No objections at all and neither any intention to use/switch to REST at the moment.
Generally I like REST better as well, yet there were two reasons have chosen SOAP:

  1. Me being totally clueless how to set up the REST service within OTRS
  2. A perfectly fine solution for SOAP was already available created by @JocelynDelalande which I could extend.

@frennkie
Copy link

@ewsterrenburg I think you got the wrong frennkie there.. I'm @frennkie ;-)
Otherwise I completely understand you.
Setting up the OTRS REST service is actually very easy and done in two minutes. All you need to do is download the example .yml config from the OTRS repo and upload it as a new web service:
https://github.com/OTRS/otrs/tree/master/development/webservices

@ewsterrenburg
Copy link
Owner

ewsterrenburg commented Apr 14, 2016

@frennkie
ups, so many fren(n)kies in this world...

Ok, that doesn't seem difficult. Nonetheless I was being clueless when I installed OTRS while the SOAP service worked right away. So, maybe it's possible to switch someday, yet for now SOAP service does it's job perfectly fine :)

@frdmn
Copy link
Author

frdmn commented Apr 14, 2016

@frennkie Perhaps you could "+1" the issue in the bug tracker so the OTRS dev team notice the demand of a fix for this problem.

Right now, my original project is kind of abandoned because it depends on a full text search in OTRS :/

I already thought about just scraping the web page instead for now...

@frennkie
Copy link

frennkie commented Apr 14, 2016

@frdmn I already posted a follow up in the OTRS tracker to Bug 11981.

@frdmn
Copy link
Author

frdmn commented Apr 14, 2016

@frennkie Oh, I saw Robert's comments but didn't realize it's you. Thanks buddy! 👍

@ewsterrenburg
Copy link
Owner

Issue is clear. Is now fixed in OTRS (at least in OTRS5). Will close this issue.

@frdmn
Copy link
Author

frdmn commented Jul 27, 2016

👍

@Filterer
Copy link

Filterer commented Apr 6, 2018

Hi all,

I know that this issue is closed but I have the same problem when trying to search tickets based on their article fields (subject, body etc). I m having OTRS 6 on ubuntu and I am executing queries with curl in the terminal. OTRS is also configured as an Invoker with REST and I am using the common GenericTicketConnectorREST webservice with the basic ticket and session functions.

For example:
This query works and searches for tickets with a specific title and the ones that belong to the 'Raw' queue.
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?SessionID=xLHFqyIbO9OUDZypaFGSVDbe3sA0v3NF&Title=some+title&Queues=Raw"

But this one that searches for tickets with a specific subject it doesn't work and returns all the existing tickets on the OTRS server.
curl "http://localhost/otrs/nph-genericinterface.pl/Webservice/GenericTicketConnectorREST/Ticket?SessionID=xLHFqyIbO9OUDZypaFGSVDbe3sA0v3NF&Subject=some+subject"

Same problem exists for the From, To, CC and Body. ContentSearch and FullTextIndex don't make a difference as well. Also AttachmentName doesn't seem to work as well but that is not article related I guess.

Any help will be appreciated.

@ewsterrenburg
Copy link
Owner

@Filterer
Am I correct that you are not experiencing an issue with the python-otrs library, yet with OTRS itself?

If so, could you please try the OTRS mailing list or one of the OTRS related forums for help...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants