Work at SourceForge, help us to make it a better place! We have an immediate need for a Support Technician in our San Francisco or Denver office.

Close

HTTP Error: Couldn't open socket connection

Help
2010-07-07
2013-06-06
  • kaushik asokan
    kaushik asokan
    2010-07-07

    Hello,

    I am running my application in a linux server. You can check the configuration using the URL: http://www.kwa.kerala.gov.in/online_payment/test.php. I am using a web service to connect to a java web service for logging in . The URL of the java web service is "http://210.212.24.56:8080/OnlinePaymentService/services/BillDeskService". Thats also working fine. When I am check that URL through a browser I am getting the desired results. I am using nusoap version 0.7.3.

    The code I am using is as follows:

    <?php
    /**********************************************************************
    * This script is for signing in to the Kerala Water Authority Network *
    * In the back end we are connecting to a web service written in java *
    * Users have to enter their consumer id and password(if they are  *
    * already registered) for signing in.                              *
    *                                                                    *
    * Author: Kaushik.M                                                   *
    * Createad On: 24/06/2010                                             *
    *                                                                   *
    *********************************************************************/
    // Start the session
    session_start();

    // Include the includes page
    require_once 'lib/config.php';

    // Include the nusoap library
    require_once 'lib/nusoap.php';

    // DON'T CACHE the SOAP on the PHP server
    $ini = ini_set("soap.wsdl_cache_enabled","0");

    // Flag for checking all data is enterd OK
    $all_data_ok = true;

    // If the consumer id field is entered
    if(isset($_POST)) {

    // Retrive the consumer id from the POST element
    $cons_id = trim($_POST);

    // INITIALIZATIONS //
    /******************/

    // Set the consumer id error flag
    $cons_id_error = false;
    // Initialize the error string
    $cons_id_error_string = "";
    // initialize the style flag
    $cons_id_error_style = "";

    // VALIDATIONS  //
    //**************/

    // (1)If the entered consumer id is null
    if($cons_id == "") {
    $cons_id_error = true;
    $cons_id_error_style = "background-color: #FFEBEB;";
    $cons_id_error_string = "This field is required";
    } else if(!preg_match('/^{9}$/',$cons_id)) { // If the entered consumer id is not matching our pattern
    $cons_id_error = true;
    $cons_id_error_style = "background-color: #FFEBEB;";
    $cons_id_error_string = "Please enter a valid Consumer ID";
    }
    // If there is error in consumer id entry set global flag to false
    if($cons_id_error)
    $all_data_ok = false;
    } else { // If no consumer id is entered set the global error flag to false
    $all_data_ok = false;
    }

    // If the user has enterd password
    if(isset($_POST)) {

    // Retrieve the password from POST element
    $passwd = trim($_POST);

    //  INITIALIZATIONS //
    //*****************//

    // Set the password error flag
    $passwd_error = false;
    // Initialize the error string
    $passwd_error_string = "";
    // Initialize error style
    $passwd_error_style = "";

    // VALIDATIONS //
    //************//

    // (1) If the password length is 0
    if($passwd == "") {
    $passwd_error = true;
    $passwd_error_string = "This field is required";
    $passwd_error_style = "background-color: #FFEBEB;";
    }
    // (2) If the password length is less than 5 characters
    else if(strlen($passwd) < 5) {
    $passwd_error = true;
    $passwd_error_string = "Password should contain at least 5 characters";
    $passwd_error_style = "background-color: #FFEBEB;";
    }
    // If there is error in password entry set global flag to false
    if($passwd_error)
    $all_data_ok = false;
    } else { // If no password is entered set the global flag to false
    $all_data_ok = false;
    }

    // If data entered is OK
    if($all_data_ok) {

    // Don't cache the SOAP on the PHP server
    $ini = ini_set("soap.wsdl_cache_enabled","0");

    // Initialize the error string
    //$error_string = "";

    try {
    // Create soap client for connecting to the java web service
    //$soapClient = new SoapClient(SOAP_ONLINE_CONSUMERS."?wsdl");
    $soapClient = new nusoap_client(SOAP_ONLINE_CONSUMERS);
    // Create params for soap
    $params = array (
    'userId' => $cons_id,
    'passWd' => $passwd
    );
    // Retrieve results
    $results = $soapClient->call("loginUser",$params);
                    echo $soapClient->getError();
    } catch (soap_fault $e) {
    echo $e;
    }

    // VALIDATIONS BASED ON THE RESULTS FROM WEB SERVICE //
    //**************************************************//

    // (1) If there is no such consumer as user entered
    if($results == "no such consumer id") {
    $cons_id_error = true;
    $cons_id_error_string = "Please Register.";

    // (2) If Incorrect password is entered
    } else if($results == "Incorrect password entered.") {
    $passwd_error = true;
    $passwd_error_string = "Password incorrect";

    // (3) If all data is ok, log in the user
    } else if($results == "You are successfuly logged in") {
    // Disable caching
       header( "Expires: Mon, 20 Dec 1998 01:00:00 GMT" );
        header( "Last-Modified: " . gmdate("D, d M Y H:i:s") . " GMT" );
        header( "Cache-Control: no-cache, must-revalidate" );
            header( "Pragma: no-cache" );

            // set consumer id to session
            $_SESSION = $cons_id;
           
            //  Go to the registration successful page.
    header('Location: ' . HOME_PAGE);
    }
    }
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
    <html>
    <head>
    <title>Kerala Water Authority - Login</title>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">

    <script type="text/javascript" src="include/js/jquery-1.4.2.js"></script>
    <script type="text/javascript" src="include/js/jquery.validate.js"></script>
    <script type="text/javascript" src="include/js/jquery.metadata.js"></script>
    <link rel="stylesheet" type="text/css" href="include/css/login.css">
    <style type="text/css">

    #inputs input.error { background-color: #FFEBEB;} ;

    </style>
    <script type="text/javascript">

    // Method for checking consumer id
    $.validator.addMethod("cons_id", function(cons_id) {
    // Remove spaces
    cons_id = cons_id.replace(/\s+/g, "");
    // Check whether the consumer id contains 10 digits
    if(cons_id.match(/^{1,9}$/)) {
    return true;
    }
    return false;
    }, "Please enter a valid digit");
    $(document).ready(function () {

    // validate the form when it is submitted
    var validator = $("#loginForm").validate({
    rules: {
    cons_id: {
    required: true,
    cons_id: true,
    minlength: 10,
    maxlength: 10
    //remote: 'lib/cons_id.php'
    },
    passwd: {
    required: true,
    minlength: 5
    }
    },
    messages: {
    cons_id: {
    required: "This field is required",
    cons_id: "Please enter a valid Consumer ID",
    minlength:  jQuery.format("Enter at least {0} characters"),
    maxlength:  jQuery.format("Maximum {0} characters")
    //remote: "Consumer ID is invalid"
    },
    passwd: {
    required: "This field is required",
    minlength: jQuery.format("Enter at least {0} characters")
    }
    },
    onkeyup: false
    });
    });
    </script>
    </head>

    <body bgcolor="#3176B3">
    <table border="0" align="right" width="100%">
    <tr>
    <td width="70%" align="center">
    <font style="arial" size="6" color="#FFFFFF">Kerala Water Authority e-Payment Service</font>
    <object width="100%" height="100">
                      <param name="movie" value="lake3.swf"/>
                      <embed src="include/images/lake3.swf" width="100%" height="350"/>
                    </object>
    </td>
    <td align="center">
    <div id="yreglg">
    <div class="top yregbx">
    <div class="yregbxi">
    <div class=" badge">
    <h2>Sign in to KWA</h2>
    <fieldset id="fslogin" class="clear">
    <legend>Login Form</legend>
    <form name="loginForm" id="loginForm" method="post" action="<?php echo $_SERVER; ?>">
    <div id="inputs">
    <div class="container">
    <label>Consumer ID</label>
    <input type="text" id="cons_id" name="cons_id" style="<?php echo $cons_id_error_style; ?>" maxlength="10" tabindex="1">
    <?php
    // If the entered consumer id is incorrect display the error
    if(true == $cons_id_error) {
    ?>
    <label class="error"><?php echo $cons_id_error_string; ?></label>
    <?php
    }
    ?>
    <p>&nbsp;</p>
    <label>Password</label>
    <input type="password" id="passwd" name="passwd" style="<?php echo $passwd_error_style; ?>" maxlength="64" tabindex="2">
    <?php
    // If the entered password is incorrect display the error string
    if($passwd_error == true) {
    ?>
    <label class="error"><?php echo $passwd_error_string; ?></label>
    <?php
    }
    ?>
    </div>
    </div>
    <div id="fun"> </div>
    <div id="submit">
    <button type="submit" name="submit" id=".save" class="primaryCta" tabindex="3">Sign In</button>
    <p>&nbsp;</p>
    </div>
       </form>
    </fieldset>
    <DIV id="fc1">
    <DIV id="fcue_c1" class="yui-panel-container fcue-yellow">
      <DIV id="fcue1" class="yui-module yui-overlay yui-panel fcue-outer fcue-small">
    <DIV class="fcue-inner">
      <DIV class="fcue-t"></DIV>
      <DIV id="fcue-bd" class="fcue-content">
    <DIV class="hd">CAPS LOCK is On</DIV>
    <DIV class="bd">
      <P>Password is case sensitive</P>
    </DIV>
      </DIV>
    </DIV>
    <DIV class="fcue-b">
      <DIV></DIV>
    </DIV>
    <DIV class="fcue-pnt fcue-pnt-r"></DIV>
      </DIV>
    </DIV>
      </DIV>
       <DIV id="help"> <A href="#">I forgot my password</A> &nbsp;&nbsp;|&nbsp;&nbsp;<A href="#">Help</A>
      </DIV>
    </DIV>
    <DIV id="lisu">
      <DIV id="yregmain">
    <H3>New user?</H3>
    <A class="secondaryCta" href="<?php echo REGISTRATION_PAGE; ?>">Create New Account</A> </DIV>
    </DIV>
    </div>
    </div>
    </div>
    </div>
    </td>
    </tr>
    </table>
    </body>
    </html>

    But when I try to login using user name and password I am getting the following error:

    HTTP Error: Couldn't open socket connection to server http://210.212.24.56:8080/OnlinePaymentService/services/BillDeskService, Error (111): Connection refused

    As our need is so urgent that I have to find a solution till tomorrow. I request you people to give me a solution ASAP