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