Articles for the ‘Web Services’ Category

Testing OpenAPI / Swagger Schema Compliance with Java, JUnit and assertj-swagger

Friday, August 31st, 2018

The OpenAPI and Swagger API description format are becoming important standards to specify API contracts for RESTful web services and the Microservices trend pushes the need for such contracts even further.

Therefore arises the need for software architects, testers and developers to write tests to verify if an exposed API follows such a specified contract.

In the following tutorial I will demonstrate a setup with Java, Maven, JUnit and the designated contract-testing-library, assertj-swagger that verifies the validity of such a contract exposed by a Spring Boot application against a local stored definition.

(more…)

Writing BDD-Style Webservice Tests with Karate and Java

Thursday, April 6th, 2017

There is a new testing framework out there called Karate that is build on top of the popular Cucumber framework.

Karate makes it easy to script interactions with out web-services under test and verify the results. In addition it offers us a lot of useful features like parallelization, script/feature re-use, data-tables, JsonPath and XPath support, gherkin syntax, switchable staging-configurations and many others.

In the following tutorial we’ll be writing different scenarios and features for a real-world RESTful web-service to demonstrate some of its features.

(more…)

Creating REST Clients for JAX-RS based Webservices with Netflix Feign

Thursday, October 22nd, 2015

For us developers there plenty of libraries exist helping us in deriving and generating clients for existing RESTful web-services and I have already covered some of the in this blog (e.g. the JAX-RS Client API). Nevertheless, I’d like to share my experience with another interesting lightweight library here: Netflix Feign.

Feign offers a nice fluent-builder API, a rich integration for  common libraries and APIs like JAX-RS, Jackson, GSON, SAX, JAX-B, OkHttp, Ribbon, Hystrix, SLF4J and more and last bot not least, it is setup easy and the service contracts are specified using interfaces and annotations.

In the following tutorial I’d like to demonstrate how to derive a service binding from a simple, JAX-RS based RESTful web-service, how to create the service adapter using the integrated builder and at last, performing CRUD operations.

(more…)

Integrating Swagger into a Spring Boot RESTful Webservice with Springfox

Wednesday, July 1st, 2015

Spring Boot allows us to create RESTful web-services with ease, Swagger specifies a format to describe the capabilities and operations of these services and with Swagger UI it is possible to explore our REST API with a nice graphical user interface in our browser.

Springfox is a project that aims at creating automated JSON API documentation for API’s built with Spring and is used in the following tutorial to integrate Swagger into a sample application.

(more…)

Documenting RESTful Webservices in Swagger, AsciiDoc and Plain Text with Maven and the JAX-RS Analyzer

Tuesday, June 16th, 2015

A variety of different tools exists to help us analyze RESTful web-services and create documentations for their APIs in different formats.

In the following tutorial I’d like to demonstrate how to document an existing JAX-RS web-service in multiple formats like Swagger, AsciiDoc or Plain Text using Maven, the JAX-RS Analyzer and the JAX-RS Analyzer Maven Plugin.

The JAX-RS Analyzer gathers its information not only by reflection like most other tools but also by bytecode analysis and therefore does not require us to add special annotations for documentation to our code.

(more…)

JAX-RS Server API Snippets

Sunday, September 28th, 2014

Because a lot of my current projects are using JAX-RS in different versions I’d like to write down and share some frequently used snippets for implementing RESTful web-services with the JAX-RS specification here.

(more…)

Java EE 7 Database Migrations with Liquibase and WildFly

Thursday, July 31st, 2014

I have written about other database migration frameworks before but in this article I’d like to cover the Liquibase framework in combination with WildFly as Java EE 7 compatible application server.

In the following tutorial, we’re going to write a full Java EE 7 book store application with a few steps and with Liquibase on board to create the database structure and insert example data into the database.

Thanks to the WildFly Maven Plug-in we even do not need to download and configure the application server but let Maven and the plug-in do the work for us.

(more…)

JAX-RS 2.0 REST Client Features by Example

Monday, December 30th, 2013

JAX-RS 2.0 aka JSR 339 not also specifies the API to build up a RESTful webservice but also enhances the client side API to easen up the process of writing a client for a REST service.

In the following tutorial we’re building up a client for a ready-to-play REST service and explore the different new options e.g. how to handle requests in a synchronous or asynchronous way, how to add callback handlers for a request, how to specify invocation targets to build up requests for a later execution or how to filter the client-server communication using client request filters and client response filters.

(more…)

Using Apache Camel with Scala and the Camel Scala DSL

Wednesday, February 13th, 2013

Whenever I encounter a situation where I have to mix a blend of different services and endpoints and apply one or more of the traditional enterprise integration patterns then Apache Camel often is my weapon of choice.

I simply love how easy it is to set up some datasources, add some routing magic, data transformers, load balancers, content enrichers and enjoy the result.

Another thing that I’m beginning to love is Scala and so this is the perfect time to write an article about using Scala and Apache Camel together.

In the following tutorial we’re setting up our environment using SBT and Scala we’ll take a look at several interesting use cases for camel.

(more…)

Testing RESTful Web Services made easy using the REST-assured Framework

Sunday, October 23rd, 2011

REST-assured Integration Test Tutorial Logo There are many frameworks out there to facilitate testing RESTful webservices but there is one framework I’d like to acquaint you with my favourite framework named REST-assured.

REST-assured offers a bunch of nice features like a DSL-like syntax, XPath-Validation, Specification Reuse, easy file uploads and those features we’re going to explore in the following article.

With a few lines of code and Jersey I have written a RESTful web service that allows us to explore the features of the REST-assured framework and to run tests against this service.

(more…)

REST-assured vs Jersey-Test-Framework: Testing your RESTful Web-Services

Monday, September 5th, 2011

Today we’re going to take a look at two specific frameworks that enables you to efficiently test your REST-ful services: On the one side there is the framework REST-assured that offers a nice DSL-like syntax to create well readable tests – on the other side there is the Jersey-Test-Framework that offers a nice execution environment and is built upon the JAX-RS reference implementation, Jersey.

In the following tutorial we’re going to create a simple REST service first and then implement integration tests for this service using both frameworks.

The title of this article might be misleading due to the fact that I am not going to compare both frameworks to choose a winner, just showing the different approach ..

(more…)

Contract-First Web-Services using JAX-WS, JAX-B, Maven and Eclipse

Tuesday, August 23rd, 2011

Using the contract-first approach to define a web service offers some advantages in contrast to the code-first approach.

In the following tutorial we’re going to take a look at some details of this approach and we’re going to implement a real SOAP service using JAX-WS, Maven and the Eclipse IDE.

Finally we’re going to run our service implementation on an embedded Jetty instance and we’re going to take a look at soapUI and how to test our service using this neat tool.

(more…)

Creating a REST Client Step-by-Step using JAX-RS, JAX-B and Jersey

Thursday, November 25th, 2010

Often in a developer’s life there is a REST service to deal with and nowadays one wants a fast and clean solution to create a client for such a service.

The following tutorial shows a quick approach using JAX-RS with its reference implementation, Jersey in combination with JAX-B for annotation driven marshalling between XML or JSON structures and our Java-Beans.

(more…)

How to create a Confluence SOAP Component in 5 Minutes

Sunday, October 24th, 2010

You’re using the popular Confluence wiki? You’re using its RPC/SOAP API and missing a function you really need? Just extend the  capabilities of the Confluence RPC API by programming a custom web service component – it is really easy and also well documented.

In this tutorial we’re going to take a look on how to quickly implement a SOAP service, securing it and putting its methods in a transactional context.

(more…)

Creating a SOAP Service using JAX-WS Annotations

Thursday, September 23rd, 2010

It is possible to create SOAP webservices with only a few lines of code using the JAX-WS annotations. In a productivity environment you might prefer using contract-first instead of code-first to create your webservice but for now we’re going to use the fast method and that means code-first and annotations olé!

(more…)

Create a SOAP client using the JAX-WS Maven Plugin

Thursday, April 8th, 2010

Having written the article “How to build a Confluence SOAP client in 5 minutes” some readers asked me for some more information and help using the  JAX-WS plugin that I mentioned in the article instead of the Axis plugin – so here we go ;) (more…)

How to build a Confluence SOAP client in 5 minutes

Sunday, March 28th, 2010

In this tutorial we are going to build a SOAP client for the popular Confluence Wiki in about five minutes. The client is going to receive rendered HTML Markup from a specified Confluence Page.
(more…)

Search
Categories