accessing otrs soap using java_groovy _ gregors braindump

2
20/12/13 Accessing OTRS SOAP using Java/Groovy | Gregors Braindump gregor.tudan.de/2010/04/accessing-otrs-soap-from-javagroovy/ 1/2 Accessing OTRS SOAP using Java/Groovy Being interested in Webservices, I was searching for something to play with in order to get a bit more practise and found OTRS at work. I was excited and wanted to give it a try, but soon found, that the interface OTRS was offering had little to do with Webservices. It is more like RPC using the SOAP protocol, basic elements like a predefined interface (WSDL) are missing. This makes all the frameworks for Webservices in Java practically useless. After googling around, I found a post from Joko Sastriawan explaining how to build SOAP-Messages using the standard JDK methods. I gave it a try and came up with a generic Java utility for creating SOAP Messages for OTRS. While is written in pure Java, it is intended to be used with something dynamic like Groovy and comes pretty close to the feeling of the original SOAP::Lite client. Watch this: This will give you an array of TicketIDs, that can be used for more sophisticated stuff. Let’s print the body of the last Article for a Ticket: You get the idea. I’m willing to share what I learned and might upload the code to github. If you’re interested, drop me a line. UPDA TE: The code is available on github: https://github.com/gtudan/OTRS-Client 0 Posted by Gregor Tudan on April 26, 2010 Leave a comment (6) Go to comments 1 // Prepare Connection 2 def otrsConn = new OtrsConnector( 'https://example.org/otrs/rpc.pl' , 'soapUser' , 'soapPass' ) 3 4 // Find all open tickets 5 def params = [Result: 'ARRAY' , Limit: 100 , UserID: 1 , StateType:[ 'open' ]] 6 def msg = otrsConn.dispatchCall( "TicketObject" , "TicketSearch" , params) 7 String[] result = new SimpleSoapMessageParser().nodesToArray(msg) 1 def msg2 = otrsConn.dispatchCall( "TicketObject" , "ArticleFirstArticle" , [TicketID: 0815 ]) 2 def result2 = new SimpleSoapMessageParser().nodesToMap(msg2) 3 4 // Accessing properties is easy using groovy, since this is a map 5 def body = result2[ 'Body' ] // or result2.Body 6 7 // Body comes base64 encoded, we need some magic here... 8 println new String(body. decodeBase64 (), 'UTF-8' ) Programming Groovy, Java, OTRS, SOAP, Webservice 6 Comments. Leave a comment ? Thomas Holmström July 6, 2010 at 21:03 Hi! Would you like to share your code? I’m trying to do the same from Ruby, but have a hard time reverse-engineering the calls to OTRS’s SOAP::Lite peculiarities. It seems like the order of the parameters in the SOAP body is significant, right? I am at the point where I’ve got OTRS to accept my SOAP call without de-serialization errors but I get empty answers for all my calls. The OTRS log shows “Need UserID or CustomerUserID params for permission check!” for my TicketSearch calls and “Need User or UserID!” for my GetUserData call even though I provide a UserID in both cases… Reply Recent Posts Accessing OTRS SOAP using Java/Groovy Search by Tags! Groovy Java OTRS SOAP Webservice Archives April 2010 Links Meta Log in RSS Feed Gregors Braindump Home About Search: type, hit enter

Upload: diego-flores

Post on 26-Nov-2015

100 views

Category:

Documents


5 download

TRANSCRIPT

  • 20/12/13 Accessing OTRS SOAP using Java/Groovy | Gregors Braindump

    gregor.tudan.de/2010/04/accessing-otrs-soap-from-javagroovy/ 1/2

    Accessing OTRS SOAP using Java/Groovy

    Being interested in Webservices, I was searching for something to play with in order to get a bit more

    practise and found OTRS at work. I was excited and wanted to give it a try, but soon found, that the

    interface OTRS was offering had little to do with Webservices. It is more like RPC using the SOAP protocol,

    basic elements like a predefined interface (WSDL) are missing. This makes all the frameworks for

    Webservices in Java practically useless. After googling around, I found a post from Joko Sastriawan

    explaining how to build SOAP-Messages using the standard JDK methods.

    I gave it a try and came up with a generic Java utility for creating SOAP Messages for OTRS. While is

    written in pure Java, it is intended to be used with something dynamic like Groovy and comes pretty close to

    the feeling of the original SOAP::Lite client. Watch this:

    This will give you an array of TicketIDs, that can be used for more sophisticated stuff. Lets print the body of

    the last Article for a Ticket:

    You get the idea. Im willing to share what I learned and might upload the code to github. If youre

    interested, drop me a line.

    UPDATE: The code is available on github: https://github.com/gtudan/OTRS-Client

    0

    Posted by Gregor Tudan on April 26, 2010 Leave a comment (6)Go to comments

    1 // Prepare Connection2 def otrsConn = new OtrsConnector('https://example.org/otrs/rpc.pl', 'soapUser','soapPass')

    3 4 // Find all open tickets5 def params = [Result:'ARRAY', Limit:100, UserID:1, StateType:['open']]6 def msg = otrsConn.dispatchCall("TicketObject", "TicketSearch", params)7 String[] result = new SimpleSoapMessageParser().nodesToArray(msg)

    1 def msg2 = otrsConn.dispatchCall("TicketObject", "ArticleFirstArticle",[TicketID:0815])

    2 def result2 = new SimpleSoapMessageParser().nodesToMap(msg2) 3 4 // Accessing properties is easy using groovy, since this is a map5 def body = result2['Body'] // or result2.Body6 7 // Body comes base64 encoded, we need some magic here...8 println new String(body.decodeBase64(),'UTF-8')

    Programming Groovy, Java, OTRS, SOAP, Webservice

    6 Comments.Leave a comment ?

    Thomas Holmstrm July 6, 2010 at 21:03

    Hi!Would you like to share your code? Im trying to do the same from Ruby, but have a hardtime reverse-engineering the calls to OTRSs SOAP::Lite peculiarities. It seems like theorder of the parameters in the SOAP body is significant, right?

    I am at the point where Ive got OTRS to accept my SOAP call without de-serializationerrors but I get empty answers for all my calls.

    The OTRS log shows Need UserID or CustomerUserID params for permission check! formy TicketSearch calls and Need User or UserID! for my GetUserData call even though Iprovide a UserID in both cases

    Reply

    Recent Posts

    Accessing OTRS SOAP using Java/Groovy

    Search by Tags!

    Groovy Java OTRS SOAP Webservice

    Archives

    April 2010

    Links

    Meta

    Log in

    RSS Feed

    Gregors Braindump

    Home AboutSearch: type, hit enter

  • 20/12/13 Accessing OTRS SOAP using Java/Groovy | Gregors Braindump

    gregor.tudan.de/2010/04/accessing-otrs-soap-from-javagroovy/ 2/2

    Leave a Comment

    NAME

    EMAIL

    Website URL

    NOTE - You can use these HTML tags and attributes:

    SUBMIT

    Regards,

    Thomas

    Greg Duffy October 25, 2010 at 10:47

    Would also like to share your code, any chance of passing it on please.

    Regards

    Greg

    Reply

    Jayanth February 4, 2011 at 07:53

    Hi,

    I am very interested to try out your approach. Can you share the code

    Regards,Jayanth

    Reply

    The Red May 31, 2011 at 14:43

    Im also very interested. Thanks for help. Good work!

    Reply

    Stephan Scharff-Rahn August 12, 2011 at 15:03

    Im very interested to.

    Chears*Stephan

    Reply

    Roman Keller January 4, 2012 at 11:15

    Hi

    That is wat im looking for Is there a way to get your Library?

    Thank you,Roman

    Reply

    Copyright 2013 Gregors Braindump | Powered by zBench and WordPress Top