Skip to main content

Posts

How to Create, Add, Receive MSMQ

//How to Create a MessageQueue ?_______________________ static string myQueue = ".\\private$\\EmailQueue"; if (!MessageQueue.Exists(myQueue)) { MessageQueue.Create(myQueue, false); } Console.WriteLine("Server is up and running on port 32578"); //How to Add MessageQueue :__________________________ MessageQueue messageQueue = new MessageQueue(myQueue); messageQueue.Send(emailDetail, "Email"); //How to Receive a MessageQueue :_____________________________________ private static EmailDetails ReceiveMessage(string queueName) { log.Info(DateTime.Now + " Queue checking"); MessageQueue messageQueue = new MessageQueue(queueName); EmailDetails emailDetail = null; try { messageQueue.Formatter = new XmlMessageFormatter(new Type[] { typeof(EmailDetails) }); emailDetail = (Emai

Access to Message Queuing system is denied

Access to Message Queuing system is denied Following step are involved to resolve this issue 1- Go to start and pess Windows + R key fro keyboard and write: compmgmt.msc 2- Expand services and applications 3- Next expand Message queuing 4- Click on private queue and then right click on desired queue which you have created 5- Allow permission from security every one and IIS if showing.

Jersey JAX-RS Framework - Step by Step Guide for Developing RESTful web services

Overview Jersey is a Java framework for developing RESTful web services. It is an implementation of JAX-RS reference.  In addition to JAX-RS , Jersey has its extended APIs that eases the development of restful web services and client development. In this tutorial, I will guide you through the steps to jump-start developing the RESTful web services using the Jersey framework. Requirements for this tutorial Eclipse Maven Jersey Framework Tomcat or any other Servlet container STEP 1 Open the Eclipse and create an empty Maven web project. Add the following dependencies   <dependencies>         <dependency>             <groupId>javax.ws.rs</groupId>             <artifactId>javax.ws.rs-api</artifactId>             <version>${jaxrs.version}</version>         </dependency>         <dependency>             <groupId>org.glassfish.jersey.containers</groupId>             <artifactId>jersey

Jersey Framework - java.lang.IllegalStateException: InjectionManagerFactory not found.

I have used Jersey Framework for RESTful web services development. I encountered the following error when I tried to upgrade it from 2.25 to 2.26 java.lang.IllegalStateException: InjectionManagerFactory not found. at org.glassfish.jersey.internal.inject.Injections.lambda$lookupInjectionManagerFactory$0(Injections.java:98) at java.util.Optional.orElseThrow(Unknown Source) at org.glassfish.jersey.internal.inject.Injections.lookupInjectionManagerFactory(Injections.java:98) at org.glassfish.jersey.internal.inject.Injections.createInjectionManager(Injections.java:93) at org.glassfish.jersey.server.ApplicationHandler.<init>(ApplicationHandler.java:282) at org.glassfish.jersey.servlet.WebComponent.<init>(WebComponent.java:335) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:178) at org.glassfish.jersey.servlet.ServletContainer.init(ServletContainer.java:370) at javax.servlet.GenericServlet.init(GenericServlet.java:158) at org.a

How to print SOAP request and response using Apache CXF?

Overview Most of the time, developers are developing the web services but they do not have the idea what's happening behind the screen. Using the web services client, you have the better idea of the request and response, the mandatory and optional fields etc. When you are consuming the web services through the code, you are looking at the code level and not the final Soap envelop structure. In this post, I will show you how to print the Soap request and response using the Apache CXF framework for easy debugging Apache CXF is an open source framework provided by Apache. It helps you to develop and consume the web services. It has the support for a variety of protocols like SOAP, RESTful and CORBA etc. Logging the Soap Request and Response Using Apache CXF, you can print/log the request and response using the interceptors. Interceptors are the basic processing units of the CXF framework. When a client requests a server using the SOAP, a chain of interceptors is formed

A complete guide to securing Spring RESTful web services using HTTP Basic Authentication header

In the following tutorial, I have shown you how to develop RESTful web services using Spring Boot Spring Data Rest web services for Beginners - Step By Step Guide This is a simple and easy written tutorial for beginners who are interested to explore the trending and widely used J2EE framework. In this tutorial, we will learn how to secure the Restful web services using the HTTP Basic Authentication header. According to rfc7617,  basic authentication is the method for HTTP user agent to provide the following two pieces of information in a request User Name Password In this method, the HTTP request contains the header in the following format Authorization: Basic <credentials>  where <credentials> is base64(username:password) Step 1 Add the following dependency to the maven <dependency>   <groupId>org.springframework.boot</groupId>   <artifactId>spring-boot-starter-security</artifactId> <dependency> Step

Best way to convert float to int in Java 8?

Most of the time, Java developers have to do type conversion. In this example, I will cover the conversion of  float datatype to int . There are several ways to achieve this. Solution 1 public class FloatToIntCasting {               public static void main( String[] args ) {                  float value = 0.9f;                  System.out.println( "0.9f converted to int : " +  (int) value );                  value = 1.1f;                  System.out.println( "1.1f converted to int : " + (int) value );              } } Output  0.9 f converted to int : 0 1.1 f converted to  int  : 1 As we can see in the above example, casting a float to int results in downcasting. It simply removes the fraction part and returns the value. Solution 2 public class FloatToIntUsingMathRound {     public static void main( String[] args ) {         float value = 0.9f;                    System.out.println( "0.9f rounded to int  : " + 

Spring Boot - How to deploy WAR file to Tomcat or any other external container?

Introduction When we develop Spring Boot application using Maven, the project is by default configured to package the project as JAR with an embedded Tomcat or another container. If we wish to export the project as WAR for deployment on the external container, we will have to change the configuration. Below are the steps to export Spring Boot project as WAR STEP 1 Change the maven.xml, replace the packaging value as provided below <packaging> war </packaging> STEP 2 Extend your main application class file from  SpringBootServletInitializer and override its  configure method as shown below Please leave your feedback in the comments box.

Spring Data Rest web services for beginners - Step By Step Guide

This tutorial is designed for those who have not worked with the Spring Framework or rest web services before. I am keeping it simple and less verbose so that readers can easily follow the steps and start developing the restful web services using Spring Data Rest. Spring Framework is the trending and widely used J2EE frameworks. It has various modules for web development. In this tutorial, we will use the Spring Data Rest. RESTful Web services Representational State Transfer (REST)  is based on server-client architecture and uses the HTTP protocol(stateless protocol). CRUD operations can be easily mapped on HTTP methods Create POST Read GET Update PUT Delete Delete Prerequisites for this tutorial Java 8 or later version Eclipse Maven Let's start developing the RESTful web services STEP 1 Open a new Maven Project in the eclipse, let's call it MyFirstRestApp.  We will use the Spring Boot for this tutorial. Open the maven.xml file and ad