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
  #1 (permalink)  
Old 01-14-2010, 02:47 AM
Starter Member
 
Posts: 2
Default Zimbra API's/Web service

Hi,

We are developing an system where we need to save the contacts from our portal to zimbra contacts.
Our portal is developed Ruby On Rails.
We have already developed an zimlet to save contact from Zimbra to portal through web services.

But the issues is that we don't have any api or web-services to save the contact from our portal to zimbra server.

I will be thankful if any one give us some solution over this.


Regards
Milind
Reply With Quote
  #2 (permalink)  
Old 01-14-2010, 05:43 AM
Zimbra Employee
 
Posts: 105
Default

You can use the Zimbra SOAP API from Ruby. The API documentation is currently only available as soap.txt from the source ZimbraServer/docs/soap.txt

You'll want to check the latest source, which can be obtained from our perforce server (codes.zimbra.com) or there is a bundle of the src at:

Browse Zimbra Community Builds & Projects Files on SourceForge.net

Building Zimbra using Perforce - Zimbra :: Wiki

Looks like there is a command:

<CreateContactRequest [verbose="0|1"]>
<cn [l="{folder-id}"] [t="{tags}"]>
<a>...</a>+
</cn>
</CreateContactRequest>

Also, search these forums to see if anyone has called the Zimbra SOAP API from Ruby. There might be an example...might not be of creating a contact but would be a good start.
Reply With Quote
  #3 (permalink)  
Old 01-14-2010, 06:33 AM
Special Member
 
Posts: 107
Default

To create a new distribution list, I use the attached ruby code. It based on code from Adding Appointments in Zimbra with Ruby and SOAP | Tyler Lesmann.

I use ruby 1.8.7 with soap4r 1.5.8 (gem)

The send_soap2 returns the response as a string, instead of a SOAP::Mapping:Object. The is due to a parse error of the soap4r xml parser. If the error occurs, I use REXML to parse the string myself.
Attached Files
File Type: zip ruby_zimbra_createdl.zip (1.3 KB, 27 views)

Last edited by jummo; 01-14-2010 at 06:35 AM.. Reason: insert URL
Reply With Quote
  #4 (permalink)  
Old 01-15-2010, 12:04 AM
Starter Member
 
Posts: 2
Default

hi jummo,

Thanks for the reply.
We tried the code you send as zip.

The code we changed are as below
host = 'xxx.xxxx.com'
user = 'xxx.xxx@xxx.com'
password = '****'

We are getting response as Request not allowed on port xxxx.
We tried to change the ports, but it didn't worked.

We are saving the contact to an user login not through the admin login.

Any suggestions for these.
Do we need any changes to on zimbra servers?

Regards
Milind
Reply With Quote
  #5 (permalink)  
Old 01-18-2010, 03:19 AM
Special Member
 
Posts: 107
Default

The example is for admin SOAP requests. For the non-admin SOAP requests you have to edit the zimbra.rb file.

In method send_soap and send_soap2
Code:
    url = 'https://' + host + ':7071/service/admin/soap/'
to
Code:
    url = 'https://' + host + '/service/soap/'
In mehtod self.authenticate change
Code:
      {   
        'xmlns' => 'urn:zimbraAdmin',
      },  
      [   
        element('name', name),
        element('password', password),
      ]
to
Code:
          {   
            'xmlns' => 'urn:zimbraAccount',
          },  
          [   
            element('account', name, {'by'=>"name"}),
            element('password', password),
          ]
And in the method CreateContactRequest
Code:
          {
            'xmlns' => 'urn:zimbraAdmin',
          },
to (I think it's zimbraMail, look at soap.txt in the src)
Code:
          {
            'xmlns' => 'urn:zimbraMail',
          },
Reply With Quote
  #6 (permalink)  
Old 01-21-2010, 12:41 AM
Junior Member
 
Posts: 6
Default

Hi,

Means it is possible to create contact from Ruby on rails application to zimbra server?

And what about if some one create contact into zimbra it should automatically create contact into ruby on rails application or it should give some event.

I have zimlet which is doing same but I need to do it without zimlet, since in zimlet user has to drag and drop the contact on zimlet.

I need a event of doing same. Or block user to create contact into zimbra.
Reply With Quote
  #7 (permalink)  
Old 01-26-2010, 11:52 PM
Junior Member
 
Posts: 5
Default

Hi,

When ever i try to connect zimbra from our local porta which is a ruby on rails application i always get error like "`connect': certificate verify failed (OpenSSL::SSL::SSLError)". Can someone help me on this!!

Regards,
Rohit
Reply With Quote
  #8 (permalink)  
Old 01-27-2010, 12:49 AM
Junior Member
 
Posts: 6
Default

Hi,

You can modify send_soap and send_soap2 methods,

stream = SOAP::HTTPStreamHandler.new(SOAP::Property.new)
stream.client.ssl_config.verify_mode = OpenSSL::SSL::VERIFY_NONE

Regards,
Rahul P. Chaudhari
Reply With Quote
  #9 (permalink)  
Old 01-27-2010, 10:17 PM
Junior Member
 
Posts: 6
Default

Hi,

I am able to create contact from rails application into Zimbra address book.

Now I want to know is it possible to block user from adding and modifying contact of address book from UI of zimbra mail box?

Or

Is it possible, if some one modified contact into zimbra it should be get reflected into rails application without dragging of that contact on zimlet?

Regards,
Rahul P. Chaudhari
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.