Showing posts with label Web Service. Show all posts
Showing posts with label Web Service. Show all posts

Saturday, 30 April 2016

Web Service Testing (using Client security certificate .pfx format) by using SOAP UI Tool





Please follow below steps for working with web service

Test Web Service URL = http://www.webservicex.com/currencyconvertor.asmx?WSDL
Test Client Security certificate (.pfx) = c:\test-certificate.pfx
Test Client Security certificate Password = 1234




1) create SOAP Project

- File -> New SOAP Project -> Enter Project Name -> Click ok

2) Add WSDL Link

Right Click on project -> Add Wsdl -> Enter Web Service URL -> Click ok

Ex : http://www.webservicex.com/currencyconvertor.asmx?WSDL



3) Import client Security certificate 


i) Add Certificate in Kestores

Double Click on Project -> WS-Security Configurations tab-> Keystores tab -> Click + (Add New keysore to this config) -> Select file (c:\test-certificate.pfx) -> enter password (1234) -> click ok -> The Status automatically changed to "OK" (If NOT issue in certificate).


ii) Outgoing WS-Security Configurations

- Click + (Add New Outgoing WSS Configuration) -> Enter Any name for outgoing WSS Configuration (Ex: Test_OUtgoing)-> Click "ok"

- Click + (Add new WSS Entry) -> Select Type of Entry to Add is "Signature".

- double click on "Signature" for configuration (Add below value)

Keystore = Select certificate from drop down (c:\test-certificate.pfx)
Alias = Select Alis from drop down
Password = 1234  (Test Client Security certificate Password)
Key Identifier Type = "Binary Security Token"
Signature Algorithm =
Signature canonicalization =
Digest Algorithm =
Use Single Certificate = check the checkbox


iii) incoming WS-Security Configurations

- Click + (Add New Incoming WSS Configuration) -> Enter Any name for Incoming WSS Configuration (Ex: Test_Incoming) -> Click "ok"

- Select Decrypt Keysore and Signature keystore from drop down



iv) Save all the changes



4) Add New Authorization


- Double click on "Request1" under the project
- Click "Auth" (Authentication and Security related settings) in below Request1
- Select Authorization as "Add New Authorization.."
- Select Authorization Type as "Basic"
- Select outgoing WSS = Test_OUtgoing (Which we create Outgoing WS-Security Configurations)
- Select Incoming WSS = Test_Incoming (Which we create incoming WS-Security Configurations)



5) SOAP Request

Double click on Request1 under the project and enter below mentioned code

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>AFA</web:FromCurrency>
         <web:ToCurrency>DZD</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>


And click Run (Trigger) the SOAP Request


6) SOAP Response

We are getting the below responce once we triggered the


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
         <ConversionRateResult>-1</ConversionRateResult>
      </ConversionRateResponse>
   </soap:Body>
</soap:Envelope>

Web Service Testing (With out using security certificate) by using SOAP UI Tool





Please follow below steps for working with web service

Test Web Service URL = http://www.webservicex.com/currencyconvertor.asmx?WSDL




1) create SOAP Project

- File -> New SOAP Project -> Enter Project Name -> Click ok

2) Add WSDL Link

Right Click on project -> Add Wsdl -> Enter Web Service URL -> Click ok

Ex : http://www.webservicex.com/currencyconvertor.asmx?WSDL

3) SOAP Request

Double click on Request1 under the project and enter below mentioned code

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:web="http://www.webserviceX.NET/">
   <soapenv:Header/>
   <soapenv:Body>
      <web:ConversionRate>
         <web:FromCurrency>AFA</web:FromCurrency>
         <web:ToCurrency>DZD</web:ToCurrency>
      </web:ConversionRate>
   </soapenv:Body>
</soapenv:Envelope>


And click Run (Trigger) the SOAP Request


4) SOAP Response

We are getting the below responce once we triggered the


<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <soap:Body>
      <ConversionRateResponse xmlns="http://www.webserviceX.NET/">
         <ConversionRateResult>-1</ConversionRateResult>
      </ConversionRateResponse>
   </soap:Body>
</soap:Envelope>


How to add the attribute in XML document to send the SOAP request message.



Consider below example


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/">
            <SOAP-ENV:Header/>
           <SOAP-ENV:Body xmlns:example="http://ws.cdyne.com/"  wsu:Id="id-123456789" >
               <example:VerifyEmail>
                   <example:email>mutantninja@gmail.com</example:email>
   <CDH/>
                   <example:LicenseKey>
<ABC>123</ABC>
   </example:LicenseKey>


               </example:VerifyEmail>
           </SOAP-ENV:Body>
     
</SOAP-ENV:Envelope>








 MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
 SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();

envelope.addNamespaceDeclaration("example", "http://ws.cdyne.com/");

SOAPBody soapBody = envelope.getBody();

soapBody.addNamespaceDeclaration("example", "http://ws.cdyne.com/");
//  soapBody.addAttribute(envelope.createName("wsu:Id"), "id-123456789");
   
QName attributeName = new QName("wsu:Id");
soapBody.addAttribute(attributeName, "id-123456789");
     


SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example");
SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example").addTextNode("mutantninja@gmail.com");
SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("CDH");
SOAPElement soapBodyElem3 = soapBodyElem.addChildElement("LicenseKey", "example")
SOAPElement soapBodyElem3 = soapBodyElem3.addChildElement("ABC").addTextNode("123");



MimeHeaders headers = soapMessage.getMimeHeaders();
headers.addHeader("SOAPAction", serverURI  + "VerifyEmail");
soapMessage.saveChanges();




by using above code we can add the attribute value.

How to construct the XML document by using java code to send the SOAP request




Consider below Web Service URL and XML document.


Web Service URL = http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/">
            <SOAP-ENV:Header/>
           <SOAP-ENV:Body>
               <example:VerifyEmail>
                   <example:email>mutantninja@gmail.com</example:email>
                   <example:LicenseKey>123</example:LicenseKey>
               </example:VerifyEmail>
           </SOAP-ENV:Body>
     
</SOAP-ENV:Envelope>



Code for construct the XML document by using java code to send the SOAP request


 MessageFactory messageFactory = MessageFactory.newInstance();
SOAPMessage soapMessage = messageFactory.createMessage();
 SOAPPart soapPart = soapMessage.getSOAPPart();
SOAPEnvelope envelope = soapPart.getEnvelope();

envelope.addNamespaceDeclaration("example", "http://ws.cdyne.com/");

SOAPBody soapBody = envelope.getBody();


SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example");
SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example").addTextNode("mutantninja@gmail.com");
SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("LicenseKey", "example").addTextNode("123");


MimeHeaders headers = soapMessage.getMimeHeaders();
headers.addHeader("SOAPAction", serverURI  + "VerifyEmail");
soapMessage.saveChanges();



By using above code we can construct the XML document by using java code to send the SOAP request message.


How to send the SOAP request message (Construct the XML document by using jave) to get the SOAP response message




We need to follow the below information for send the SOAP request and get the SOAP response by using below web service URL


Web Service URL = http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx



<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:example="http://ws.cdyne.com/">
            <SOAP-ENV:Header/>
           <SOAP-ENV:Body>
               <example:VerifyEmail>
                   <example:email>mutantninja@gmail.com</example:email>
                   <example:LicenseKey>123</example:LicenseKey>
               </example:VerifyEmail>
           </SOAP-ENV:Body>
     
</SOAP-ENV:Envelope>

http://stackoverflow.com/questions/19291283/soap-request-to-webservice-with-java


Code:



import javax.xml.soap.*;
import javax.xml.transform.*;
import javax.xml.transform.stream.*;

public class SOAPClientSAAJ {

    /**
     * Starting point for the SAAJ - SOAP Client Testing
     */
    public static void main(String args[]) {
        try {
            // Create SOAP Connection
            SOAPConnectionFactory soapConnectionFactory = SOAPConnectionFactory.newInstance();
            SOAPConnection soapConnection = soapConnectionFactory.createConnection();

            // Send SOAP Message to SOAP Server
            String url = "http://ws.cdyne.com/emailverify/Emailvernotestemail.asmx";
            SOAPMessage soapResponse = soapConnection.call(createSOAPRequest(), url);

            // Process the SOAP Response
            printSOAPResponse(soapResponse);

            soapConnection.close();
        } catch (Exception e) {
            System.err.println("Error occurred while sending SOAP Request to Server");
            e.printStackTrace();
        }
    }

    private static SOAPMessage createSOAPRequest() throws Exception {
        MessageFactory messageFactory = MessageFactory.newInstance();
        SOAPMessage soapMessage = messageFactory.createMessage();
        SOAPPart soapPart = soapMessage.getSOAPPart();

        String serverURI = "http://ws.cdyne.com/";

        // SOAP Envelope
        SOAPEnvelope envelope = soapPart.getEnvelope();
        envelope.addNamespaceDeclaration("example", serverURI);


        // SOAP Body
        SOAPBody soapBody = envelope.getBody();
        SOAPElement soapBodyElem = soapBody.addChildElement("VerifyEmail", "example");
        SOAPElement soapBodyElem1 = soapBodyElem.addChildElement("email", "example");
        soapBodyElem1.addTextNode("mutantninja@gmail.com");
        SOAPElement soapBodyElem2 = soapBodyElem.addChildElement("LicenseKey", "example");
        soapBodyElem2.addTextNode("123");

        MimeHeaders headers = soapMessage.getMimeHeaders();
        headers.addHeader("SOAPAction", serverURI  + "VerifyEmail");

        soapMessage.saveChanges();

        /* Print the request message */
        System.out.print("Request SOAP Message = ");
        soapMessage.writeTo(System.out);
        System.out.println();

        return soapMessage;
    }

    /**
     * Method used to print the SOAP Response
     */
    private static void printSOAPResponse(SOAPMessage soapResponse) throws Exception {
        TransformerFactory transformerFactory = TransformerFactory.newInstance();
        Transformer transformer = transformerFactory.newTransformer();
        Source sourceContent = soapResponse.getSOAPPart().getContent();
        System.out.print("\nResponse SOAP Message = ");
        StreamResult result = new StreamResult(System.out);
        transformer.transform(sourceContent, result);
    }

}



Wednesday, 9 October 2013

Difference between Batch Processing and Interactive Processing


Batch Processing - If we want to run bulk of mainframe files more than one time


The huge volume set of input file running bulk with out user interation. Those input data are saved in Mainframe files and executed by Batch Process.

The jobs are setup made up without any ineractions, The operators specify the below inforamtion correctly in batch job

1) collection of input files
2) And specify the ouput files where we get the output.

While the user submit (SUB) the job, the system Automatically takes the bulk of input data from files and prcessed and saved those result in output file without any manual interaction.



Example :


he way credit card companies process billing is a very good example of batch processing. The credit card owner does not receive a bill for each separate credit card purchase. Instead the bill is created using a batch process and the data are stored there. At the end of the month or the billing cycle, the data are collected as a batch process and the card holder gets the bill for the whole months transaction.




Interactive Processing - Here they ask the input files and ouput files information each an everytime. 


Here user give the input and submit the job and get the ouput files. we get the ouput immediately. Then user specify the some other input and submit the job and get the ouput. So the  input-output-input cycle continue still we get the expected result with user interactions.

This is called Interactive Processing


Example:


An example of an interactive processing system is where an insurance company can make changes to a customer's household insurance, e.g. while the customer is on the phone. The insurance clerk simply calls up details of the customer's policy on the screen, and types in any required changes which immediately update the customer's records. A report of the change would be automatically generated and a copy sent to the customer.

CICS Meaning


This is Transaction Server.

CICS can manage large volumes of transactions. CICS allows transactions to run concurrently at the same time serving many online users.

CICS offers ACID properties. CICS allows sharing of data and resources.

Different CICS services are exposed through a rich set of API(Application programming interface) commands.

To make Cobol program(s) interactive, we code special CICS API commands in the program. CICS programs are not very different from ordinary Cobol programs.


Transaction : 


A transaction is the basic unit-of-work in online systems. A transaction runs one or more  programs to process the data. A user types the input data on the computer screen, and presses Enter to start the transaction. The transaction invokes one or more programs to process the data right away. Immediately, the output results are displayed on the terminal and the transaction ends.

A single business-transaction(such as enrollment of a customer, retirement of an employee) may involve one or more CICS transactions.

Friday, 4 October 2013

CICS table


CICS = Customer Information Control System

CICS maintains the two table

1) PCT - Program Control Table

THe PCT contains the information about the Trans ID and name of the first program to run.

2) PPT - Processing Program Table

The PPT contains the inforamtion about the Program name and load-library address of the program.


While we entered the four digit Trans id into the CICS terminal (Web Browser), its first search the Trans ID in PCT tabel. If its find the Trans ID in PCT, then its search the Program to run in PPT table.

CICS put the Program into disk main storage to run. The Active and running instance are called Task.The output results are displayed on screen and the CICS transaction ends.

Note :

1) We should define the Program in PPT table before we use that Program
2) We should define the Trans Id in PCT tabel before we use the Trans ID.