Saturday 26 January 2013

Consume Third Party Web Service in PeopleSoft


Consuming 3rd Party Web Service in PeopleSoft

In this example we will consume a 3rd party web service in our peoplesoft system. The web service we have used is a simple calculator program having four operations – Add, Subtract, Multiply & Divide.


We are on PeopleTools 8.51.15
Before performing the steps please make sure that Integration Broker is configured - Integration Broker Setup

Step 1 – Setup Node


We have to setup a node in PeopleSoft System which will communicate with the external system.
Open the existing node WSDL_NODE.






Copy the node to be used for integration.




Step 2 – Get a Public Web Service

There are many available on the net. We will use this as an example.

http://www.dneonline.com/calculator.asmx?WSDL




It is having four operations – Add, Multiply, Subtract and Divide. We will use these four operations.

Step 2 – Consume the Web Service



Navigate to PeopleTools  Integration Broker  Web Services  Consume Web Service



Check the WSDL URL radio button and enter the WSDL.





Select the Operations that you want to use.





Give some friendly message names.






Enter the new node that we have created in the first step.








Step 4 – Enter Connection Information



Again, open the node DR_WEB_SERVICE and enter the connector id and Primary URL.




The Primary URL will be - http://www.dneonline.com/calculator.asmx


Now, ping the node to confirm that the setup is correct.






Step 5 – Provide Security

Now, search for the service operations that we have created above.





Give a permission list which is assigned to your user profile.




Similarly, provide the security for other service operations.

Step 5 – PeopleCode to Use Web Service


Review the request and response message and accordingly we will create in peoplecode.
Request
<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<Add xmlns="http://tempuri.org/">
<intA>int</intA>
<intB>int</intB>
</Add>
</soap:Body>
</soap:Envelope>

Response

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<AddResponse xmlns="http://tempuri.org/">
<AddResult>int</AddResult>
</AddResponse>
</soap:Body>
</soap:Envelope>



Create a simple page –






On the FieldChange event of Calculate button write the following peoplecode. In this example we are using ADD service operation.








Click on the Calculate button.

Request




Response




Integration Broker Setup - PeopleTools 8.51


Step 1 – Activate Pub / Sub Servers


Open psadmin and make sure that the Pub/Sub Servers option is Yes in Application Server.


Step 2 – Configure Local Gateway

Click on Ping Gateway



Click on “Gateway Setup Properties”



Enter the information as shown below.



Click on Ping Node



To resolve the issue, open the node PSFT_HR.



Set Authentication option as “Password” and enter the Node Password.


Now, again go back to Gateways and ping the node.



Click on Advanced Properties.



Enter the password as password, confirm password and click on Encrypt.
Copy the encrypted password and assign it to secureFileKeystorePassword

Tuesday 8 January 2013

Captcha Implementation on PeopleSoft Sign On Page



Implementation of Captcha in PeopleSoft Sign-in Page


What is Captcha?

Captcha stands for - Completely Automated Public Turing test to tell Computers and Humans Apart.

A CAPTCHA is a program that can generate and grade tests that humans can pass but current computer programs cannot. For example, humans can read distorted text as the one shown below, but current computer programs can't:




Applications
CAPTCHAs are used to prevent automated software from performing actions which degrade the quality of service of a given system, whether due to abuse or resource expenditure. CAPTCHAs can be deployed to protect systems vulnerable to e-mail spam, such as the webmail services of Gmail, Hotmail, and Yahoo! Mail. CAPTCHAs are also used on Wikipedia for anonymous or new users who attempt to add links.

CAPTCHAs have found active use in stopping automated posting to blogs, forums and wikis, whether as a result of commercial promotion, or harassment and vandalism. CAPTCHAs also serve an important function in rate limiting, as automated usage of a service might be desirable until such usage is done in excess, and to the detriment of human users. In such a case, a CAPTCHA can enforce automated usage policies as set by the administrator when certain usage metrics exceed a given threshold. The article rating systems used by many news web sites are another example of an online facility vulnerable to manipulation by automated software.

Current PeopleSoft Authentication Process
Ø  User logs in by giving user id and password.
Ø  Sign on PeopleCode fires on clicking the sign in button.
Ø  LDAP Authentication takes place.
Ø  Accordingly the user gets logged in or gets the error message.




Proposed
Ø  Sign on page will be modified to generate Captcha image (through jsp).
Ø  User will log on into the system by giving userid, password and Captcha text.
Ø  On clicking the sign in button, first the Captcha text entered by the user will get validated (done by jsp).
Ø  If the Captcha validation is successful then only sign on PeopleCode will get fired (LDAP authentication) other wise it will not.
Thus it will secure our PeopleSoft application from bogus users/automated scripts. It means that, whenever a human being will log in into the system then only the LDAP will get hit otherwise not, since the Captcha text is readable only by a human being and not by any automated script/software.



Technology Used – JSP (Java Server Pages)
JSP (java server pages) are used to generate the Captcha image and validate the text entered by the user.
What is JSP - JavaServer Pages (JSP) is a Java technology that allows software developers to create dynamically-generated web sites, with HTML, XML, or other document types, in response to a Web client request. The technology allows Java code and certain pre-defined actions to be embedded into static content.
The JSP syntax adds additional XML-like tags, called JSP actions, to be used to invoke built-in functionality. Additionally, the technology allows for the creation of JSP tag libraries that act as extensions to the standard HTML or XML tags. Tag libraries provide a platform independent way of extending the capabilities of a Web server.
JSPs are compiled into Java Servlets by a JSP compiler. A JSP compiler may generate a servlet in Java code that is then compiled by the Java compiler, or it may generate byte code for the servlet directly. JSPs can also be interpreted on-the-fly, reducing the time taken to reload changes.



Code for Generating Captcha Image
Generatecaptcha.jsp




Logic Implemented
Ø  A random text is generated.
Ø  This text is stored in a session.
Ø  A blank image is generated.
Ø  The random text generated is written on the blank image.


Code for Validating the Captcha Text Entered by User
validate.jsp



Logic Implemented

Ø  The text stored in the current session is retrieved.
Ø  The text entered by the user is retrieved.
Ø  Both the retrieved texts are compared.
Ø  If equals then the request is forwarded to the peoplesoft servlet – psp, this servlet will now hit the signon peoplecode for LDAP authentication.
Ø  If not, then the user will directed to the signin page.

In the tag <jsp:forward page=<u can place any path(ex. Homepage or Default page etc.)> >



Changes to be made in signin.html

NOTE:
Please take the backup of signin.html before making any changed to signin.html i.e. save the signin.html file with another name. In case of any issue/problem just rename the backup of signin.html to signin.html.
Navigate to
<PS_HOME>\webserv\<DOMAIN NAME>\applications\peoplesoft\PORTAL\WEB-INF\psftdocs\ps\

Three Changes have to be made in signin.html

  1. Code to be added to timeout the session, if the signin page is opened for more than 5 minutes(this time can be changed, but it should not be too large. Ideally it should be 3-6 minutes.).This step is mandatory, as we are creating a string that is in a session it becomes mandatory to disconnect the session after some time otherwise functionality wont work properly.
Here, we have kept the timeout session as 5 min, so 300 seconds.



For this purpose we will tranfer the user to a page(transfer.html, this file should also be placed under <PS_HOME>/webserv/<DOMAIN NAME>/applications/peoplesoft/PORTAL/<DOMAIN NAME>/ps/) which will show the user session timeout information. It will also have a link to again come back to the signin page, so that a new/fresh session is created.



Code for transfer.html (Please change it as per your look n feel requirements)


2. Add one textbox in which user will enter the input and one row which will hold the image. The source of the image will be generatecaptcha.jsp


3. Change the <form action=> tag to transfer the user to validate.jsp, which will perform the validation.


Final Step

Once all the above changes have been done reboot the webserver.