another SOAP related dumb question... [forget - solved]

Discuss your pilot or production implementation with other Zimbra admins or our engineers.
antonio.meireles
Posts: 25
Joined: Fri Sep 12, 2014 9:56 pm

another SOAP related dumb question... [forget - solved]

Postby antonio.meireles » Mon Oct 17, 2005 11:47 am

#!/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...
= 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


http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema"

xmlns:env=http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi=http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema-instance">




env:encodingStyle=http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding/">






= 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


http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema"

xmlns:env=http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi=http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema-instance">




env:encodingStyle=http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding/">






= 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


http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema"

xmlns:env=http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope">http://schemas.xmlsoap.org/soap/envelope/"

xmlns:xsi=http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema">http://www.w3.org/2001/XMLSchema-instance">




env:encodingStyle=http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding">http://schemas.xmlsoap.org/soap/encoding/">






= 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.


17629anand
Zimbra Alumni
Zimbra Alumni
Posts: 273
Joined: Fri Sep 12, 2014 9:53 pm

another SOAP related dumb question... [forget - solved]

Postby 17629anand » Mon Oct 17, 2005 1:25 pm

URL should contain /service/soap/
drv = SOAP::RPC::Driver.new('https://192.168.10.191:7071/', 'urn:zimbraAdmin')

vs
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.
bhwang
Posts: 5
Joined: Fri Sep 12, 2014 9:55 pm

another SOAP related dumb question... [forget - solved]

Postby bhwang » Mon Oct 17, 2005 1:58 pm

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
#!/usr/bin/ruby

require 'soap/rpc/driver'

require 'soap/driver'

require 'soap/header/simplehandler'
class ClientAuthHeaderHandler
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 <
p drv.GetAllAdminAccountsRequest()

Return to “Administrators”

Who is online

Users browsing this forum: No registered users and 22 guests