Results 1 to 3 of 3

Thread: SOAP problem - couldn't connect to host

  1. #1
    mmb12345 is offline Intermediate Member
    Join Date
    Jul 2007
    Posts
    18
    Rep Power
    8

    Question SOAP problem - couldn't connect to host

    Hello,

    There are many posts with SOAP difficulties.
    Mine is familiar: (7) couldn't connect to host

    The code I am using is from the forums for using PHP Curl.
    This works for some people but not for me.

    Where do I begin to troubleshoot this?
    What are the reasons that it cannot connect?
    The URL is correct because it tries to connect which means it finds the server.

    This is very frustrating because there is little action to take when the error is so vague and there is no where to find out more except on these forums.

    Any advice is appreciated.

  2. #2
    phoenix is online now Zimbra Consultant & Moderator
    Join Date
    Sep 2005
    Location
    Vannes, France
    Posts
    23,468
    Rep Power
    56

    Default

    Perhaps if you gave some examples of what you're trying to achieve, the code you're using and the exact errors you are seeing somebody might be able to offer you advice. I'll also move this to the developers forum where I believe it should be. I seem to remember that there is some documentation in the source code about soap calls although as I'm not a coder I could be wrong about that.
    Regards


    Bill


    Acompli: A new adventure for Co-Founder KevinH.

  3. #3
    mmb12345 is offline Intermediate Member
    Join Date
    Jul 2007
    Posts
    18
    Rep Power
    8

    Unhappy SOAP code : cannot connect to server

    When I run this code the browser says it is loading the page for about 3 minutes then times out with the message
    "ERROR: curl_exec - (7) couldn't connect to host ZimbraAdminCreateAccount Failed!"

    There was little information in the documentation with the source code about how to connect to the server.
    The documentation is useful for when you can connect to the Zimbra server.

    This is the code I am using that supposedly works. It is from another forum thread.

    What I need to know is how to troubleshoot the problem when the only error message is so vague.
    Is the problem with the code I am using?
    Is it a server issue?
    Is it a Zimbra issue?
    Where do I start?

    <?PHP
    $ServerAddress = "zimbra.mydomain.com";
    $AdminUserName = "";
    $AdminPassword = "";

    $NewUserName = "mynewaccount@mydomain.com";
    $NewUserPassword = "mynewpassoword";
    $COSId = "f070eede-c0c5-4867-a158-1f35f1c39e15";

    // To get your COSId for COS defualt or any other COS (I left mine in there as an example):
    // zmprov getCos default | grep "zimbraId:" from the command line

    if(($ZimbraSOAPResponse = ZimbraAdminCreateAccount(1, $ServerAddress, $AdminUserName, $AdminPassword, $NewUserName, $NewUserPassword, $COSId)) == FALSE)
    {
    printf("ZimbraAdminCreateAccount Failed!<BR>\n");
    return(FALSE);
    }

    print("Zimbra create account response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");
    ?>

    <?PHP

    // -------------------------------------------------------------------

    function ZimbraAdminCreateAccount($Trace, $ServerAddress, $AdminUserName, $AdminPassword, $NewUserName, $NewUserPassword, $COSId)
    {
    $CurlHandle = curl_init();
    curl_setopt($CurlHandle, CURLOPT_URL, "https://" . $ServerAddress . ":7071/service/admin/soap/");
    curl_setopt($CurlHandle, CURLOPT_POST, TRUE);
    curl_setopt($CurlHandle, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($CurlHandle, CURLOPT_SSL_VERIFYHOST, FALSE);

    // ------ Send the zimbraAdmin AuthRequest -----

    $SOAPMessage = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
    <context xmlns="urn:zimbra"/>
    </soap:Header>
    <soap:Body>
    <AuthRequest xmlns="urn:zimbraAdmin">
    <name>' . $AdminUserName . '</name>
    <password>' . $AdminPassword . '</password>
    </AuthRequest>
    </soap:Body>
    </soap:Envelope>';

    curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

    if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
    {
    print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
    return(FALSE);
    }

    print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

    // Parse for the sessionId
    // <sessionId type="admin" id="123">123</sessionId>
    $sessionId = strstr($ZimbraSOAPResponse, "<sessionId");
    $sessionId = strstr($sessionId, ">");
    $sessionId = substr($sessionId, 1, strpos($sessionId, "<") - 1);
    print("sessionId = $sessionId<BR>\n");

    // Parse for the authToken
    // <authToken>123</authToken>
    $authToken = strstr($ZimbraSOAPResponse, "<authToken");
    $authToken = strstr($authToken, ">");
    $authToken = substr($authToken, 1, strpos($authToken, "<") - 1);
    print("authToken = $authToken<BR>\n");

    // ------ Send the zimbraCreateAccount request -----
    $SOAPMessage = '<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope">
    <soap:Header>
    <context xmlns="urn:zimbra">
    <authToken>' . $authToken . '</authToken>
    <sessionId id="' . $sessionId . '">' . $sessionId . '</sessionId>
    </context>
    </soap:Header>
    <soap:Body>
    <CreateAccountRequest xmlns="urn:zimbraAdmin">
    <name>' . $NewUserName . '</name>
    <password>' . $NewUserPassword . '</password>
    <a n="zimbraCOSId">' . $COSId . '</a>
    </CreateAccountRequest>
    </soap:Body>
    </soap:Envelope>';

    curl_setopt($CurlHandle, CURLOPT_POSTFIELDS, $SOAPMessage);

    if(!($ZimbraSOAPResponse = curl_exec($CurlHandle)))
    {
    print("ERROR: curl_exec - (" . curl_errno($CurlHandle) . ") " . curl_error($CurlHandle));
    return(FALSE);
    }

    // print("Raw Zimbra SOAP Response:<BR>" . htmlentities($ZimbraSOAPResponse) . "<BR><BR>\n");

    return($ZimbraSOAPResponse);
    }
    ?>

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. zmclamdctl is not running after upgrade
    By Darren in forum Installation
    Replies: 24
    Last Post: 10-10-2008, 09:10 AM
  2. Zimbra fails after working for 2 weeks
    By Linsys in forum Administrators
    Replies: 10
    Last Post: 10-07-2008, 12:42 AM
  3. [SOLVED] Upgraded to 5.0 OSS - Sendmail Problem
    By Chewie71 in forum Installation
    Replies: 11
    Last Post: 12-28-2007, 07:07 PM
  4. Is it started or not
    By kwelipatton in forum Installation
    Replies: 10
    Last Post: 03-28-2006, 11:11 PM
  5. Can't send or receive mails from Zimbra
    By ppurama in forum Administrators
    Replies: 4
    Last Post: 11-14-2005, 10:17 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
  •