Results 1 to 2 of 2

Thread: How to read attribute value in soap response

  1. #1
    Join Date
    Feb 2012
    Posts
    30
    Rep Power
    3

    Default [SOLVED] How to read attribute value in soap response

    Dear All,
    I am making a zimlet that can detect whether the user using which locale.
    There is a field inside SOAP request GetInfoRequest, zimbraPrefLocale
    The request can be called, but I don't know how to read the value inside the tag.
    The response structure is:
    <GetInfoResponse>
    <version>{version}</version>
    <id>{account-id}</id>
    <attrs>
    <attr name="{name}">{value}</a>
    ...
    <attr name="{name}">{value}</a>
    </attrs>
    <prefs>
    <pref name="{name}">{value}</pref>
    ...
    <pref name="{name}">{value}</pref>
    </prefs>

    I want to get the value between <pref name="zimbraPrefLocale"> and </pref>

    And the code inside the js is:
    Code:
    abc_HandlerObject.prototype.getAccountInfo =
    function(result) {
    	if (result.isException()) {
    		var exception = result.getException();		
    		alert(exception);
    		return;
    	}
    	try{
    		var response = result.getResponse().GetInfoResponse;
    		var pre = response.prefs.pref;
    
    		for (var i=0;i<pre.length;i++){
    			if (pre[i].name=="zimbraPrefLocale"){
    				alert(pre[i]);
    				break;
    			}
    		}
    	}catch(e){
    		alert(e.message);
    	}
    };
    And the result is "h is undefined"....
    I have followed the coding in http://www.zimbra.com/forums/migrati...ab-client.html

    the code from the web works in my server, but my code do not work...
    Last edited by hugo@dlshk; 04-12-2012 at 08:02 PM.

  2. #2
    Join Date
    Feb 2012
    Posts
    30
    Rep Power
    3

    Default

    finally, find the answer from http://files.zimbra.com/docs/zimlet/...ttings.js.html

    Code:
    var response = result.getResponse().GetInfoResponse;
    var a = response.prefs._attrs["zimbraPrefLocale"];
    alert(a);
    Code:
    var a = response.prefs._attrs.zimbraPrefLocale;
    if the value is in id attribute and name attribute.
    <GetInfoResponse>
    <cos id="" name=""/>
    </GetInfoResponse>
    Code:
    a = response.cos.id;
    Code:
    a = response.cos.name;
    hope that can help the beginner of zimlet like me........

Similar Threads

  1. bayes db..
    By osiris in forum Administrators
    Replies: 9
    Last Post: 06-15-2011, 11:14 AM
  2. zmzimletctl deploy zimbra_posixaccount.zip - ERROR -
    By todd_dsm in forum Administrators
    Replies: 0
    Last Post: 04-02-2009, 01:41 PM
  3. speed up the net
    By mcesari in forum Administrators
    Replies: 10
    Last Post: 04-25-2008, 11:24 AM
  4. [SOLVED] Can't receive messages from Gmail
    By agfeller in forum Administrators
    Replies: 4
    Last Post: 02-04-2008, 10:16 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •