Friday, September 4, 2015

ADF Application for Consuming REST JSON Service

ADF does not support to consume the JSON response from REST service and creating the Data Control from it. Bit, we can write java code and consume the REST service in it. Once we have the response, assign it to POJO class and create data control on top of java class.


Response:-
{
    "postalcodes": [
        {
            "adminName2": "Pathanamthitta",
            "adminName3": "Adoor",
            "postalcode": "689694",
            "adminCode1": "13",
            "countryCode": "IN",
            "lng": 76.8981,
            "placeName": "Kalanjoor",
            "lat": 9.06969,
            "adminName1": "Kerala"
        },
        {
            "adminName2": "Pathanamthitta",
            "adminName3": "Adoor",
            "postalcode": "689694",
            "adminCode1": "13",
            "countryCode": "IN",
            "lng": 76.8981,
            "placeName": "Mancode",
            "lat": 9.06969,
            "adminName1": "Kerala"
        },
        {
            "adminName2": "Pathanamthitta",
            "adminName3": "Adoor",
            "postalcode": "689694",
            "adminCode1": "13",
            "countryCode": "IN",
            "lng": 76.8981,
            "placeName": "Padam",
            "lat": 9.06969,
            "adminName1": "Kerala"
        }
    ]
}

Create an ADF Application and create a Java class in Model project.

Example :-

package com.rest.service.model;

public class RestCallService {
    public RestCallService() {
        super();
    }
}

Next create a POJO class for ‘PostCodes’ in the JSON response.

Example:-

package com.rest.service.model;

public class PostalCode {
    private String adminCode3;
    private String adminName2;
    private String adminName3;
    private String adminCode2;
    private String adminName1;
    private String postalcode;
    private String adminCode1;
    private String countryCode;
    private String lng;
    private String lat;   
    private String placeName;
   
    public PostalCode() {
        super();
    }
    public void setAdminCode3(String adminCode3) {
        this.adminCode3 = adminCode3;
    }
    public String getAdminCode3() {
        return adminCode3;
    }
    public void setAdminName2(String adminName2) {
        this.adminName2 = adminName2;
    }
    public String getAdminName2() {
        return adminName2;
    }

    public void setAdminName3(String adminName3) {
        this.adminName3 = adminName3;
    }
    public String getAdminName3() {
        return adminName3;
    }
    public void setAdminCode2(String adminCode2) {
        this.adminCode2 = adminCode2;
    }
    public String getAdminCode2() {
        return adminCode2;
    }
    public void setAdminName1(String adminName1) {
        this.adminName1 = adminName1;
    }
    public String getAdminName1() {
        return adminName1;
    }
    public void setPostalcode(String postalcode) {
        this.postalcode = postalcode;
    }
    public String getPostalcode() {
        return postalcode;
    }
    public void setAdminCode1(String adminCode1) {
        this.adminCode1 = adminCode1;
    }
    public String getAdminCode1() {
        return adminCode1;
    }
    public void setCountryCode(String countryCode) {
        this.countryCode = countryCode;
    }
    public String getCountryCode() {
        return countryCode;
    }
    public void setLng(String lng) {
        this.lng = lng;
    }
    public String getLng() {
        return lng;
    }
    public void setLat(String lat) {
        this.lat = lat;
    }
    public String getLat() {
        return lat;
    }
    public void setPlaceName(String placeName) {
        this.placeName = placeName;
    }
    public String getPlaceName() {
        return placeName;
    }
}

Now, please add the code for consuming JSON Response with below code.

package com.rest.service.model;

import com.google.gson.Gson;

import com.google.gson.internal.LinkedTreeMap;

import java.io.BufferedReader;
import java.io.InputStreamReader;

import java.net.HttpURLConnection;
import java.net.URL;

import java.util.ArrayList;
import java.util.List;

public class RestCallService {
    public RestCallService() {
        super();
    }
   
    public List<PostalCode> getPostalCodes() {
        List<PostalCode> postalCodes=new ArrayList<PostalCode>();
        try {
            URL url =
                new URL("http://api.geonames.org/postalCodeLookupJSON?postalcode=689694&country=IN&username=demo");
            HttpURLConnection conn = (HttpURLConnection)url.openConnection();
            conn.setDoOutput(true);
            conn.setRequestMethod("GET");
            conn.setRequestProperty("Content-Type", "application/json");
            BufferedReader in =
                new BufferedReader(new InputStreamReader(conn.getInputStream()));
            Gson g1 = new Gson();
            LinkedTreeMap fromJson = g1.fromJson(in, LinkedTreeMap.class);
            List<LinkedTreeMap> o =
                (ArrayList<LinkedTreeMap>)fromJson.get("postalcodes");
           System.out.println(fromJson);
            if (fromJson != null && o != null) {
                for (LinkedTreeMap node : o) {
                    PostalCode post=new PostalCode();
                    if (node != null && node.get("adminCode1") != null) {
                        post.setAdminCode1(node.get("adminCode1").toString());
                    }
                    if (node != null && node.get("adminName1") != null) {
                        post.setAdminName1(node.get("adminName1").toString());
                    }
                    if (node != null && node.get("adminCode2") != null) {
                        post.setAdminCode2(node.get("adminCode2").toString());
                    }
                    if (node != null && node.get("adminName2") != null) {
                        post.setAdminName2(node.get("adminName2").toString());
                    }
                    if (node != null && node.get("adminCode3") != null) {
                        post.setAdminCode3(node.get("adminCode3").toString());
                    }
                    if (node != null && node.get("adminName3") != null) {
                        post.setAdminName3(node.get("adminName3").toString());
                    }
                    if (node != null && node.get("postalcode") != null) {
                        post.setPostalcode(node.get("postalcode").toString());
                    }
                    if (node != null && node.get("countryCode") != null) {
                        post.setCountryCode(node.get("countryCode").toString());
                    }
                    if (node != null && node.get("lng") != null) {
                        post.setLng(node.get("lng").toString());
                    }
                    if (node != null && node.get("lat") != null) {
                        post.setLat(node.get("lat").toString());
                    }
                    if (node != null && node.get("placeName") != null) {
                        post.setPlaceName(node.get("placeName").toString());
                    }
                    postalCodes.add(post);
                }
                in.close();
            }
        }
        catch(Exception e) {
            e.printStackTrace();
        }
        return postalCodes;
    }
    public static void main(String[] args) {
        RestCallService service=new RestCallService();
        service.getPostalCodes();
    }
}

Now, right click on the Java class – “RestCallService.java” and select “Create Data Control”

Go to ViewController project and create a jspx page. Go to Data Controls sections and refresh the section. Drag and drop postalCodes from Data Control and select the option Table à ADF Read Only Table.

Add the below properties to the table to make it pagination.

autoHeightRows="0" scrollPolicy="page"

Go to the Binding section of the jspx page and select “postalCodesIterator” and select RangeSize = 5 or whatever desired size.

Example :-

<?xml version='1.0' encoding='UTF-8'?>
<jsp:root xmlns:jsp="http://java.sun.com/JSP/Page" version="2.1"
          xmlns:f="http://java.sun.com/jsf/core"
          xmlns:h="http://java.sun.com/jsf/html"
          xmlns:af="http://xmlns.oracle.com/adf/faces/rich">
  <jsp:directive.page contentType="text/html;charset=UTF-8"/>
  <f:view>
    <af:document id="d1">
      <af:messages id="m1"/>
      <af:form id="f1">
        <af:panelGroupLayout id="pgl1" layout="vertical">
          <af:table value="#{bindings.postalCodes.collectionModel}" var="row"
                    rows="#{bindings.postalCodes.rangeSize}"
                    emptyText="#{bindings.postalCodes.viewable ? 'No data to display.' : 'Access Denied.'}"
                    fetchSize="#{bindings.postalCodes.rangeSize}"
                    rowBandingInterval="0"
                    selectedRowKeys="#{bindings.postalCodes.collectionModel.selectedRow}"
                    selectionListener="#{bindings.postalCodes.collectionModel.makeCurrent}"
                    rowSelection="single" id="t1" autoHeightRows="0"
                    scrollPolicy="page">
            <af:column sortProperty="#{bindings.postalCodes.hints.adminCode3.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminCode3.label}"
                       id="c1">
              <af:inputText value="#{row.bindings.adminCode3.inputValue}"
                            label="#{bindings.postalCodes.hints.adminCode3.label}"
                            required="#{bindings.postalCodes.hints.adminCode3.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminCode3.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminCode3.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminCode3.tooltip}"
                            id="it9">
                <f:validator binding="#{row.bindings.adminCode3.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminName2.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminName2.label}"
                       id="c3">
              <af:inputText value="#{row.bindings.adminName2.inputValue}"
                            label="#{bindings.postalCodes.hints.adminName2.label}"
                            required="#{bindings.postalCodes.hints.adminName2.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminName2.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminName2.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminName2.tooltip}"
                            id="it10">
                <f:validator binding="#{row.bindings.adminName2.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminName3.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminName3.label}"
                       id="c4">
              <af:inputText value="#{row.bindings.adminName3.inputValue}"
                            label="#{bindings.postalCodes.hints.adminName3.label}"
                            required="#{bindings.postalCodes.hints.adminName3.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminName3.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminName3.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminName3.tooltip}"
                            id="it4">
                <f:validator binding="#{row.bindings.adminName3.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminCode2.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminCode2.label}"
                       id="c2">
              <af:inputText value="#{row.bindings.adminCode2.inputValue}"
                            label="#{bindings.postalCodes.hints.adminCode2.label}"
                            required="#{bindings.postalCodes.hints.adminCode2.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminCode2.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminCode2.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminCode2.tooltip}"
                            id="it1">
                <f:validator binding="#{row.bindings.adminCode2.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminName1.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminName1.label}"
                       id="c8">
              <af:inputText value="#{row.bindings.adminName1.inputValue}"
                            label="#{bindings.postalCodes.hints.adminName1.label}"
                            required="#{bindings.postalCodes.hints.adminName1.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminName1.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminName1.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminName1.tooltip}"
                            id="it6">
                <f:validator binding="#{row.bindings.adminName1.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.postalcode.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.postalcode.label}"
                       id="c7">
              <af:inputText value="#{row.bindings.postalcode.inputValue}"
                            label="#{bindings.postalCodes.hints.postalcode.label}"
                            required="#{bindings.postalCodes.hints.postalcode.mandatory}"
                            columns="#{bindings.postalCodes.hints.postalcode.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.postalcode.precision}"
                            shortDesc="#{bindings.postalCodes.hints.postalcode.tooltip}"
                            id="it2">
                <f:validator binding="#{row.bindings.postalcode.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.adminCode1.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.adminCode1.label}"
                       id="c11">
              <af:inputText value="#{row.bindings.adminCode1.inputValue}"
                            label="#{bindings.postalCodes.hints.adminCode1.label}"
                            required="#{bindings.postalCodes.hints.adminCode1.mandatory}"
                            columns="#{bindings.postalCodes.hints.adminCode1.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.adminCode1.precision}"
                            shortDesc="#{bindings.postalCodes.hints.adminCode1.tooltip}"
                            id="it8">
                <f:validator binding="#{row.bindings.adminCode1.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.countryCode.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.countryCode.label}"
                       id="c9">
              <af:inputText value="#{row.bindings.countryCode.inputValue}"
                            label="#{bindings.postalCodes.hints.countryCode.label}"
                            required="#{bindings.postalCodes.hints.countryCode.mandatory}"
                            columns="#{bindings.postalCodes.hints.countryCode.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.countryCode.precision}"
                            shortDesc="#{bindings.postalCodes.hints.countryCode.tooltip}"
                            id="it3">
                <f:validator binding="#{row.bindings.countryCode.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.lng.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.lng.label}"
                       id="c6">
              <af:inputText value="#{row.bindings.lng.inputValue}"
                            label="#{bindings.postalCodes.hints.lng.label}"
                            required="#{bindings.postalCodes.hints.lng.mandatory}"
                            columns="#{bindings.postalCodes.hints.lng.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.lng.precision}"
                            shortDesc="#{bindings.postalCodes.hints.lng.tooltip}"
                            id="it11">
                <f:validator binding="#{row.bindings.lng.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.lat.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.lat.label}"
                       id="c10">
              <af:inputText value="#{row.bindings.lat.inputValue}"
                            label="#{bindings.postalCodes.hints.lat.label}"
                            required="#{bindings.postalCodes.hints.lat.mandatory}"
                            columns="#{bindings.postalCodes.hints.lat.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.lat.precision}"
                            shortDesc="#{bindings.postalCodes.hints.lat.tooltip}"
                            id="it7">
                <f:validator binding="#{row.bindings.lat.validator}"/>
              </af:inputText>
            </af:column>
            <af:column sortProperty="#{bindings.postalCodes.hints.placeName.name}"
                       sortable="false"
                       headerText="#{bindings.postalCodes.hints.placeName.label}"
                       id="c5">
              <af:inputText value="#{row.bindings.placeName.inputValue}"
                            label="#{bindings.postalCodes.hints.placeName.label}"
                            required="#{bindings.postalCodes.hints.placeName.mandatory}"
                            columns="#{bindings.postalCodes.hints.placeName.displayWidth}"
                            maximumLength="#{bindings.postalCodes.hints.placeName.precision}"
                            shortDesc="#{bindings.postalCodes.hints.placeName.tooltip}"
                            id="it5">
                <f:validator binding="#{row.bindings.placeName.validator}"/>
              </af:inputText>
            </af:column>
          </af:table>
        </af:panelGroupLayout>
      </af:form>
    </af:document>
  </f:view>
</jsp:root>


Run the application and can see the response is showing in the table with pagination.

Wednesday, September 2, 2015

Oracle Webcenter Capture Client is not loading

Oracle WebCenter Capture is used to scan the document and it can be uploaded to Webcenter Content. It provides a web interface where user can scan the document and can release the document to WebCenter Content.

When we are opening the capture client URL, http://hostname:16400/dc-client

If it throws java url, please reinstall the java and load the url


Please open below URL, and check the Java Installation status.



If it opens and  shows empty page, please check the Document Capture Version. If it is 11.1.1.8, please reinstall the patch by contacting Oracle Support  or install 11.1.1.9.

ADF Service Interface SOAP Webservice Namespace Change

We can create Service Interface from ADF BC Application Module. When we are creating the Service Interfaces, service is taking default  namespaces. This is changing sometimes, when any server restart or new deployment happens. Due to this issue, webservice fails in mobile application.

Please add the below files the directory where “AppModuleService.java” resides.

hander-chain.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
   <handler-chain>
      <handler>
         <handler-name>SOAPBodyHandler</handler-name>
         <handler-class>com.abc.SOAPBodyHandler</handler-class>
      </handler>
   </handler-chain>
</handler-chains>

SOAPBodyHandler.java

package com.abc;

import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;


public class SOAPBodyHandler implements SOAPHandler<SOAPMessageContext>
{
    static final String DESIRED_NS_PREFIX = "custname";
    static final String DESIRED_NS_URI = " /abc/mobile/si/model/common/types/";
    static final String UNWANTED_NS_PREFIX = "ns3";
   
    public SOAPBodyHandler() {
        super();
    }
    @Override
    public Set<QName> getHeaders() {
        return null;
    }
    @Override
    public boolean handleMessage(SOAPMessageContext context) {
        if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) { //Check here that the message being intercepted is an outbound message from your service, otherwise ignore.
                try {   
                  SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();
                    SOAPBody body = envelope.getBody();
                    Iterator iter = body.getChildElements();
                    while (iter.hasNext()) {
                        Object object = iter.next();
                        if (object instanceof SOAPElement) {
                            SOAPElement element = (SOAPElement) object;
                            element.removeNamespaceDeclaration(element.getPrefix());
                            element.setPrefix("custname");
                        }
                    }
                   
                } catch (SOAPException ex) {
                    Logger.getLogger(SOAPBodyHandler.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            return true; //indicates to the context to proceed with (normal)message processing
    }
    @Override
    public boolean handleFault(SOAPMessageContext context) {
        return false;
    }
    @Override
    public void close(javax.xml.ws.handler.MessageContext context) {
    }
}

If you want to change the namespace in multiple levels, please iterate the element and change it.

Sample Code given below.

if (object instanceof SOAPElement) {
                            SOAPElement element = (SOAPElement) object;
                            element.removeNamespaceDeclaration(element.getPrefix());
                            element.setPrefix("custname ");
                                Iterator a =element.getChildElements();
                            while(a.hasNext()) {
                                SOAPElement element1=(SOAPElement)a.next();
                                element1.removeNamespaceDeclaration(element1.getPrefix());
                                element1.setPrefix("custname ");
                                Iterator b =element1.getChildElements();
                                while(b.hasNext()) {
                                    SOAPElement element2=(SOAPElement)b.next();
                                    element2.removeNamespaceDeclaration(element1.getPrefix());
                                    element2.setPrefix("custname");
                                }
                            }
                        }

Please change the package names accordingly based on your project package for AppModuleService.java.

Please add the below lines in your webservice project class’s annotation.

@HandlerChain(name = "SOAPBodyHandler",file="handler-chain.xml")

Example:-

import javax.jws.HandlerChain;

@HandlerChain(name = "SOAPBodyHandler",file="handler-chain.xml")
Public class AppModuleService
{


Deploy the application and execute the webservices and you can see the changes. This is mainly happening when we are creating SOAP services for mobile (Titanium Applications) and Android device, need the complete namespace of response tags.

ADF SOAP Webservices Namespace change

We can see that the webservices created in ADF, is changing the response namespaces frequently when there are some new deployment happens. To avoid this particular issue, please follow the below workarounds in the ADF SOAP Webservice project.

Scenario 1:- Wrapper Webservice.

If we are creating wrapper webservice in ADF based on webservice proxy, please go to the proxy classes and locate “package-info.java”.

We can see the below line in the java class.

@javax.xml.bind.annotation.XmlSchema(namespace = "http://abc.com", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED)

We can change the line to below lines for setting the static namespace name.

@javax.xml.bind.annotation.XmlSchema(namespace = "http:// abc.com ", elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED,xmlns = {
@XmlNs(prefix = "customname", namespaceURI = "http:// abc.com ")})

This will change the response body tag with “customname” namespace.
Also we need to follow the below steps to change the parent nodes namespace.
Please add the below files the directory where you are creating the wrapper webservice.

hander-chain.xml

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<handler-chains xmlns="http://java.sun.com/xml/ns/javaee">
   <handler-chain>
      <handler>
         <handler-name>SOAPBodyHandler</handler-name>
         <handler-class>com.abc.SOAPBodyHandler</handler-class>
      </handler>
   </handler-chain>
</handler-chains>

SOAPBodyHandler.java

package com.abc;

import java.util.Iterator;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.namespace.QName;
import javax.xml.soap.SOAPBody;
import javax.xml.soap.SOAPElement;
import javax.xml.soap.SOAPEnvelope;
import javax.xml.soap.SOAPException;
import javax.xml.ws.handler.MessageContext;
import javax.xml.ws.handler.soap.SOAPHandler;
import javax.xml.ws.handler.soap.SOAPMessageContext;


public class SOAPBodyHandler implements SOAPHandler<SOAPMessageContext>
{
    static final String DESIRED_NS_PREFIX = "custname";
    static final String DESIRED_NS_URI = "http:// com.abc /";
    static final String UNWANTED_NS_PREFIX = "ns3";
   
    public SOAPBodyHandler() {
        super();
    }
    @Override
    public Set<QName> getHeaders() {
        return null;
    }
    @Override
    public boolean handleMessage(SOAPMessageContext context) {
        if ((Boolean) context.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY)) { //Check here that the message being intercepted is an outbound message from your service, otherwise ignore.
                try {   
                  SOAPEnvelope envelope = context.getMessage().getSOAPPart().getEnvelope();
                    SOAPBody body = envelope.getBody();
                    Iterator iter = body.getChildElements();
                    while (iter.hasNext()) {
                        Object object = iter.next();
                        if (object instanceof SOAPElement) {
                            SOAPElement element = (SOAPElement) object;
                            element.removeNamespaceDeclaration(element.getPrefix());
                            element.setPrefix("custname");
                        }
                    }
                   
                } catch (SOAPException ex) {
                    Logger.getLogger(SOAPBodyHandler.class.getName()).log(Level.SEVERE, null, ex);
                }
            }
            return true; //indicates to the context to proceed with (normal)message processing
    }
    @Override
    public boolean handleFault(SOAPMessageContext context) {
        return false;
    }
    @Override
    public void close(javax.xml.ws.handler.MessageContext context) {
    }
}

Please change the package names accordingly based on your project package.

Please add the below lines in your webservice project class’s annotation.

@HandlerChain(name = "SOAPBodyHandler",file="handler-chain.xml")

Example:-

import javax.jws.HandlerChain;

@HandlerChain(name = "SOAPBodyHandler",file="handler-chain.xml")
Public class MyClass
{


Deploy the application and execute the webservices and you can see the changes. This is mainly happening when we are creating SOAP services for mobile  (Titanium Applications) and Android device, need the complete namespace of response tags.

Wednesday, July 22, 2015

VBox Images with Same IP

This is happening because of same Mac Address that both the VBox images are using. When both the images are connected to the network, both are using one IP and thus all the request will be sent to one machine.
I have tried to refresh the MAC address of all three network adaptors (Bridged Adaptor, NAT, Host Only Adaptor) and restarted the VBox Image. But, unfortunately it stopped connecting to network and showing only loop back address for ifconfig command.
I have tried to start the network and got the below error,

a.      /etc/init.d/network restart
b.      Got the exception as “Bringing up interface eth0: Device eth0 does not seem to be present, delaying initialization” [FAILED}

After a lot of trial and error, I managed to sort out the issue and I have tested in two VBox images and it is working fine.
To avoid this issue, we need to follow the below steps.
1.       If you are connected with Bridged Adapter, NAT and Host-Only Adapter etc., please disable all the network adaptors except Bridged Adaptor.
VBox Image should be shutdown to do this à Settings àNetwork.
2.       Click on ‘Advanced’ in the Adaptor-0 (Bridged Adaptor) and click on the refresh button of MAC address. Note down this MAC Address in a note pad.
3.      Start the VM and login with root user.
4.      Remove the /etc/udev/rules.d/70-persistent-net.rules
a.      cd /etc/udev/rules.d/
b.      rm -rf 70-persistent-net.rules
5.      Manuall
a.      cd /etc/sysconfig/network-scripts/
b.      vi
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
HWADDR=08:00:27:bf:30:a7
USERCTL=no
PEERDNS=yes
IPV6INIT=no
c.       Change the HWADDR to the new One
DEVICE=eth0
BOOTPROTO=dhcp
ONBOOT=yes
TYPE=Ethernet
HWADDR=08:00:27:bf:94:a6
USERCTL=no
PEERDNS=yes
IPV6INIT=no
6.      Shutdown the VBox Image
a.      shutdown –h now
7.      Restart the Machine
8.      Start the VBox image with root user
9.      Check the IP address
a.      ifconfig
b.      We can see the eth0 are initiated and IPs are assigned.