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

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
  #1 (permalink)  
Old 10-17-2005, 09:47 AM
Active Member
 
Posts: 25
Default another SOAP related dumb question... [forget - solved]

Code:
#!/usr/bin/ruby
require 'http-access2'
require 'soap/rpc/driver'
require 'soap/driver'

drv = SOAP::RPC::Driver.new('https://192.168.10.191:7071/', 'urn:zimbraAdmin')

drv.wiredump_dev = STDERR  #if $DEBUG
drv.options["protocol.http.ssl_config.verify_mode"] = nil 
drv.options["protocol.http.basic_auth"]  << ['http://192.168.10.191:7071', 'admin@XXXXXX', 'XXXXX']
p drv.add_method('GetAllAdminAccountsRequest')
p drv.GetAllAdminAccountsRequest().call
any hint why the above ruby call returns...

Code:
= Request

! CONNECT TO 192.168.10.191:7071
! CONNECTION ESTABLISHED
at depth 0 - 18: self signed certificate
POST / HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
User-Agent: SOAP4R/1.5.5 (/114, ruby 1.8.3 (2005-09-21) [i686-linux])
Date: Mon Oct 17 17:45:13 WEST 2005
Content-Length: 428
Host: 192.168.10.191:7071

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <n1:GetAllAdminAccountsRequest xmlns:n1="urn:zimbraAdmin"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    </n1:GetAllAdminAccountsRequest>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Expires: Mon, 24 Oct 2005 16:43:22 GMT
Cache-control: max-age:604800, must-revalidate
Set-Cookie: JSESSIONID=F93E54662D82238BAD27208D2025F3E8; Path=/; Secure
Location: https://192.168.10.191:7071/zimbraAdmin
Content-Type: text/html;charset=ISO-8859-1
Content-Length: 0
Date: Mon, 17 Oct 2005 16:43:22 GMT

= Request

POST /zimbraAdmin HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
Cookie: JSESSIONID=F93E54662D82238BAD27208D2025F3E8
User-Agent: SOAP4R/1.5.5 (/114, ruby 1.8.3 (2005-09-21) [i686-linux])
Date: Mon Oct 17 17:45:13 WEST 2005
Content-Length: 428
Host: 192.168.10.191:7071

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <n1:GetAllAdminAccountsRequest xmlns:n1="urn:zimbraAdmin"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    </n1:GetAllAdminAccountsRequest>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 302 Moved Temporarily
Server: Apache-Coyote/1.1
Location: https://192.168.10.191:7071/zimbraAdmin/
Transfer-Encoding: chunked
Date: Mon, 17 Oct 2005 16:43:22 GMT

0

= Request

POST /zimbraAdmin/ HTTP/1.1
SOAPAction: ""
Content-Type: text/xml; charset=utf-8
Cookie: JSESSIONID=F93E54662D82238BAD27208D2025F3E8
User-Agent: SOAP4R/1.5.5 (/114, ruby 1.8.3 (2005-09-21) [i686-linux])
Date: Mon Oct 17 17:45:13 WEST 2005
Content-Length: 428
Host: 192.168.10.191:7071

<?xml version="1.0" encoding="utf-8" ?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <env:Body>
    <n1:GetAllAdminAccountsRequest xmlns:n1="urn:zimbraAdmin"
        env:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
    </n1:GetAllAdminAccountsRequest>
  </env:Body>
</env:Envelope>

= Response

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Expires: Thu, 3 Nov 2005 17:23:51 GMT
Cache-control: max-age:31536000, must-revalidate
Set-Cookie: JSESSIONID=BCC1B34B6333112258C7640A561B8A8A; Path=/zimbraAdmin; Secure
Content-Type: text/html;charset=ISO-8859-1
Content-Language: en-US
Transfer-Encoding: chunked
Date: Mon, 17 Oct 2005 16:43:22 GMT

(...)
and not the expected answer ?


Thanxs in advance.

Last edited by antonio.meireles; 10-17-2005 at 10:35 AM..
Reply With Quote
  #2 (permalink)  
Old 10-17-2005, 11:25 AM
Zimbra Employee
 
Posts: 274
Default URL for SOAP is different from UI url.

URL should contain /service/soap/

Code:
drv = SOAP::RPC::Driver.new('https://192.168.10.191:7071/', 'urn:zimbraAdmin')
vs

Code:
drv = SOAP::RPC::Driver.new('https://192.168.10.191:7071/service/soap/', 'urn:zimbraAdmin')
I am almost sure the trailing slash is required (tomcat, not us) - try it with and without.
Reply With Quote
  #3 (permalink)  
Old 10-17-2005, 11:58 AM
Zimbra Employee
 
Posts: 6
Default

There are several issues with the script that you provided so that it won't work with Zimbra server

1) As OP stated, the url is incorrect
2) Authentication process is in Zimbra layer not in SSL layer therefore login soap request has to be sent to Zimbra server first to obtain session and token ids.

Here is a rather crude and simple ruby script to issue 'GetAllAdminAccountsRequest'

Hope it helps

Bill

Code:
#!/usr/bin/ruby
require 'soap/rpc/driver'
require 'soap/driver'
require 'soap/header/simplehandler'

class ClientAuthHeaderHandler < SOAP::Header::SimpleHandler
    MyHeaderName = XSD::QName.new("urn:zimbra", "context")
    
    def initialize(sessionid = nil, authtoken = nil)
      super(MyHeaderName)
      @sessionid = sessionid
      @authtoken = authtoken       
    end
    
    def on_simple_outbound
      if @sessionid
        { "sessionId" => @sessionid, "authToken" => @authtoken }
      end     
    end 
end

drv = SOAP::RPC::Driver.new('https://foo.zimbra.com:7071/service/admin/soap/', 'urn:zimbraAdmin')

drv.wiredump_dev = STDERR  #if $DEBUG
drv.options["protocol.http.ssl_config.verify_mode"] = nil 
drv.add_method('GetAllAdminAccountsRequest')
drv.add_method('AuthRequest',"name", "password")

token, lifetime, sessionid = drv.AuthRequest('admin@foo.zimbra.com','zimbra')
drv.headerhandler << ClientAuthHeaderHandler.new(sessionid, token) 
p drv.GetAllAdminAccountsRequest()

Last edited by bhwang; 10-17-2005 at 12:03 PM..
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.