Posts

Consuming wsdl into spring boot

Image
  Steps to consume SOAP wsdl into Spring Boot 1.        Create a standard spring boot project 2.        Copy the wsdl file content into <file-name>.wsdl file, saved in resources folder.   https://apiservices.balady.gov.sa/v1/gsb/wasel-address-service 1.        In project window create an empty folders to store generated wsdl stub files. Here, com.example.consumewebservice1.stubs   is the empty directory created. 1.        In pom.xml add dependencies spring web and spring web service and to convert WSDL to stub add jaxb plug-ins <build>     <plugins>         <plugin>             <groupId> org.jvnet.jaxb2.maven2 </groupId>             <artifactId> maven-jaxb2-plugin </artifactId>             <executions>                 <execution>                     <goals>                         <goal> generate </goal>                     </goals>                 </execution>             <

Java 8 Handy Notes

Image
Lambda Expression - it helps in implementation of functional interface, lambda expression is treated as a function, so compiler does not create .class file Java Method References – Method reference is used to refer method of functional interface or class. It is compact and easy form of lambda expression. There are 3-types of method references in java 1.        Reference to a static method 2.        Reference to a instance method 3.        Reference to a constructor Syntax for above each type of method references. 1.        Syntax of static Method Reference <Class name> :: <static method name> 2.        Syntax of instance Method Reference <Class name> :: <instance method name> 3.        Syntax of Constructor Method Reference <Class name> :: <new> (it is new keyword) Functional Interface - any interface that has only one abstract method is called functional interface, @FunctionalInterface annotation can be used to declare an

tips and handy

when I consume in custom java application, following lines are getting print in console... javax.xml.soap.SOAPException: Not a valid SOAP Content-Type: application/xml ===== reqeust ======== Content-Type:text/xml; charset=UTF-8 Content-Length:306 SOAPAction:"http://tempuri.org/IWaselAddressService/GetIndividualWaselAddress" Authorization:Bearer D8uiNeKyepGsXEGlnqMJIcPulquh NationalID 1030036857 =================================== and I think these lines are in sop of wsdl, as I didn't set any sop in my code ======= Map > httpHeaderMap = new HashMap >(); public ConfigHeaders() { System.out.println("calling >>> ConfigHeaders"); MainBaladyToken token = new MainBaladyToken(); // Map > headers = new HashMap >(); httpHeaderMap.put("Authorization", Collections.singletonList(token.getTokenKey(1))); httpHeaderMap.put("Host", Collections.singletonList("apiservic

Spring Interview Preparation

Image
  Interview Preparation Spring Boot 1.        management.endpoints.web.exposure.include=httptrace When we work with microservices or web services in general, it's quite useful to know how our users interact with our services. This can be achieved by tracing all the requests that hit our services and collect this information to analyze it later. There some systems available out there that can help us with this and can be easily integrated with Spring like  Zipkin . However,  Spring Boot Actuator has this functionality built-in  and can be used through its  httpTrace  endpoint which traces all HTTP requests. In this tutorial, we'll show how to use it and how to customize it to fit better our requirements. @Repository public class CustomTraceRepository implements HttpTraceRepository {   “From above for tracing we can use zipkin server and spring boot actuator”   2.        Spring Boot Actuator - It’s an immensely helpful library that helps you monitor app health