Showing posts with label webservices. Show all posts
Showing posts with label webservices. Show all posts

June 17, 2016

Swagger - RESTful API Documentation Specification

Swagger : The goal of Swagger is to define a standard, language-agnostic interface to REST APIs which allows both humans and computers to discover and understand the capabilities of the service without access to source code, documentation, or through network traffic inspection.

Swagger is a formal specification surrounded by a large ecosystem of tools, which includes everything from front-end user interfaces, low-level code libraries and commercial API management solutions.

Swagger api: https://github.com/swagger-api/swagger.io/blob/wordpress//tools/index.md

Swagger integration on web application example: http://www.3pillarglobal.com/insights/restful-api-documentation-using-swagger-and-spring-mvc

Ref: http://swagger.io
Read more ...

Online test web application deployment environment (Openshift, Interserver) and Online project workspace (Codenvy)

Codenvy makes on-demand workspaces to give you a better agile experience. Codenvy SaaS is available for self-service at codenvy.com. You can also install Codenvy on your own infrastructure with Codenvy On-Prem. Ref: http://codenvy.readme.io/docs/release-notes

Online test web application deployment environment are :Openshift , Interserver

Read more ...

January 12, 2015

Exception “Received fatal alert: handshake_failure” while sending a request through java code or Error response: 401 java.io.IOException: Server returned HTTP response code: 401 for URL:

Issue:
1 .Exception “Received fatal alert: handshake_failure” while sending a request through java code or  
2 .Error orresponse: 401 java.io.IOException: Server returned HTTP response code: 401 for URL:
3. Exception in thread "main" javax.net.ssl.SSLHandshakeException: Received fatal alert: handshake_failure
4.Same url is working successfully in browser, but it’s not working through java program.

Solutions for all above issues for this program, please try and post your comments.
import java.io.BufferedReader;
import java.io.InputStreamReader;
import org.apache.http.HttpResponse;
import org.apache.http.HttpStatus;
import org.apache.http.auth.AuthScope;
import org.apache.http.auth.UsernamePasswordCredentials;
import org.apache.http.client.CredentialsProvider;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.impl.client.BasicCredentialsProvider;
import org.apache.http.impl.client.HttpClientBuilder;
/**
 * A simple example that uses HttpClient to perform a GET using Basic
 * Authentication. Can be run standalone without parameters. 
 * You need to have JSSE on your classpath for JDK prior to 1.4
 * 
 * @author Myjavacafe
 */
 public class BasicHttpsAuthTest {
  
  /**
  * Constructor for BasicHttpsAuthTest.
  */
  public BasicHttpsAuthTest() {
   super();
  }
  public static void main(String[] args) throws Exception {
 String URL_SECURED_BY_BASIC_AUTHENTICATION = "https://<host>:<port&tt;/<etc...>";
    CredentialsProvider provider = new BasicCredentialsProvider();
    UsernamePasswordCredentials credentials = new UsernamePasswordCredentials(<userNaem>,<Passwrod> );
    provider.setCredentials(AuthScope.ANY, credentials);
    HttpClient client = HttpClientBuilder.create().setDefaultCredentialsProvider(provider).build();
   HttpResponse response = client.execute(new HttpGet(URL_SECURED_BY_BASIC_AUTHENTICATION));
    System.out.println("Response Code :"+ response.getStatusLine().getStatusCode());
    int statusCode = response.getStatusLine().getStatusCode();
    if (statusCode != 200) {
  throw new RuntimeException("Failed : HTTP error code : "+ response.getStatusLine().getStatusCode());
    }
    BufferedReader br = new BufferedReader(new InputStreamReader((response.getEntity().getContent())));
    String output;
    while ((output = br.readLine()) != null) {
     System.out.println("Response :" + output);
    }
    br.close();//If not mentioned - "Client connection failed" warnings from HornetQ in JBoss EAP
  }
}
Read more ...

May 13, 2014

Sending mail Using JavaMail

To sending email using Mime Message, Message, Session, Transport, XXXException import from javax.mail package. Those classes contains below jars:

j2ee.jar or (mail.jar and activation.jar)

If using j2ee.jar , you may get error : NoClassDefFoundError.

Exception in thread "main" java.lang.NoClassDefFoundError: javax/mail/Address

So, we need import mail.jar and activation.jar files, then NoClassDefFoundError error resolve automatically.

Send an email message, an application prepares a MimeMessage object, then sends it with the static method send() on the Transport class in javax.mail package. The message is created using a JavaMail Session object. The Session and the Transport work with the Application Engine Mail service without any additional configuration to this method.


import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

//..

private static void sendMail(){

       
Properties props = new Properties();
        String smtpHost = "smtp.corp.anthem.com";
                    props.put("mail.imaps.partialfetch", "false");
                    props.put("mail.smtp.host", smtpHost);
        Session session = Session.getInstance(props, null); or Session.getDefaultInstance(props, null);
       
String msgBody = "...";

       
try {
           
Message msg = new MimeMessage(session);
            msg
.setFrom(new InternetAddress("fromTeam@example.com", "XXX@XMail.com Admin"));
            msg
.addRecipient(Message.RecipientType.TO,
                             
new InternetAddress("enduser@example.com", "Mr. EndUser"));
            msg
.setSubject("Your XXX  account has been activated");
            msg
.setText(msgBody);
           
Transport.send(msg);

       
} catch (AddressException e) {
           
// ...
       
} catch (MessagingException e) {
           
// ...
       
}
}


if you want more information mail parameters, please visit below web page:
JavaMail


Read more ...

February 19, 2014

Context: Issue while running in debug mode on eclipse IDE using application server-- ‘JVM debug port 7777 is in use’ popup issue

IBM Rational Application Developer (RAD) is basically a typically IBM heavy version ofEclipse WebSphere is a typically IBM heavy version of a J2EE server.  Therefore you would think you could debug web applications using  Eclipse.
However I could not find anyone on my latest project who knew how to do this.  Fortunately after much Googling I found this PDF document, Debugging Applications in IBM Rational Application Developer, and on page 12 are instructions on how to do this.

The instructions seem to be a little out of date so here are my instructions.
1.      Log into your Integrated Solutions Console.  The default URL ishttp://localhost:9060/ibm/console/login.do.
2.      Navigate using the left side column to Servers –> Application Servers.
3.      Select the Application server you want to debug from the list of Application servers.
4.      Under the Configuration tab select the Debugging Service link which is near the bottom right in the Additional Properties section.
5.      Select the “Enable service at server startup” checkbox.  Note the JVM debug port.

6.      Press the Apply button.
7.      In the Messages box, which appeared at the top after pressing the Apply button, click on the Save link.
8.      Stop and start your Application Server.  It should now be running in Debug mode.
9.      In RAD go to the project for the web application you want to debug.
10.  From the menu select Run –> Debug Configurations.
11.  Select Remote Java Application and press the New button (it’s the top left button).  For the port set it to the JVM debug port (default is 7777).
12.  Press Apply.  Then press Debug.  It should connect to WebSphere’s JVM.
Now you can set breakpoints and even change small amounts of code which will be deployed automatically to WebSphere.  No more waiting 15 minutes to test every change you make because builds are so brutally long. 


Read more ...

August 14, 2012

Difference between Web Server and Application Server...

Most of the times these terms Web Server and Application server are used interchangeably.
Following are some of the key differences in features of Web Server and Application Server:
  • Web Server is designed to serve HTTP Content. App Server can also serve HTTP Content but is not limited to just HTTP. It can be provided other protocol support such as RMI/RPC
  • Web Server is mostly designed to serve static content. Though most of the Web Servers are having plugins to support scripting languages like Perl, PHP, ASP, JSP etc. through which these servers can generate dynamic HTTP content.
  • Most of the application servers have Web Server as integral part of them, that means App Server can do whatever Web Server is capable of. Additionally App Server have components and features to support Application level services such as Connection Pooling, Object Pooling, Transaction Support, Messaging services etc.
  • As web servers are well suited for static content and app servers for dynamic content, most of the production environments have web server acting as reverse proxy to app server. That means while service a page request, static contents such as images/Static html is served by web server that interprets the request. Using some kind of filtering technique (mostly extension of requested resource) web server identifies dynamic content request and transparently forwards to app server
Example of such configuration is Apache HTTP Server and BEA WebLogic Server. Apache HTTP Server is Web Server and BEA WebLogic is Application Server.
In some cases the servers are tightly integrated such as IIS and .NET Runtime. IIS is web server. when equipped with .NET runtime environment IIS is capable of providing application services.
Read more ...

March 17, 2011

Web Service. IWAB0506E Error when copying Axis jar files to web project.

IWAB0506E Error when copying Axis jar files to web project
java.io.FileNotFoundException: /lib/saaj.jar
at org.eclipse.osgi.framework.internal.protocol.bundleentry.Handler.findBundleEntry(Handler.java:44)

1. Go to STS installation directory.
2. Open Plugins folder.

There you can find a bundle
javax.xml.soap_1.2.0.v201005080501 and javax.xml.soap_1.3.0.v201005080502.jar file.

3. Delete the javax.xml.soap_1.3.0.*****.jar file

Restart the sts. Now it will work.
Read more ...

January 16, 2011

Difference Between Application Servers & Web Servers

Difference Between Application Servers & Web Servers

A Web Server transmits Web pages to the browsers, and the Application Server performs business logic or data processing to the application programs.
Web Server
Web Server handles HyperText Transfer Protocol, or HTTP, which is responsible for website functionality.
Application Server
Application Server exposes business logic to the client-side applications, such as Graphical User Interface or GUI running on your computer.
Fact
Web Server is responsible for HTML or HyperText Markup Language display on the Web browser, whereas the application server allows access to the business code with the help of a method or function.
Resources
Application Server has the capability of handling its resources such as security, connection pooling, transactions and messaging, whereas Web server may not support these functionalities.
Insight
With the help of Extensible Markup Language or XML web services, a Web Server can process data as the Application Server.
Read more ...

My Favorite Site's List

#update below script more than 500 posts