Hi,I need to call a webscript form a Java WebService .I have just solved it using the URLConnection Java class ,but i don't want to parse the html respose for getting the return values .This is the code that i'm testing with the Javascript Debubber web script because it require authentication :
package org.alfresco.sample.webservice;
import org.alfresco.webservice.repository.*;
import org.alfresco.webservice.types.*;
import org.alfresco.webservice.util.*;
import java.io.*;
import java.net.*;
import org.alfresco.webservice.util.*;
public class Call2
{
public static void main(String[] args)
throws Exception
{
AuthenticationUtils.startSession("admin","admin");
String ticket=AuthenticationUtils.getTicket();
try
{
try
{
URL url= new URL("http://localhost:8080/alfresco/service/api/javascript/debugger?alf_ticket='+ticket);
URLConnection uc = url.openConnection();
BufferedReader in = new BufferedReader(new InputStreamReader(uc.getInputStream()));
String inputLine;
while ((inputLine = in.readLine()) != null)
System.out.println(inputLine);
in.close();
}catch(IOException e)
{
System.out.println("Error"+e);
}
}
finally
{
AuthenticationUtils.endSession();
}
}
}
and this is the html reponse :
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Alfresco Javascript Debugger</title>
<link rel="stylesheet" href="/alfresco/css/main.css" TYPE="text/css">
</head>
<body>
<form action="/alfresco/service/api/javascript/debugger" method="post">
<input type="hidden" name="visible" value="true">
<table>
<tr>
<td><img src="/alfresco/images/logo/AlfrescoLogo32.png" alt="Alfresco" /></td>
<td><nobr><span class="mainTitle">Alfresco Javascript Debugger</span></nobr></td>
</tr>
<tr><td><td>Alfresco Community Network v2.1.0 (482)
<tr><td><td>Currently disabled.
<input type="submit" name="submit" value="Enable">
</table>
</form>
</body>
</html>
The question is: if there exists another ways to do the same thing ? Thanks in advance.