I try to interact with the otrs-ticketsystem in order to make
a few pictures and calculate some statistics. This I want to do in haskell
- I
use the package soap
.
Ignoring the import statements the code is fairly straightforward, I create a
SOAP-Transport with config file soap.cfg
(see below). Then construct the
SOAP-Body and call the web service with "Dispatch"
.
{-# LANGUAGE OverloadedStrings #-}
import Network (withSocketsDo)
import Network.SOAP
import Network.SOAP.Transport.HTTP
import Text.XML.Writer
import Text.XML.Stream.Parse as Parse
import Data.Text (Text)
import qualified Data.Text as T
import qualified Data.ByteString.Lazy.Char8 as BS
import Data.Configurator (load, Worth(Required))
main :: IO ()
main = withSocketsDo $ do
transport <- confTransport "soap" =<< load [Required "./src/SOAP/soap.cfg"]
let body = do element "TicketObject" ("TicketSearch" :: Text)
element "OwnerID" ("owner" :: Text)
xmlresult <- invokeWS transport "#TicketObject" () body (RawParser id)
BS.putStrLn xmlresult
soap.cfg
soap {
url = "http://domain/otrs/rpc.pl"
user = "testuser"
password = "testpass"
trace = true
timeout = 15
}
If I build and call this program I get the following xmlresult
:
request:
<?xml version="1.0" encoding="UTF-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<TicketObject>TicketSearch</TicketObject>
<OwnerID>heu</OwnerID>
</soapenv:Body>
</soapenv:Envelope>
response:
<?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>
<soap:Fault>
<faultcode>soap:Client</faultcode>
<faultstring>
SOAPAction shall match 'uri#method' if present (got 'Dispatch', expected '#TicketObject'
</faultstring>
</soap:Fault>
</soap:Body>
</soap:Envelope>
If I then change the line following line
xmlresult <- invokeWS transport "Dispatch" () body (RawParser id)
to
xmlresult <- invokeWS transport "#TicketObject" () body (RawParser id)
the faultstring becomes
<faultstring>
Denied access to method (TicketObject) in class (main) at /opt/otrs/Kernel/cpan-lib/SOAP/Lite.pm line 2810.
</faultstring>
I searched the internet for some solution, I only found this
- http://otrs.perl-services.de/… about ticketsearch, and of course the OTRS 3.3 API
- http://blog.otrs.org -> ticket search (perl)
- OTRS Client in Java
- OTRS iPhoneObject providing JSON
with the last one I successfully managed to get a result - but only for iPhoneObject and TicketGet - unfortunately TicketSearch seems not to be supported.
Can anybody tell me what valid XML for the request needs to look like?
I also found How to create an otrs ticket using a soap request .Net - which uses web services - but unfortunately I do not know how to create such a service.