1. Please take a little time for this simple survey! Thank you for participating!
    Dismiss Notice
  2. Dear Pleskians, please read this carefully! New attachments and other rules Thank you!
    Dismiss Notice
  3. Dear Pleskians, I really hope that you will share your opinion in this Special topic for chatter about Plesk in the Clouds. Thank you!
    Dismiss Notice

Expand API via webgate.php problem

Discussion in 'Plesk Expand 2.2 Troubleshooting Issues' started by WaDavid, Jan 9, 2008.

  1. WaDavid

    WaDavid Guest

    0
     
    We have am automated process, when a client signs up on our website for hosting, a process automatically creates the hosting for the client on one of our plesk servers via expand. This is by sending xml via https://expandserver:8442/webgate.php or in our case we moved the service to port 443 instead.

    Now this used to work all very well with Expand 2.1.2 which used apache to serve the expand control panel. We however upgraded our expand server early this year/month to version 2.2.2 which now uses the swsoft control panel server. From what I can tell this is a modified version of lighthttpd.

    Now the problem:
    Our automated system is not working anymore, when we make the connection to the expand server to send the xml, we get a response back from the server: HTTP Error 417 Expectation failed

    Is there something specific we need to change to get this to work again?

    The connection to the expand server is made from a windows 2003 server with IIS and asp.net if that could supply any tips on why we have this problem.
     
  2. Sergey L

    Sergey L Golden Pleskian Staff Member

    32
    43%
    Joined:
    Aug 10, 2006
    Messages:
    1,195
    Likes Received:
    30
    Hello, that is a problem in incorrect handling of 'Expect: 100-continue' header automatically added to HTML request by cURL 7.14 and higher. The solution would be in explicit speicification of empty 'Expect:' header like it is in the sample below:
    PHP:
    <?php

    $data 
    =<<<EOF
    <packet version="0.6.4.1">
            <person>
                    <get>
                            <filter>
                                    <id>1</id>
                            </filter>
                    </get>
            </person>
    </packet>
    EOF;

    function 
    write_callback($ch$data) {
            echo 
    $data;
            return 
    strlen($data);
    }

    class 
    Test{

    function 
    sendCommand() {
            
    $url "https://your.expand.com:8442/webgate.php";
            
    $pass "setup";
            
    $login "root@expand.com";

            
    $headers = array(
                    
    "HTTP_AUTH_OP: exp_expand_config",
                    
    "HTTP_AUTH_LOGIN: $login",
                    
    "HTTP_AUTH_PASSWD: $pass",
                    
    "Expect:",
                    
    "Content-Type: text/xml",
            );

            
    // Initalize the curl engine
            
    $ch curl_init();

            
    // Set the curl options
            
    curl_setopt($chCURLOPT_SSL_VERIFYHOST,  2);
            
    // this line makes it work under https
            
    curl_setopt($chCURLOPT_SSL_VERIFYPEERFALSE);
            
    curl_setopt($chCURLOPT_HTTPHEADER, &$headers);

            
    // Set the URL to be processed
            
    curl_setopt($chCURLOPT_URL$url);

            
    // Set the callback functions
            
    curl_setopt($chCURLOPT_WRITEFUNCTIONwrite_callback);

            
    // Set the data to be send
            
    global $data;
            
    curl_setopt($chCURLOPT_POSTFIELDS$data);

            
    // Debug, however...
            
    curl_setopt($chCURLOPT_VERBOSE1);

            
    $result curl_exec($ch);

            
    //print_r(curl_getinfo($ch));
            
    echo "\n\n-------------------------\ncURL error number:"
    .curl_errno($ch);
            echo 
    "\n\ncURL error:" curl_error($ch);

            
    curl_close($ch);
            return;
    }
    }

    $o = new Test();
    $o->sendCommand();

    ?>
    Regards
     
  3. WaDavid

    WaDavid Guest

    0
     
    Thank you, that is exactly what we needed to fix. Except the .NET framework always send out a Expect: 100-continue Header. We found our fix on http://haacked.com/archive/2004/05/15/http-web-request-expect-100-continue.aspx

    The fix for us was to set the Expect100Continue property of the System.Net.ServicePointManager class to false.

    Our automated system can now communicate with expand again, once we have updated our xml input.
     
Loading...