Zimbra offers Open Source email server software and shared calendar for Linux and the Mac
Go Back   Zimbra :: Forums > Zimbra Collaboration Suite > Developers

Welcome to the Zimbra :: Forums!
Welcome, if you would like to post a comment please register. We also encourage you to explore all things Zimbra with our team and members of the community.

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #11 (permalink)  
Old 03-22-2006, 09:25 PM
Senior Member
 
Posts: 59
Default url="https://192.168.1.127:7071/zimbraAdmin"

public class NoCertificationHttpsGetSample {
public static void main(String[] args) {
Protocol myhttps = new Protocol("https",
new MySecureProtocolSocketFactory(),7071);
Protocol.registerProtocol("https", myhttps);
HttpClient httpClient = new HttpClient();
httpClient.getHostConfiguration().setHost("192.168 .1.127",7071,myhttps);
String url="https://192.168.1.127:7071/zimbraAdmin";
PostMethod postMethod = new PostMethod(url);
postMethod.getParams().setParameter(HttpMethodPara ms.RETRY_HANDLER,
new DefaultHttpMethodRetryHandler());
try{
InputStream soap= new FileInputStream("soap.xml");
postMethod.setRequestBody(soap);
}catch(Exception err){};
try{
int statusCode = httpClient.executeMethod(postMethod);
if (statusCode != HttpStatus.SC_OK) {
System.err.println("Method failed: "+ postMethod.getStatusLine());
}
InputStream responseBody=postMethod.getResponseBodyAsStream();
System.out.println(responseBody);
} catch (HttpException e) {
System.out.println("Please check your provided https address!");
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally{
postMethod.releaseConnection();
}

}
}

soap.xml like this:
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>
<context xmlns="urn:zimbra"/>
</soap:Header>
<soap:Body>
<AuthRequest xmlns="urn:zimbraAdmin">
<name>admin@sina.com</name>
<password>zimbra</password>
</AuthRequest>
</soap:Body>
</soap:Envelope>


error:
2006-3-23 13:21:06 org.apache.commons.httpclient.HttpMethodDirector isRedirectNeeded
信息: Redirect requested but followRedirects is disabled
Method failed: HTTP/1.1 302 Moved Temporarily
org.apache.commons.httpclient.AutoCloseInputStream @1cde100

Last edited by crossany; 07-05-2010 at 12:38 AM..
Reply With Quote
  #12 (permalink)  
Old 03-22-2006, 11:51 PM
Senior Member
 
Posts: 59
Default String url="https://192.168.1.127:7071/auth/";

I change the postMoethod url to "https://192.168.1.127:7071/auth/";
the error like this :
Method failed: HTTP/1.1 400 Bad Request
org.apache.commons.httpclient.AutoCloseInputStream @2bbd86
I think that should be the soap error
would tell me the right soap xmlstream
Reply With Quote
  #13 (permalink)  
Old 03-23-2006, 07:39 AM
Zimbra Employee
 
Posts: 4,792
Default

Quote:
Originally Posted by crossany
I change the postMoethod url to "https://192.168.1.127:7071/auth/";
the error like this :
Method failed: HTTP/1.1 400 Bad Request
org.apache.commons.httpclient.AutoCloseInputStream @2bbd86
I think that should be the soap error
would tell me the right soap xmlstream
That is a HTTP url for the webclient. It's not used for SOAP requests.
__________________
Bugzilla - Wiki - Downloads - Offline Client
Reply With Quote
  #14 (permalink)  
Old 03-23-2006, 06:07 PM
Senior Member
 
Posts: 59
Default admin AuthRequest

Quote:
Originally Posted by sam
yeah, first send

<Envelope xmlns="http://www.w3.org/2003/05/soap-envelope">
<Body>
<AuthRequest xmlns="urn:zimbraAccount">
<account by="name">user1</account>
<password>****</password>
</AuthRequest>
</Body>
</Envelope>

you'll get back

<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
<soap:Header>...stuff...
</soap:Header>
<soap:Body>
<AuthResponse xmlns="urn:zimbraAccount">
<authToken>...auth_token...</authToken>
<lifetime>172800000</lifetime>
<sessionId id="55">55</sessionId>
</AuthResponse>
</soap:Body>
</soap:Envelope>


You must save the auth_token and sessionId and pass it back to the server in subsequent requests.
I look the soap.txt and soapadmin.txt I find you tell me the code is was the user AuthRequest .I want send a AuthRequest as a admin . could you tell the
soap xmlStream ,and tell the https url.
Reply With Quote
  #15 (permalink)  
Old 09-01-2008, 11:26 PM
Loyal Member
 
Posts: 91
Default

What is new MySecureProtocolSocketFactory() class do?

Thank you
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes


Similar Threads

Why Join?

Registering let's you ask questions, makes it easier to search, displays any files attached to posts, and notifies you about replies.

blog.zimbra.com




 

SEO by vBSEO ©2011, Crawlability, Inc.