• Post Reply Bookmark Topic Watch Topic
  • New Topic

Java and Perl

 
Mithila Ananth
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone suggest a good protocol used to call perl modules from a java program? I tried using xml-rpc but encountered a lot of errors. Any other ideas? Please post any links you think might be useful.
 
Ulf Dittmer
Rancher
Posts: 42970
73
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What do you mean by "Perl module" - something that's running in an Apache httpd server? TellTheDetails of what you tried, and what the result was, including error messages.
 
Mithila Ananth
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks for the quick reply.

I'm trying to connect a java client with a perl server using xml-rpc, the code for which I found at this link - http://www.javaworld.com/javaworld/jw-10-2004/jw-1011-xmlrpc.html?page=1

But I'm getting an error saying -

org.apache.xmlrpc.XmlRpcClientException: Error decoding XML-RPC response
at org.apache.xmlrpc.XmlRpcClientResponseProcessor.decodeResponse(XmlRpcClientResponseProcessor.java:78)
at org.apache.xmlrpc.XmlRpcClientWorker.execute(XmlRpcClientWorker.java:72)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:193)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:184)
at org.apache.xmlrpc.XmlRpcClient.execute(XmlRpcClient.java:177)
at XmlRpcClientExample.say_hello(XmlRpcClientExample.java:21)
at XmlRpcClientExample.main(XmlRpcClientExample.java:52)
Caused by: org.apache.xmlrpc.XmlRpcClientException: Error decoding XML-RPC exception response
at org.apache.xmlrpc.XmlRpcClientResponseProcessor.decodeException(XmlRpcClientResponseProcessor.java:109)
at org.apache.xmlrpc.XmlRpcClientResponseProcessor.decodeResponse(XmlRpcClientResponseProcessor.java:69)
... 6 more
Caused by: java.lang.NumberFormatException: For input string: "Client"
at java.lang.NumberFormatException.forInputString(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at java.lang.Integer.parseInt(Unknown Source)
at org.apache.xmlrpc.XmlRpcClientResponseProcessor.decodeException(XmlRpcClientResponseProcessor.java:102)
... 7 more



This is my client request message -

POST /otrs/server.pl HTTP/1.1
Content-Length: 118
Content-Type: text/xml
Cache-Control: no-cache
Pragma: no-cache
User-Agent: Java/1.6.0_10
Host: localhost:8080
Accept: text/html, image/gif, image/jpeg, *; q=.2, */*; q=.2
Connection: keep-alive

<?xml version="1.0"?><methodCall><methodName>PerlSystemFacade.say_hello_psf</methodName><params></params></methodCall>


This is my server response -

HTTP/1.1 200 OK
Date: Tue, 11 Jan 2011 08:17:02 GMT
Server: Apache/2.2.17 (Win32) mod_apreq2-20090110/2.7.1 mod_perl/2.0.4 Perl/v5.12.2
SOAPServer: SOAP::Lite/Perl/0.710.10
Content-Length: 336
Keep-Alive: timeout=5, max=100
Connection: Keep-Alive
Content-Type: text/xml

<?xml version="1.0" encoding="UTF-8"?><methodResponse><fault><value><struct><member><name>faultString</name><value><string>Application failed during request deserialization:
no element found</string></value></member><member><name>faultCode</name><value><string>Client</string></value></member></struct></value></fault></methodResponse>


Do you have any idea, what the problem could be?
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The NumberFormatException for input string "Client" appears to refer to:



Which the client code was trying to parse as an Integer. I have no idea why it expected an integer there.

Bill
 
Jimmy Clark
Ranch Hand
Posts: 2187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Could someone suggest a good protocol used to call perl modules from a java program?


Use a web service to connect the Java program and the Perl program.

Java Program -----> Web Service -----> Perl Program
 
Naren Chivukula
Ranch Hand
Posts: 577
Java Notepad Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mithila,
Just to add what Jimmy said. You can use SOAP/HTTP, if you have any experience with SOAP. If not XML/HTTP (Restful) web services.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!