Results 1 to 9 of 9

Thread: Problem creatiing accounts via SOAPAdmin

  1. #1
    Join Date
    Oct 2005
    Posts
    6
    Rep Power
    10

    Default Problem creatiing accounts via SOAPAdmin

    Part of our eval process is making sure that I can integrate Zimbra into our current account management system, which means I need to be able to create and delete users over the network using the SOAP interface -- but (and especially since I'm new to using SOAP) I'm having a little problem there. Just to try and figure out how to talk to the server, I wrote a short bit of java code using the Apache Commons Httpclient. This is the code:

    PostMethod postMethod = new PostMethod( url );
    postMethod.setRequestContentLength(soap.length());

    postMethod.addRequestHeader("Host", "zimbra.linfield.edu");
    postMethod.addRequestHeader("Content-type", "text/xml; charset=utf-8");
    postMethod.addRequestHeader("SOAPAction","AuthRequ est");

    postMethod.setRequestBody( soap );

    try {
    int status = client.executeMethod( postMethod );
    System.out.println("Return Status Code: " + status + "\n");

    } catch (HttpException e) {
    e.printStackTrace();
    } catch (IOException e) {
    e.printStackTrace();
    }

    This is the error that's returned:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Body>
    <AuthRequest xmlns="urn:zimbraAdmin">
    <name>
    admin@zimbra.linfield.edu
    </name>
    <password>
    adin-passwd
    </password>
    </AuthRequest>
    </soap:Body>
    </soap:Envelope>


    What I get back is:

    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope"><soap:Body><soap:Fault>
    <soap:Code><soap:Value>soap:Sender</soap:Value></soap:Code><soap:Reason>
    <soap:Text>unknown document: AuthRequest</soap:Text>
    </soap:Reason><soap:Detail><Error xmlns="urn:zimbra">
    <Code>service.UNKNOWN_DOCUMENT</Code>
    <Trace> omitted </Trace>
    </Error></soap:Detail></soap:Fault></soap:Body></soap:Envelope>


    I have also tried it with a <header></header> section, and in all cases I get the same result. What am I missing?

    Thanks,

    Rob Tanner
    Linfield College

  2. #2
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    19

    Default

    You should not need this line:

    postMethod.addRequestHeader("SOAPAction","AuthRequ est");

    What is the URL you trying to POST to? It should look like:

    https://SERVER:7071/service/admin/soap

    Is this:
    Code:
    <soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Body>
    <AuthRequest xmlns="urn:zimbraAdmin">
    <name>
    admin@zimbra.linfield.edu
    </name>
    <password>
    adin-passwd
    </password>
    </AuthRequest>
    </soap:Body>
    </soap:Envelope>
    The value of 'soap' in the example code above? It should be.
    Looking for new beta users -> Co-Founder of Acompli. Previously worked at Zimbra (and Yahoo! & VMware) since 2005.

  3. #3
    Join Date
    Oct 2005
    Posts
    6
    Rep Power
    10

    Default

    Yes, the value of the variable soap was the included soap document -- sorry if I wasn't clear on that.

    I removed thd the SOAPAction header and I was going to the wrong URL -- I was going to /service/soap. I changed it to /service/admin/soap and tried again.

    When the URL is <https://zimbra.linfield.edu:7071/service/soap> I get the errors I reported in the original post.

    When the URL is <https://zimbra.linfield.edu:7071/service/admin/soap> I get an error telling me that the "Request not allowed on port 443". Where is that coming from?

    To see if somehow the simple SSL method HttpClient was the cause of the problem, I went ahead and did it the verbose way. To wit:

    ProtocolSocketFactory sf = new SSLProtocolSocketFactory();
    Protocol https = new Protocol("https", sf, 7071);
    Protocol.registerProtocol("https", https);

    HostConfiguration conf = new HostConfiguration();
    conf.setHost("zimbra.linfield.edu", 7071, https);

    PostMethod postMethod = new PostMethod();
    postMethod.setPath("/service/admin/soap");

    postMethod.setRequestContentLength(soap.length());

    postMethod.addRequestHeader("Host", "zimbra.linfield.edu");
    postMethod.addRequestHeader("Content-type",
    "text/xml; charset=utf-8");

    postMethod.setRequestBody(soap);

    int status = client.executeMethod(conf, postMethod);
    System.out.println("Return Status Code: " + status + "\n");

    If the path is set to "/service/soap" I get the original "unknown document: AuthRequest" error and if the path is set to "/service/admin/soap" I get the "Request not allowed on port 443" error. And while it is consistent, I do not understand it.

  4. #4
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    19

    Default

    Somehow it's just seeing https and using the default of 443. Try this:

    postMethod.addRequestHeader("Host", "zimbra.linfield.edu:7071");

    /service/soap will never work. We do not allow or configure the admin commands on the URI hence the unknown document/request error.
    Looking for new beta users -> Co-Founder of Acompli. Previously worked at Zimbra (and Yahoo! & VMware) since 2005.

  5. #5
    Join Date
    Oct 2005
    Posts
    6
    Rep Power
    10

    Default

    Success! Thanks.

  6. #6
    Join Date
    Aug 2005
    Location
    San Mateo, CA
    Posts
    4,789
    Rep Power
    19

    Default

    Want to share your code with others? Many have run into this and may want to borrow your solution?
    Looking for new beta users -> Co-Founder of Acompli. Previously worked at Zimbra (and Yahoo! & VMware) since 2005.

  7. #7
    Join Date
    Apr 2006
    Posts
    3
    Rep Power
    9

    Default Request not allowed on port 443

    I tried rtanner's HTTPClient (posted above) but get the "Request not allowed on port 443" response despite appending the port to the Host request header. Any other suggestions?

  8. #8
    Join Date
    Oct 2005
    Posts
    6
    Rep Power
    10

    Default

    With apologies -- I'm being pulled too many ways and hadn't gotten back.

    Anyway, here the change I made to make it work.

    This way GETS the port 443 error:
    postMethod.addRequestHeader("Host", "zimbra.linfield.edu");

    This way DOES NOT GET the port 443 error:
    postMethod.addRequestHeader("Host", "zimbra.linfield.edu:7071");

    And that's all it took. Otherwise my code is identical to my 04-19-2006 03:51 PM post. It was actually KevinH's suggestion.

    -- Rob

  9. #9
    Join Date
    Apr 2006
    Posts
    3
    Rep Power
    9

    Default Request not allowed on port 443

    Sorry if my post was unclear but I did indeed try appending the port, i.e.:

    postMethod.addRequestHeader("Host", "192.168.1.186:7071");

    However, I'm still getting the "Request not allowed on port 443" error.

    Note: If I add a second tomcat connector on port 443 it works fine.

Similar Threads

  1. Multiple Mail Accounts, Folders
    By skwdenyer in forum Users
    Replies: 12
    Last Post: 12-01-2013, 08:52 PM
  2. Replies: 59
    Last Post: 12-05-2008, 10:33 AM
  3. Zimbra, WM5.0, AS + problem with regional fonts
    By wojo2000 in forum Zimbra Mobile
    Replies: 7
    Last Post: 06-25-2007, 02:04 AM
  4. Is it started or not
    By kwelipatton in forum Installation
    Replies: 10
    Last Post: 03-28-2006, 11:11 PM

Posting Permissions

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