#!/usr/bin/perl # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file distributed with # this work for additional information regarding copyright ownership. # The ASF licenses this file to You under the Apache License, Version 2.0 # (the "License"); you may not use this file except in compliance with # the License. You may obtain a copy of the License at # # http://www.apache.org/licenses/LICENSE-2.0 # # Unless required by applicable law or agreed to in writing, software # distributed under the License is distributed on an "AS IS" BASIS, # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. # See the License for the specific language governing permissions and # limitations under the License. use CGI qw/:standard/; use WSO2::WSF; use XML::LibXML; my $q = new CGI; my $WSFC_HOME='/opt/wso2/wsf_c/'; # get the endpoitn from the configuration service sub get_endpoint { $config_endpoint = $q->cookie('endpoint'); $input_xml = < PERL_CLIENT XML my $client = new WSO2::WSF::WSClient( { 'to' => $config_endpoint, 'log_file' => '/tmp/stocktrader.log', 'log_level' => 4, 'wsfc_home' => $WSFC_HOME }/opt/wso2/wsf_c/client->request( { 'payload' => $input_xml } ); my $response_str = $response_msg->{str}; my $response_parser = XML::LibXML->new(); $response_xml = $response_parser->parse_string($response_str); my $xpc = XML::LibXML::XPathContext->new($response_xml); $xpc->registerNs('ns'=> 'http://wso2.org/interop/stocktrader/xsd'); $bs = $xpc->findvalue('//ns:BS'); return $bs; } # register user sub RegisterUser { my($userID) = shift; my($password) = shift; my($fullname ) = shift; my($address) = shift; my($email) = shift; my($creditcard) = shift; my($openBalance) = shift; my $register_request =< ${userID} ${password} ${fullname}
${address}
${email} ${creditcard} ${openBalance} EOF my $tmp_endpoint = get_endpoint(); my $client = new WSO2::WSF::WSClient( { 'to' => $tmp_endpoint, 'log_file' => '/tmp/stocktrader.log', 'log_level' => 4, 'wsfc_home' => $WSFC_HOME } ); $response = $client->request( { 'payload' => $register_request } ); $response_str = $response->{str}; # $response_str = < # # # #XML return $response_str; } print $q->header(); if ($q->param('REGISTERUSER')) { # New user registration $userID = $q->param('REQUESTEDID'); $openBalance = $q->param('OPENBALANCE'); $fullname = $q->param('FULLNAME'); $email = $q->param('EMAIL'); $address = $q->param('ADDRESS'); $password = $q->param('PASSWORD'); $creditcard = $q->param('CREDITCARD'); $confpassword = $q->param('CONFIRMATIONPASSWORD'); $invalidInformation = 0; if (!$userID || $password != $confpassword) { $invalidInformation = 1; } else { $response = RegisterUser($userID, $password, $fullname, $address, $email, $creditcard, $openBalance); if ($response) { $successfulRegistration = 1; } else { $invalidInformation = 1; } } } print < WSF/PHP StockTrader Welcome

Register

HTML_CODE if ($successfulRegistration) { print("

Registration was successful, please login.

"); } else { if ($invalidInformation) { print("

Please enter valid information.

"); } print ("
Create Account Profile:
 
Requested ID: Opening Balance:
Full Name: Email Address:
Address: Password:
Credit Card: Confirm Password:
"); } print <
HTML_CODE