1
Invoking SecurePay
  • public String invokeCreditCardValidationService(HttpSession session) throws Exception
    {
    String sHtmlResponse = "";
    String encryptedFile = "C:\\Program Files\\Apache Group\\jakarta-tomcat-4.1.27\\webapps\\cs554project\\WEB-INF\\encryptedpaymentfile.xml";
    String urlString = "http://localhost:7001/cs5890project/servlet/rpcrouter"; //SecurePay web service is running at this URL
    String returnedString = "";

    try
    {
    BufferedReader in = new BufferedReader(new FileReader(encryptedFile)); //encrypted file is converted to a StringBuffer
    String str = null;
    StringBuffer stringBuffer = new StringBuffer();

    while ((str = in.readLine()) != null)
    {
    stringBuffer.append(str+"\n");
    }

    //build a Call object
    Call call = new Call();
    call.setTargetObjectURI("urn:creditCardValidatorService"); //name of the webservice
    call.setMethodName("validateCreditCard"); //name of the method
    call.setEncodingStyleURI(Constants.NS_URI_SOAP_ENC);

    //creating a parameter list
    Vector params = new Vector();
    params.addElement(new Parameter("name", String.class, stringBuffer, null));

    //adding the parameter(s) to the Call object
    call.setParams(params);

    System.out.println("urlString is " + urlString);

    //invoke the soap method
    Response res = call.invoke(new URL(urlString), "");

    //if there is no fault in the method invocation, get the result

    if( res.generatedFault() ==false)
    {
    Parameter retValue = res.getReturnValue();
    Object value = retValue.getValue();
    returnedString = value.toString();
    }
    else
    {
    returnedString = res.getFault().getFaultString();
    System.out.println("The fault is: "+res.getFault().getFaultString());
    }

    System.out.println("returnedString is " + returnedString);

    return returnedString;
    }

    catch(Exception e)
    {
    e.printStackTrace();
    throw e;
    }


    }
  • Apache's XML RPC implementation is used.
  • What's is XML RPC ?. It's remote procedure calling using HTTP as the transport and XML as the encoding. XML-RPC is designed to be as simple as possible, while allowing complex data structures to be transmitted, processed and returned.



  •