Thursday, May 26, 2016

Java - XMLGregorianCalendar to java.sql.date

Refer below..


private Date toDate(XMLGregorianCalendar calendar){
        if(calendar == null) {
            return null;
        }
     
        java.util.Date dt = calendar.toGregorianCalendar().getTime();
        java.sql.Date sqlDt = new java.sql.Date(dt.getTime());
        return sqlDt;
       
    }

Sunday, April 3, 2016

Curl - Send Webservice Request thru Linux terminal

Below is step by step to test request and response on webservice.

Create a request01.xml in server.
Example command : cat > request01.xml

and then paste your xml.

<?xml version="1.0" encoding="utf-8"?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:NSS="http://tempuri.org/MyService">
   <soapenv:Header/>
   <soapenv:Body>
      <NSS:retrieveDataReq>
         <AgencyCode>123456</AgencyCode>
         <BranchCode>MyBranch011</BranchCode>
         <RequestDateTime>2016-01-18T14:35:00</RequestDateTime>
      </NSS:retrieveDataReq>
   </soapenv:Body>
</soapenv:Envelope>

Ctrl + c to exit the cat command.

Use below curl command to send the request.

curl --header "Content-Type: application/soap+xml;charset=UTF-8" --data @request01.xml http://192.168.1.20:82/webserviceName?wsdl

The response will show in terminal with the raw XML. this curl is use for test the request and response on webservice.

Java wsimport - create webservice client


mkdir C:\temp
cd C:\temp

"C:\Program Files\Java\jdk1.8.0_73\bin\wsimport" -keep http://localhost:83/yourWebservice?wsdl


Sunday, June 28, 2015

UNIX - Remove ^M

Open the file with “vi” editor and type the following:

:%s/^M//g

NOTE: To get the ^M in there, you should type CTRL+V+M

Saturday, June 13, 2015

Oracle - Show all sequence

SELECT us.sequence_name
              FROM USER_SEQUENCES us;

Oracle - Show all table name

SELECT ut.table_name
              FROM USER_TABLES ut;

Oracle - PL/SQL - Delete all table

DECLARE
BEGIN
    --Bye Tables!
  FOR i IN (SELECT ut.table_name
              FROM USER_TABLES ut) LOOP
    EXECUTE IMMEDIATE 'drop table '|| i.table_name ||' CASCADE CONSTRAINTS ';
  END LOOP;

END;