How to use javascript to call Zimbra SOAP

Have a great idea for extending Zimbra? Share ideas, ask questions, contribute, and get feedback.
Post Reply
thutrung
Posts: 5
Joined: Sat Sep 13, 2014 2:43 am

How to use javascript to call Zimbra SOAP

Post by thutrung »

Hi,
I'm trying to learn how to use javascript to call Zimbra SOAP request as well as parse the content of the SOAP response message.Could you give me a clue about how to accomplish that,of course it would be better if you post the code here.
Any help would be appreciated,thanks.
phoenix
Ambassador
Ambassador
Posts: 27278
Joined: Fri Sep 12, 2014 9:56 pm
Location: Liverpool, England

How to use javascript to call Zimbra SOAP

Post by phoenix »

Have you read any of the documentation that's supplied with your ZCS server? site:zimbra.com +soap +consume - Yahoo! Search Results
Regards

Bill

Rspamd: A high performance spamassassin replacement

Per ardua ad astra
thutrung
Posts: 5
Joined: Sat Sep 13, 2014 2:43 am

How to use javascript to call Zimbra SOAP

Post by thutrung »

Hi Bill,thanks for your help.It really helped me.
Currently,I got a problem when trying to send a SOAP request via Java Script to Zimbra Server.I am using the jquery ajax to send SOAP request,and below is my code to check the error returned from the server:
error: function(jqXHR, exception) {

if (jqXHR.status === 0) {

alert('Not connect.
Verify Network.');

}

//something else...

}

Anytime I try to send a SOAP message to the server,i got a notification message "Not connect.Verify Network".

I just wonder if is related to SSL problems or something else that constrains the use of web services from client-side javascript.(The Zimbra server is hosted on another machine than mine,and here is the URL I used: https://server-IP:7071/zimbraAdmin/service/soap,and obviously,I can use this URL to access the server on my browser)
Please help me,thanks.
phoenix
Ambassador
Ambassador
Posts: 27278
Joined: Fri Sep 12, 2014 9:56 pm
Location: Liverpool, England

How to use javascript to call Zimbra SOAP

Post by phoenix »

Unfortunately I can't help you with any coding, I'm not a developer - you'll have to wait for someone more experienced that can give you some advice.
Regards

Bill

Rspamd: A high performance spamassassin replacement

Per ardua ad astra
thutrung
Posts: 5
Joined: Sat Sep 13, 2014 2:43 am

How to use javascript to call Zimbra SOAP

Post by thutrung »

I have read the soap.txt document in /opt/zimbra/docs, it mentioned many functions on message and conversation,but the thing is I cannot find any instruction on how to attain messageId,conversationId..Could anyone show me how can I achieve that,thanks.
10142Jignesh
Advanced member
Advanced member
Posts: 64
Joined: Sat Sep 13, 2014 2:17 am

How to use javascript to call Zimbra SOAP

Post by 10142Jignesh »

var jsonObj = {CreateFolderRequest:{_jsns:"urn:zimbraMail"}};

var request = jsonObj.CreateFolderRequest;

if(isBlank(color)){

request.folder = { name:name,view:"appointment",url:""};

}else if(custom){

request.folder = { name:name,view:"appointment",url:"",rgb:color};

}else{

request.folder = { name:name,view:"appointment",url:"",color:color};

}

var searchParams = {

jsonObj:jsonObj,

asyncMode:false

};

appCtxt.getAppController().sendRequest(searchParams);
I don't know what you want exactly but this is the example of SOAP request. Let me know your exact requirement.
roby.tea
Posts: 31
Joined: Sat Sep 13, 2014 3:18 am

How to use javascript to call Zimbra SOAP

Post by roby.tea »

Hello Jignesh
yours is an example about calling Zimbra API "inside" Zimbra... for example with a Zimlet.
What if I would like to invoke Zimbra SOAP services from outside, for example from my Intranet site...? I searched a lot over the net and read the docs, but I'm facing with a big error about CORS (Cross-origin resource sharing)...
Are there any examples on how to call such Zimbra SOAP API from "outside" Zimbra server?
Thanks

Roberto
10142Jignesh
Advanced member
Advanced member
Posts: 64
Joined: Sat Sep 13, 2014 2:17 am

How to use javascript to call Zimbra SOAP

Post by 10142Jignesh »

I am sure but you may need to write a java code to access Zimbra services from outside Zimbra. You can't achieve it from javascript only.

OTOH, Are you sure you want to do it without any authentication? You may want to use Zimbra-Preauth or something...
Post Reply