+1-866-788-4185 begin_of_the_skype_highlighting +1-866-788-4185 FREE  end_of_the_skype_highlighting

JD Edwards Business Service Integration (Part 3-5)

Overview

First of all, we would like to thank everyone for such a wonderful response on our Part-1 and Part-2 for JD Edwards Business Service Integration series, if you haven’t seen it yet Click here to read Part-1 and similarly Click here to read Part-2. In this part we will continue from where we left off and develop business service object using Java inside JDeveloper. We will be exploring the two major classes for BSSV integration which includes ValueObject class and Business Service class. Lets take a look at what we will be covering in this part.

 

What is covered in Part-3

In Part-3 of this series, we will talk about

Looking at the WebService Output from our Sample Scenario

We will review the web service provider for our sample scenario.

JD Edwards BSSV Sample Output

JD Edwards BSSV Sample Output

Brief overview on the available BSSV Classes

We will discuss about “ValueObject” and “Business Service” class.

JD Edwards BSSV ValueObject BusinessService Class

JD Edwards BSSV ValueObject BusinessService Class

Download Source Code to Presentation

Download the Source Code here (ValidateAddressVO.java) (ValidateUKAddress.java).

ValueObject Class ValidateAddressVO.java

package oracle.e1.bssv.J55V002.valueobject;import java.io.Serializable;

import oracle.e1.bssvfoundation.base.ValueObject;

/**
* TODO: Java Doc comments for Value Object here
*/
public class ValidateAddressVO extends ValueObject implements Serializable {
/**
* Source Description
* <p>
* TODO: Description using Glossary Text from EnterpriseOne if appropriate.
* </p>
* TODO: EnterpriseOne Key Field: false <br>
* EnterpriseOne Alias: 79AEMSD <br>
* EnterpriseOne field length: 100 <br>
*/
private String szTownName = null;

/**
* Source Description
* <p>
* TODO: Description using Glossary Text from EnterpriseOne if appropriate.
* </p>
* TODO: EnterpriseOne Key Field: false <br>
* EnterpriseOne Alias: 79AEMSD <br>
* EnterpriseOne field length: 100 <br>
*/
private String szResponse = null;

/**
* Source Description
* <p>
* TODO: Description using Glossary Text from EnterpriseOne if appropriate.
* </p>
* TODO: EnterpriseOne Key Field: false <br>
* EnterpriseOne Alias: 79AEMSD <br>
* EnterpriseOne field length: 100 <br>
*/
private String szCounty = null;

/**
* Source Description
* <p>
* TODO: Description using Glossary Text from EnterpriseOne if appropriate.
* </p>
* TODO: EnterpriseOne Key Field: false <br>
* EnterpriseOne Alias: 79AEMSD <br>
* EnterpriseOne field length: 100 <br>
*/
private String szPostCode = null;

public void setSzTownName(String szTownName) {
this.szTownName = szTownName;
}

public String getSzTownName() {
return szTownName;
}

public void setSzResponse(String szResponse) {
this.szResponse = szResponse;
}

public String getSzResponse() {
return szResponse;
}

public void setSzCounty(String szCounty) {
this.szCounty = szCounty;
}

public String getSzCounty() {
return szCounty;
}

public void setSzPostCode(String szPostCode) {
this.szPostCode = szPostCode;
}

public String getSzPostCode() {
return szPostCode;
}
}

Business Service Class ValidateUKAddress.java

package oracle.e1.bssv.J55V002;import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;import oracle.e1.bssv.J55V002.valueobject.ValidateAddressVO;
import oracle.e1.bssvfoundation.base.BusinessService;
import oracle.e1.bssvfoundation.base.IContext;
import oracle.e1.bssvfoundation.connection.IConnection;
import oracle.e1.bssvfoundation.util.E1MessageList;

/**
* TODO: Java Doc for BusinessService
*/
public abstract class ValidateUKAddress extends BusinessService {
/**
* TODO: Create Java Doc for: getValidateAddress
* Method getValidateAddress is used for…?
* @param context conditionally provides the connection for the database operation and logging information
* @param connection can either be an explicit connection or null. If null the default connection is used.
* @param internalVO represents data that is passed to EnterpriseOne for processing TODO: complete javadoc for VO.
* @return an E1Message containing the text of any errors or warnings that may have occurred
*/
public static E1MessageList getValidateAddress(IContext context, IConnection connection, ValidateAddressVO internalVO) {

//Call start internal method, passing the context (which was passed from PublishedBusinessService).
startInternalMethod(context, “getValidateAddress”, internalVO);
//Create new message list for BusinessService processing.
E1MessageList messages = new E1MessageList();

//TODO: call method (created by the wizard), which then executes Business Function or Database operation.
ValidateAddressVO retVO = ValidateAddress(internalVO.getSzTownName());

internalVO.setSzResponse(retVO.getSzResponse());
internalVO.setSzCounty(retVO.getSzCounty());
internalVO.setSzPostCode(retVO.getSzPostCode());

// Debug Output
System.out.println(“Response: “+retVO.getSzResponse());
System.out.println(“CountyName: “+retVO.getSzCounty());
System.out.println(“PostCode: “+retVO.getSzPostCode());
//TODO: add messages returned from E1 processing to BusinessService message list.

//Call finish internal method passing context.
finishInternalMethod(context, “getValidateAddress”);

//Call finish internal method passing context.
return messages;
}

private static final String TAG_SUCCESS = “<NewDataSet>”;
private static final String TAG_COUNTY_START = “<County>”;
private static final String TAG_COUNTY_END = “</County>”;
private static final String TAG_POSTCODE_START = “<PostCode>”;
private static final String TAG_POSTCODE_END = “</PostCode>”;

private static ValidateAddressVO ValidateAddress(String strTownName) {
String strOutput=”",line=”";
String urlAddress = “http://www.webservicex.net/uklocation.asmx/GetUKLocationByTown?Town=”;
ValidateAddressVO retVO = new ValidateAddressVO();
int startIndex, endIndex;

urlAddress += strTownName;

try {
URL url = new URL(urlAddress);

HttpURLConnection conn = (HttpURLConnection) url.openConnection();

if (conn.getResponseCode() != 200) {

retVO.setSzResponse(“FAILURE!!: ” + conn.getResponseCode() + ” error Occured.”);
retVO.setSzPostCode(“”);
retVO.setSzCounty(“”);
}
else{
// If exceution is successful retrieve the response
InputStream content = (InputStream)conn.getInputStream();
BufferedReader in = new BufferedReader (new InputStreamReader (content));

while ((line = in.readLine()) != null) {
strOutput += line;
}
in.close();

// HTML Escaping
strOutput = strOutput.replace(“&lt;”,”<”).replace(“&amp;”,”&”).replace(“&gt;”,”>”).replace(“&quot;”,”\”");

// Processing the Response
startIndex = strOutput.indexOf(TAG_SUCCESS);
// Check if we have a valid Town
if (startIndex < 0) {
retVO.setSzResponse(“Invalid Town Name Passed”);
retVO.setSzPostCode(“”);
retVO.setSzCounty(“”);
} else {
retVO.setSzResponse(“SUCCESS”);

startIndex = strOutput.indexOf(TAG_COUNTY_START);
endIndex = strOutput.indexOf(TAG_COUNTY_END);
retVO.setSzCounty(strOutput.substring(startIndex+TAG_COUNTY_START.length(),endIndex));

startIndex = strOutput.indexOf(TAG_POSTCODE_START);
endIndex = strOutput.indexOf(TAG_POSTCODE_END);
retVO.setSzPostCode(strOutput.substring(startIndex+TAG_POSTCODE_START.length(),endIndex));
}
}
} catch (MalformedURLException e) {
retVO.setSzResponse(“FAILURE: ” + e.toString() );
retVO.setSzPostCode(“”);
retVO.setSzCounty(“”);
} catch (Exception e) {
retVO.setSzResponse(“FAILURE: ” + e.toString() );
retVO.setSzPostCode(“”);
retVO.setSzCounty(“”);
}

return retVO;
}

}

Add comment

Comments

Be the first to comment!

Stray Boots, a New York-based startup that launched in 2009 with Ephlux as its core development partner raises $2M to expand its mobile reach. Stray Boots, a New York-based startup that got its start delivering guided tour scavenger hunt games to tourists and city dwellers around the world via SMS, and which recently made the move to mobile apps, today announced a new $2 million Series A funding round, led by Milestone Venture Partners and including Correlation Ventures, Great Oaks and a number of angel investors.

0 comments