View Single Post
  #32 (permalink)  
Old 11-23-2007, 04:08 AM
monkeysandbox monkeysandbox is offline
Starter Member
 
Posts: 1
Default Cant get authToken

Hello Everyone,
For some reason, I cant seem to get the auth Token from /service/soap. (I get a java.io.IOException: Server returned HTTP response code: 500 for URL: http://localhost:7070/service/soap)
I can get all the other JSON responses from the server normally. When I login as user1 into Zimbra(in debug mode), I can see the auth token in the Zimbra SOAP Request/Response window. So it's only through my code that auth_token isn't being returned.
Could there be something wrong with my LDAP ?

Thanks,
-Linux/Java newbie


My Code... (Which Doesn't work)

Code:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page  language="java" %>
<%@ page  import="java.io.*" %>
<%@ page  import="java.net.*" %>

String GetAuthTokenSOAPString = "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'>";
	 GetAuthTokenSOAPString = "<soap:Header>";
	 GetAuthTokenSOAPString = "<context xmlns='urn:zimbra'>";
	 GetAuthTokenSOAPString = "<format type='js'/>";
	 GetAuthTokenSOAPString = "</context>";
	 GetAuthTokenSOAPString = "</soap:Header>";
	 GetAuthTokenSOAPString = "<soap:Body>";
	 GetAuthTokenSOAPString = "<AuthRequest xmlns='urn:zimbraAccount'>";
	 GetAuthTokenSOAPString = "<account by='name'>user1</account>";
	 GetAuthTokenSOAPString = "<password>test123</password>";
	 GetAuthTokenSOAPString = "</AuthRequest>";
	 GetAuthTokenSOAPString = "</soap:Body>";
	 GetAuthTokenSOAPString = "</soap:Envelope>";
		 
	 	 
	try
 	{
 	  	  
	  URL url = new URL("http://localhost:7070/service/soap");
	  URLConnection connection = url.openConnection();
	  connection.setDoOutput(true);
	  
	  OutputStreamWriter out1 = new OutputStreamWriter(
              connection.getOutputStream());
	  out1.write(GetAuthTokenSOAPString);
	  out1.close();
		
		BufferedReader in = new BufferedReader(
		new InputStreamReader(
		connection.getInputStream()));
		
		String decodedString;
		while ((decodedString = in.readLine()) != null) {
		out.println(decodedString);
		}
		in.close();
 	}
	catch (Exception e)
	{
			out.println(e);
	}
	%>
My Code for Batch Request... (Which works)
Code:
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ page  language="java" %>
<%@ page  import="java.io.*" %>
<%@ page  import="java.net.*" %>
 
 
 <%  
	 String SOAPstring = "<soap:Envelope xmlns:soap='http://www.w3.org/2003/05/soap-envelope'>\r\n";
	 SOAPstring += "<soap:Header> ";
	 SOAPstring += "<context xmlns='urn:zimbra'>";
	 SOAPstring += "<userAgent name='ZimbraWebClient - FF1.5 (Linux)' version='0.0'/>";
	 SOAPstring += "<sessionId id='8'/>";
	 SOAPstring += "<change token='199' type='new'/>";
	 SOAPstring += "<authToken>0_fda5351a0674d8d0eff356353d20f0c049d05c6c_69643d33363a33616563316263302d646133352d343631652d396438652d3030653538326465353562353b6578703d31333a313139353937383434313439353b</authToken>";
	 SOAPstring += "<format type='js'/>";
	 SOAPstring += "</context>";
	 SOAPstring += "</soap:Header>";
	 SOAPstring += "<soap:Body>";
	 //SOAPstring += "<BatchRequest xmlns='urn:zimbra' onerror='continue'>";
	 //SOAPstring += "<GetApptSummariesRequest xmlns='urn:zimbraMail' s='1195709400000' e='1195792200000' l='10' id='0'/>";
	 //SOAPstring += "</BatchRequest>";
	 SOAPstring += "<GetInfoRequest xmlns='urn:zimbraAccount'/>";
	 SOAPstring += "</soap:Body>";
	 SOAPstring += "</soap:Envelope>";
	
	try
 	{
 	  	  
	  URL url = new URL("http://localhost:7070/service/soap");
	  URLConnection connection = url.openConnection();
	  connection.setDoOutput(true);
	  
	  OutputStreamWriter out1 = new OutputStreamWriter(
              connection.getOutputStream());
	  out1.write(SOAPstring);
	  out1.close();
		
		BufferedReader in = new BufferedReader(
		new InputStreamReader(
		connection.getInputStream()));
		
		String decodedString;
		while ((decodedString = in.readLine()) != null) {
		out.println(decodedString);
		}
		in.close();
 	}
	catch (Exception e)
	{
			out.println(e);
	}
	%>
Reply With Quote