CFHTTP to get response variable
Hi all,
I am integrating the HSBC CPI to a site at the moment, and am
having some difficulty in getting the value of the CPI hash. I am
attempting to use CFHTTP to post form variables to a page to get
the variables converted to a hash then returned to my page to
submit.
I am using the following code:
<!--- GET ORDER --->
<cfinvoke component="cfc.shoppingCart"
method="getSavedOrder" returnvariable="getSavedOrder">
<cfhttp method="get" redirect="yes"
url="OrderHash.cfm">
<cfhttpparam type="formfield" name="OrderId"
value="#getSavedOrder.orderRef#">
<cfhttpparam type="formfield" name="TimeStamp"
value="">
<cfhttpparam type="formfield" name="CpiReturnUrl"
value="https://www.mysite.com/results.cfm">
<cfhttpparam type="formfield" name="CpiDirectResultUrl"
value="https://www.mysite.com/results.cfm">
<cfhttpparam type="formfield" name="StorefrontId"
value="UK12345678GBP">
<cfhttpparam type="formfield" name="OrderDesc"
value="Online Shop">
<cfhttpparam type="formfield" name="PurchaseAmount"
value="#replace(decimalFormat(getSavedOrder.orderTotal), ".", "",
"All")#">
<cfhttpparam type="formfield" name="PurchaseCurrency"
value="826">
<cfhttpparam type="formfield" name="TransactionType"
value="Auth">
<cfhttpparam type="formfield" name="UserId" value="">
<cfhttpparam type="formfield" name="Mode" value="T">
<cfhttpparam type="formfield" name="MerchantData"
value="">
<cfhttpparam type="formfield" name="BillingFirstName"
value="#getSavedOrder.uFirstName#">
<cfhttpparam type="formfield" name="BillingLastName"
value="#getSavedOrder.uLastName#">
<cfhttpparam type="formfield" name="ShopperEmail"
value="">
<cfhttpparam type="formfield" name="BillingAddress1"
value="#getSavedOrder.billAddr1#">
<cfhttpparam type="formfield" name="BillingAddress2"
value="#getSavedOrder.billAddr2#">
<cfhttpparam type="formfield" name="BillingCity"
value="#getSavedOrder.billAddr3#">
<cfhttpparam type="formfield" name="BillingCounty"
value="">
<cfhttpparam type="formfield" name="BillingPostal"
value="#getSavedOrder.billPoco#">
<cfhttpparam type="formfield" name="BillingCountry"
value="826">
<cfhttpparam type="formfield" name="ShippingFirstName"
value="#getSavedOrder.delFirstName#">
<cfhttpparam type="formfield" name="ShippingLastName"
value="#getSavedOrder.delLastName#">
<cfhttpparam type="formfield" name="ShippingAddress1"
value="#getSavedOrder.delAddr1#">
<cfhttpparam type="formfield" name="ShippingAddress2"
value="#getSavedOrder.delAddr2#">
<cfhttpparam type="formfield" name="ShippingCity"
value="#getSavedOrder.delAddr3#">
<cfhttpparam type="formfield" name="ShippingCounty"
value="">
<cfhttpparam type="formfield" name="ShippingPostal"
value="#getSavedOrder.delPoco#">
<cfhttpparam type="formfield" name="ShippingCountry"
value="826">
</cfhttp>
To post to a page that consumes tyhose fields to create a
hash.
How can I return the hash to my page using cfhttp? Is it
possible?
TIA,
Paul
Mark,
I currently have all the cart side of the site on non ssl,
and when an order goes through the checkout it loops through the
cart and creates an order total and saves the order into the db. A
cflocation sends the user to the https with a URL variable relating
to the order id. A query pulls that order from the database, uses
cfhttp to post the data to OrderHash.cfm, receives the order hash
back - I did this by altering the output of OrderHash.cfm so that
the hash is the last thing to output, stuck a listLast() around it
to pull back just the key - , and submits it to the HSBC Servlet.
It has fallen down at this point on the HSBC site saying that there
is a communication error.
I have spoke to their tech support and have someone from
their senior support team calling me tomorrow as the lady I spoke
with said that the communication error is usually a browser
setting.
I will post more as I get it fixed.
Paul
Similar Messages
-
How to get response from such a function
How to get response from such a function (in MODULE USER_COMMAND_0010 INPUT I get "ODGOVOR" 'X'
FUNCTION Z_SEENKRAT.
""Local Interface:
*" EXPORTING
*" REFERENCE(ODGOVOR) TYPE MSEG-KZEAR
DATA ok_code LIKE sy-ucomm.
DATA: test like mseg-kzear.
BREAK-POINT.
call screen 10.
test = ODGOVOR.
ENDFUNCTION.
*& Module CLEAR_OK_CODE OUTPUT
text
MODULE clear_ok_code OUTPUT.
CLEAR ok_code.
ENDMODULE. " CLEAR_OK_CODE OUTPUT
*& Module USER_COMMAND_0010 INPUT
text
MODULE USER_COMMAND_0010 INPUT.
DATA odgovor LIKE mseg-KZEAR.
CASE ok_code.
WHEN 'DA'.
ODGOVOR = 'X'.
ENDCASE.
ENDMODULE. " USER_COMMAND_0010 INPUTHi,
You need to declare the ODGOVOR variable in the TOP include, then you will get the value
Regards
Sudheer -
Can an embedded Flash SWF save and get a variable with Reader?
My SWF content contains text in different languages. The user selects a language and it appears.
Is there a way to store this setting locally so that the correct language appears when the pdf is reopened?
I only need a two-letter string, like "EN," "FR," "ZH," etc. and the SWF does the rest.
I've tried calling multimedia_saveSettingsString from the SWF Actionscript, and I've tried setting an Acrobat global variable and setPersistent using Actionscript and local .js files. It works in Acrobat, but not Reader on a users system.
I also tried using a separate pdf form to store a global variable, and then attempted to get that variable using the SWF Actionscript.
Could the be an issue with security settings or Acrobat properties?
I'm not a virtuoso at this, so script examples would help.
(Windows 7; Actionscript 3; Acrobat 9 and XI are available; Adobe Reader 9 is in the installed base, but I may be able to switch to a higher version of Reader)
I asked a similar question in the Acrobat Javascript community, but got no responses. I reworded it here with additional detail
Thanks.Here's the section from my example that's linked to the Save and Load buttons. evalText, infoText and replyText are the three TextArea fields.
Note that it's important to send a string, but return an object and cast it back into a string. EI.call() has no clue what's being sent back from JavaScript.
// button handlers
butSave.addEventListener(MouseEvent.CLICK, doSave);
function doSave(e:MouseEvent):void {
var rtn:Object = ExternalInterface.call("multimedia_saveSettingsString",evalText.text);
if (rtn == null) {
infoText.appendText("Save: REPLY = null");
} else if (rtn.toString() == "") {
infoText.appendText("Save: REPLY = empty string");
} else replyText.appendText("Save: reply = " + rtn.toString());
butLoad.addEventListener(MouseEvent.CLICK, doLoad);
function doLoad(e:MouseEvent):void {
var rtn:Object = ExternalInterface.call("multimedia_loadSettingsString");
if (rtn == null) {
infoText.appendText("Load: REPLY = null");
} else if (rtn.toString() == "") {
aT(infoText,"Load: REPLY = empty string");
} else replyText.appendText("Load: reply = " + rtn.toString()); -
Get javascript variable in JSP
Hi all,
can anybody tell me- how to get javascript variable in JSP,
in the same file (JSP).
Is this possible.
I can use JavaScript to get the value,
but then I have no way to get that to the JSP code.
Please give the appripriate answer with code.
Thanks
amitindiaHi all,
Thanks for your quick response.
So u are right that we can not call javascript variable
in the same JSP. and pass them to the bean class.
So what I did --- I get java script variable in another JSP using
request.getParameter(); and then redirected to previous JSP.
and I have solve my problem.
Actually I had to call bean class and pass varible to the bean
method but I was getting the same problem that I disscussed but now it
has been solved.
Thanks again for participation
amitindia -
Get response & slow performance
Internal authenticate method when the RSA 2K RSA key is used returns 256 bytes. The applet does not support the extended length. Because of it, the internal authenticate method returns 255 in the first launch. After the get response is called and the rest (1 byte) is returned. Get response function lasts unexpectedly slow. More than 300 ms. This code handle get response:
if (apdu.getCurrentState() != APDU.STATE_OUTGOING) {
apdu.setOutgoing();
apdu.setOutgoingLength(length);
apdu.sendBytesLong(tmpBuffer.data, remainingDataOffset, length);I am aware that in order to return the rest of the message, the array has to be iterated on the appropriate position (255). Is there any way how this can be optimized under the prerequisite that the extended length is not used?This is just the extract of my code. There is a part of code in which I am checking if the command is GET RESPONSE.
Can you see in this code what makes the get response acts slow. In the second launch, only one bate is resturned. This
byte is at the offset 255 of the tmpBuffer.data variable
Extract from the process method:
The instance variables:
private static final byte INS_GET_RESPONSE = (byte) 0xC0;
private byte[] remainingDataLength;
private byte[] remainingDataOffset;
The constructor:
remainingDataLength = JCSystem.makeTransientByteArray((short) 2,
JCSystem.CLEAR_ON_DESELECT);
remainingDataOffset = JCSystem.makeTransientByteArray((short) 2,
JCSystem.CLEAR_ON_DESELECT);
byte[] buffer = apdu.getBuffer();
byte ins = buffer[OFFSET_INS];
if (ins == INS_GET_RESPONSE) {
if (Util.getShort(remainingDataLength, (short) 0) <= 0) {
ISOException.throwIt(SW_CONDITIONS_NOT_SATISFIED);
sendData(apdu, Util.getShort(remainingDataLength, (short) 0));
return;
else {
Util.setShort(remainingDataOffset, (short) 0, (short) 0);
Util.setShort(remainingDataLength, (short) 0, (short) 0);
}The called sendData method:
private void sendData(APDU apdu, short length) {
short remainingDataOffsetTmp = Util.getShort(remainingDataOffset, (short) 0);
short remainingDataLengthTemp = Util.getShort(remainingDataLength, (short) 0);
if (length > RESPONSE_LENGTH) {
if (apdu.getCurrentState() != APDU.STATE_OUTGOING) {
apdu.setOutgoing();
apdu.setOutgoingLength(RESPONSE_LENGTH);
apdu.sendBytesLong(tmpBuffer.data, remainingDataOffsetTmp, RESPONSE_LENGTH);
remainingDataOffsetTmp += RESPONSE_LENGTH;
remainingDataLengthTemp = (short) (length - RESPONSE_LENGTH);
Util.setShort(remainingDataOffset, (short) 0, remainingDataOffsetTmp);
Util.setShort(remainingDataLength, (short) 0, remainingDataLengthTemp);
ISOException
.throwIt((short) (ISO7816Ext.SW_MORE_DATA + ((remainingDataLengthTemp > RESPONSE_LENGTH) ? RESPONSE_LENGTH
: remainingDataLengthTemp)));
else if (length > 0 && length <= RESPONSE_LENGTH) {
if (apdu.getCurrentState() != APDU.STATE_OUTGOING) {
apdu.setOutgoing();
apdu.setOutgoingLength(length);
apdu.sendBytesLong(tmpBuffer.data, remainingDataOffsetTmp, length);
Util.setShort(remainingDataOffset, (short) 0, (short) 0);
Util.setShort(remainingDataLength, (short) 0, (short) 0);
} -
I try hard but do not managed, I can't get the variable situaded inside a step?
I have created my sequence object then my step object (I can get the right name of this one)
but I didn't find in the help the method allowing to get any value of the step variables.
Any idea? Thank youHi,
You obtain a reference to your step as an PropertyObject.
Using this PropertyObject reference you can use the PropertObject.GetValString|GetValNumeric|GetValBoolean.
Hope this helps.
Regards
Ray Farmer
Regards
Ray Farmer -
Issue: Not getting response when the document is having special chars
Please help following issue: Not getting response when the document is having special chars(Use any doc with special char(ex: &, $, <, >,.....) TestErrorFour.doc
Error message:
System.FormatException: Invalid length for a Base-64 char array. at
System.Convert.FromBase64String(String s) at
Summarize.Summarizer.AccumulateBroadcast(String filedata, String givenWords) in
c:\DocumentSummarizer\App_Code\Summarizer.cs:line 66
Code:
File 1:
import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import java.net.URL;
import java.net.URLConnection;
import java.util.Properties;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.hwpf.*;
import org.apache.poi.hwpf.extractor.*;
import com.lowagie.text.Document;
import com.lowagie.text.pdf.PRTokeniser;
import com.lowagie.text.pdf.PdfReader;
public class DocumentSummarizerClient {
static Properties loadProperties() {
Properties prop = new Properties();
try {
prop.load(DocumentSummarizerClient.class.getClassLoader().getResourceAsStream("vep.properties"));
} catch (Exception ioe) {
ioe.printStackTrace();
return prop;
public String getSummary(String fileName,String noOfWordsOrPercentage ){
String summaryInputData ="";
String summarizedData="";
String summarizerURL = loadProperties().getProperty("Summarizer.serviceURL");
try {
String fileExtension=fileName.substring(fileName.lastIndexOf(".")+1, fileName.length());
if (fileExtension.equalsIgnoreCase("doc")|| fileExtension.equalsIgnoreCase("txt")|| fileExtension.equalsIgnoreCase("pdf")) {
if (fileExtension.equalsIgnoreCase("txt")) {
BufferedReader bufferedReader = new BufferedReader(
new FileReader(fileName));
String line = null;
while ((line = bufferedReader.readLine()) != null) {
summaryInputData += line;
if(fileExtension.equalsIgnoreCase("doc")){
POIFSFileSystem fs = null;
fs = new POIFSFileSystem(new FileInputStream(fileName));
HWPFDocument doc = new HWPFDocument(fs);
WordExtractor we = new WordExtractor(doc);
String[] paragraphs = we.getParagraphText();
for( int i=0; i<paragraphs .length; i++ ) {
paragraphs[i] = paragraphs.replaceAll("\\cM?\r?\n","");
summaryInputData+= paragraphs[i];
if(fileExtension.equalsIgnoreCase("pdf")){
Document document = new Document();
document.open();
PdfReader reader = new PdfReader(fileName);
int pageCount =reader.getNumberOfPages();
for(int i=1;i<=pageCount;i++){
byte[] bytes = reader.getPageContent(i);
PRTokeniser tokenizer = new PRTokeniser(bytes);
StringBuffer buffer = new StringBuffer();
while (tokenizer.nextToken()) {
if (tokenizer.getTokenType() == PRTokeniser.TK_STRING) {
buffer.append(tokenizer.getStringValue());
summaryInputData += buffer.toString();
else{
System.out.println("This is Invalid document. Presntly we support only text,word and PDF documents ");
// String encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String encoded=Base64Utils.base64Encode(summaryInputData.getBytes());
// encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String parameters= "base64String="+encoded+"&noOfWordsOrPercentage="+noOfWordsOrPercentage;
summarizedData= postRequest(parameters,summarizerURL);
String slength= "<string xmlns=\"http://tempuri.org/\">";
if(summarizedData.contains("</string>")){
summarizedData= summarizedData.substring(summarizedData.indexOf(slength)+slength.length(),summarizedData.indexOf("</string>"));
summarizedData = replaceVal(summarizedData);
//System.out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?><![CDATA["+summarizedData+"]]>");
// System.out.println("Summarized data "+summarizedData);
if(summarizedData.contains("Please enter the percentage")){
summarizedData="Data given cannot be summarized further";
else{
System.out.println("Data given cannot be summarized further");
summarizedData="";
} catch (FileNotFoundException e) {
return("The File is not found \n\n"+e.toString());
} catch (IOException e) {
return("The File is already in use \n\n"+e.toString());
} catch (Exception e) {
return(e.toString());
return summarizedData;
public static String postRequest(String parameters,String webServiceURL) throws Exception{
Properties systemSettings = System.getProperties();
systemSettings.put("http.proxyHost", loadProperties().getProperty("proxyHost"));
systemSettings.put("http.proxyPort", loadProperties().getProperty("proxyPort"));
System.setProperties(systemSettings);
String responseXML = "";
try {
URL url = new URL(webServiceURL);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
byte[] requestXML = parameters.getBytes();
httpConn.setRequestProperty("Content-Length", String
.valueOf(requestXML.length));
httpConn.setRequestProperty("Content-Type",
"application/x-www-form-urlencoded");
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
OutputStream out = httpConn.getOutputStream();
out.write(requestXML, 0, requestXML.length);
out.close();
InputStreamReader isr = new InputStreamReader(httpConn
.getInputStream());
BufferedReader br = new BufferedReader(isr);
String temp;
String tempResponse = "";
while ((temp = br.readLine()) != null)
tempResponse = tempResponse + temp;
responseXML = tempResponse;
br.close();
isr.close();
} catch (java.net.MalformedURLException e) {
System.out
.println("Error in postRequest(): Secure Service Required");
} catch (Exception e) {
System.out.println("Error in postRequest(): " + e.getMessage());
return responseXML;
public String replaceVal(String value) {
if (value == null) {
value = "";
value = value.replace("<", "<");
value = value.replace(">", ">");
value = value.replace("&", "&");
return value;
public static void main(String[] args) {
DocumentSummarizerClient testdoc=new DocumentSummarizerClient();
System.out.println("hello");
testdoc.getSummary("C:\\working_folder\\vep\\UnitTestCases\\VEP1.0\\DocumentSummarizerTestData\\TestErrorFour.doc","100%");
Note: Use any doc with special char(ex: &, $, <, >,.....) TestErrorFour.doc
File 2:
---------public class Base64Utils {
private static byte[] mBase64EncMap, mBase64DecMap;
* Class initializer. Initializes the Base64 alphabet (specified in RFC-2045).
static {
byte[] base64Map = {
(byte)'A', (byte)'B', (byte)'C', (byte)'D', (byte)'E', (byte)'F',
(byte)'G', (byte)'H', (byte)'I', (byte)'J', (byte)'K', (byte)'L',
(byte)'M', (byte)'N', (byte)'O', (byte)'P', (byte)'Q', (byte)'R',
(byte)'S', (byte)'T', (byte)'U', (byte)'V', (byte)'W', (byte)'X',
(byte)'Y', (byte)'Z',
(byte)'a', (byte)'b', (byte)'c', (byte)'d', (byte)'e', (byte)'f',
(byte)'g', (byte)'h', (byte)'i', (byte)'j', (byte)'k', (byte)'l',
(byte)'m', (byte)'n', (byte)'o', (byte)'p', (byte)'q', (byte)'r',
(byte)'s', (byte)'t', (byte)'u', (byte)'v', (byte)'w', (byte)'x',
(byte)'y', (byte)'z',
(byte)'0', (byte)'1', (byte)'2', (byte)'3', (byte)'4', (byte)'5',
(byte)'6', (byte)'7', (byte)'8', (byte)'9', (byte)'+', (byte)'/'};
mBase64EncMap = base64Map;
mBase64DecMap = new byte[128];
for (int i=0; i<mBase64EncMap.length; i++)
mBase64DecMap[mBase64EncMap[i]] = (byte) i;
* This class isn't meant to be instantiated.
private Base64Utils() {
* Encodes the given byte[] using the Base64-encoding,
* as specified in RFC-2045 (Section 6.8).
* @param aData the data to be encoded
* @return the Base64-encoded <var>aData</var>
* @exception IllegalArgumentException if NULL or empty array is passed
public static String base64Encode(byte[] aData) {
if ((aData == null) || (aData.length == 0))
throw new IllegalArgumentException("Can not encode NULL or empty byte array.");
byte encodedBuf[] = new byte[((aData.length+2)/3)*4];
// 3-byte to 4-byte conversion
int srcIndex, destIndex;
for (srcIndex=0, destIndex=0; srcIndex < aData.length-2; srcIndex += 3) {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex] >>> 2) & 077];
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+1] >>> 4) & 017 |
(aData[srcIndex] << 4) & 077];
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+2] >>> 6) & 003 |
(aData[srcIndex+1] << 2) & 077];
encodedBuf[destIndex++] = mBase64EncMap[aData[srcIndex+2] & 077];
// Convert the last 1 or 2 bytes
if (srcIndex < aData.length) {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex] >>> 2) & 077];
if (srcIndex < aData.length-1) {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+1] >>> 4) & 017 |
(aData[srcIndex] << 4) & 077];
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex+1] << 2) & 077];
else {
encodedBuf[destIndex++] = mBase64EncMap[(aData[srcIndex] << 4) & 077];
// Add padding to the end of encoded data
while (destIndex < encodedBuf.length) {
encodedBuf[destIndex] = (byte) '=';
destIndex++;
String result = new String(encodedBuf);
return result;
* Decodes the given Base64-encoded data,
* as specified in RFC-2045 (Section 6.8).
* @param aData the Base64-encoded aData.
* @return the decoded <var>aData</var>.
* @exception IllegalArgumentException if NULL or empty data is passed
public static byte[] base64Decode(String aData) {
if ((aData == null) || (aData.length() == 0))
throw new IllegalArgumentException("Can not decode NULL or empty string.");
byte[] data = aData.getBytes();
// Skip padding from the end of encoded data
int tail = data.length;
while (data[tail-1] == '=')
tail--;
byte decodedBuf[] = new byte[tail - data.length/4];
// ASCII-printable to 0-63 conversion
for (int i = 0; i < data.length; i++)
data[i] = mBase64DecMap[data[i]];
// 4-byte to 3-byte conversion
int srcIndex, destIndex;
for (srcIndex = 0, destIndex=0; destIndex < decodedBuf.length-2;
srcIndex += 4, destIndex += 3) {
decodedBuf[destIndex] = (byte) ( ((data[srcIndex] << 2) & 255) |
((data[srcIndex+1] >>> 4) & 003) );
decodedBuf[destIndex+1] = (byte) ( ((data[srcIndex+1] << 4) & 255) |
((data[srcIndex+2] >>> 2) & 017) );
decodedBuf[destIndex+2] = (byte) ( ((data[srcIndex+2] << 6) & 255) |
(data[srcIndex+3] & 077) );
// Handle last 1 or 2 bytes
if (destIndex < decodedBuf.length)
decodedBuf[destIndex] = (byte) ( ((data[srcIndex] << 2) & 255) |
((data[srcIndex+1] >>> 4) & 003) );
if (++destIndex < decodedBuf.length)
decodedBuf[destIndex] = (byte) ( ((data[srcIndex+1] << 4) & 255) |
((data[srcIndex+2] >>> 2) & 017) );
return decodedBuf;
issue 2: Exception when passing 2MB .txt file
Steps to reproduce:
Call getSummary() with 2MB .txt file
Actual:
The following exception has occured:
1. Error in postRequest(): Unexpected end of file from server
java.lang.NullPointerException
Please provide your precious feedback/suggestions.
Thanks in advance…..
Edited by: EJP on 15/03/2011 16:52: added code tags. Please use them. Code is unreadable otherwise.Thanks for your response….
This is enhancement project and some one develops long back.
Regarding point (b) You should be using the java.net.URLEncoder to encode URL parameters, not a base64 encoder.
DocumentSummarizerClient.java I am using base64
Ex:
// String encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String encoded=Base64Utils.base64Encode(summaryInputData.getBytes());
// encoded =new String (summaryInputData.getBytes("ISO-8859-1"),"UTF-8");
String parameters= "base64String="+encoded+"&noOfWordsOrPercentage="+noOfWordsOrPercentage;
summarizedData= postRequest(parameters,summarizerURL);
String slength= "<string xmlns=\"http://tempuri.org/\">";
if(summarizedData.contains("</string>")){
summarizedData= summarizedData.substring(summarizedData.indexOf(slength)+slength.length(),summarizedData.indexOf("</string>"));
summarizedData = replaceVal(summarizedData);
//System.out.println("<?xml version=\"1.0\" encoding=\"utf-8\"?><![CDATA["+summarizedData+"]]>");
System.out.println("Summarized data "+summarizedData);
if(summarizedData.contains("Please enter the percentage")){
summarizedData="Data given cannot be summarized further";
Above specific please I need to modify to resolve above issue.
Could you please suggest me what changes I need to do.
Waiting for positive response. -
How can I get the variable with the value from Thread Run method?
We want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that scope of the variable gets lost resulting to null value in the called method/class..
How can I get the variable with the value?
This is sample code:
public class SampleSynchronisation
public static void main(String df[])
sampleThread sathr= new sampleThread();
sathr.start();
System.out.println("This is the value from the run method "+sathr.x);
// I should get Inside the run method::: But I get only Inside
class sampleThread extends Thread
public String x="Inside";
public void run()
x+="the run method";
NB: if i write the variable in to a file I am able to read it from external method. This I dont want to doWe want to access a variable from the run method of a
Thread externally in a class or in a method. I presume you mean a member variable of the thread class and not a local variable inside the run() method.
Even
though I make the variable as public /public static, I
could get the value till the end of the run method
only. After that scope of the variable gets lost
resulting to null value in the called method/class..
I find it easier to implement the Runnable interface rather than extending a thread. This allows your class to extend another class (ie if you extend thread you can't extend something else, but if you implement Runnable you have the ability to inherit from something). Here's how I would write it:
public class SampleSynchronisation
public static void main(String[] args)
SampleSynchronisation app = new SampleSynchronisation();
public SampleSynchronisation()
MyRunnable runner = new MyRunnable();
new Thread(runner).start();
// yield this thread so other thread gets a chance to start
Thread.yield();
System.out.println("runner's X = " + runner.getX());
class MyRunnable implements Runnable
String X = null;
// this method called from the controlling thread
public synchronized String getX()
return X;
public void run()
System.out.println("Inside MyRunnable");
X = "MyRunnable's data";
} // end class MyRunnable
} // end class SampleSynchronisation>
public class SampleSynchronisation
public static void main(String df[])
sampleThread sathr= new sampleThread();
sathr.start();
System.out.println("This is the value from the run
method "+sathr.x);
// I should get Inside the run method::: But I get
only Inside
class sampleThread extends Thread
public String x="Inside";
public void run()
x+="the run method";
NB: if i write the variable in to a file I am able to
read it from external method. This I dont want to do -
How can I get the variable with the value from Thread's run method
We want to access a variable from the run method of a Thread externally in a class or in a method. Even though I make the variable as public /public static, I could get the value till the end of the run method only. After that scope of the variable gets lost resulting to null value in the called method/class..
How can I get the variable with the value?
This is sample code:
public class SampleSynchronisation
public static void main(String df[])
sampleThread sathr= new sampleThread();
sathr.start();
System.out.println("This is the value from the run method "+sathr.x);
/* I should get:
Inside the run method
But I get only:
Inside*/
class sampleThread extends Thread
public String x="Inside";
public void run()
x+="the run method";
NB: if i write the variable in to a file I am able to read it from external method. This I dont want to doYour main thread continues to run after the sathr thread is completed, consequently the output is done before the sathr thread has modified the string. You need to make the main thread pause, this will allow sathr time to run to the point where it will modify the string and then you can print it out. Another way would be to lock the object using a synchronized block to stop the main thread accessing the string until the sathr has finished with it.
-
How to get response from an asynchronous BPEL process in Java
I'm experimenting with BPEL and doesn't seem to be able to get response from an asynchronous BPEL process. Here's the deal:
I have a BPEL process that takes a string as input, and gives another string as output. This is a asyncronous process.
I want to initiate this BPEL process as a web service so I generate a Webservice Proxy in JDeveloper 10g (10.1.3.0.4). The function to call the process is now called "initiate" and takes three arguments: the input string, a "org.xmlsoap.schemas.ws._2003._03.addressing.EndpointReferenceType replyTo" and a
"org.xmlsoap.schemas.ws._2003._03.addressing.AttributedURI messageID".
HTTP-Analyzer shows that invoking the BPEL process with initiate("somestring", null, null) results in sending a SOAP message to the BPEL process, which returns a "202 Accepted". How do I get the response from the process? My intuition tells me that I have to use that second argument, that EnpointReferenceType thing. How do I use that?
Another question: If a asynchronous BPEL process does not exists (so the endpoint does not exist) the Java proxy does not throw an error when runned. It does not even sends a message. It exits with status 0! (This happens for example when deploying a new version of a process and when the "old" version is undeployed). Calling a non-existing synchronous BPEL process, the Java proxy DOES throw an error.Clemens,
That all sounds logical. But somehow it is still a mystery for me ... Somehow I don't see what should be done.
To call the async BPEL process I have the following procedure:
initiate(String input, org.xmlsoap.schemas.ws._2003._03.addressing.EndpointReferenceType replyTo, org.xmlsoap.schemas.ws._2003._03.addressing.AttributedURI messageID)
The first argument is the input for my BPEL process. The second is the address to a webservice that should handle the callback, right? The third is a messageID (makes sense, but why of the type AttributedURI?).
Here lies my problem. It is not clear to me how these EndpointReferenceType & AttributedURI work. I can't find anything on the net about it. The AXIS examples as where mentioned earlier use other types (namely the "org.xmlsoap.schemas.ws.addressing.MessageID" and "org.xmlsoap.schemas.ws.addressing.ReplyTo") which are completely different.
What I did so far:
- I created an webservice proxy that listens on the onResult endpoint of the BPEL process.
- I created an webservice proxy that calls the BPEL process through the initiate procedure, but it is not completely clear to me how to construct the EndPointreferenceType replyTo, and the MessageID. I did something like this:
EndpointReferenceType replyTo = new EndpointReferenceType();
// callback service running on local machine
// This URI class is the java.net's version
URI replyToURI = new URI("http://vaccinatie:8988/syncro-callback-context-root/stringconcatCallbackBindingPort");
// This AttributedURI is the org.xmlsoap.schemas.ws._2003._03.addressing's version
AttributedURI address = new AttributedURI();
// the only public methos that made sense to me:
address.set_value(replyToURI);
replyTo.setAddress(address);
// call the BPEL process
myPort.initiate("test123", replyTo, address);
But the above doesn't work (largely because I don't know what I'm doing here prob.:-) ) It does send the "test123" message, and the BPEL process does process it, but I don't seem to get the callback right.
I hope this makes my problems somewhat clearer. I hope someone can help me, because I'm just a beginner in this whole "web service area" and seems to do something terribly wrong here, because it should be very simple. Thx. -
Why im getting too long time in getting response from server in RMI???
I'm using RMI architecture. On my server side I put this method getRubricHierarchy() which returns the ArrayList of Test class objects. everything is working properly fine.
Im getting response properly, problem is its taking very long time in getting the response. method populate and create ArrayList in 0 second at server side but its taking more than 20 seconds to get response at client side.
My arraylist size is 30,000.
Any suggestions to reduce the time.
below you can see the code.
public List<Test> getRubricHierarchy(String strTree,String gblCombinedRepSectionID,String gblCompleteRepSectionID,String gblCompleteRepertoryID,Map authMap) {
Connection con=null;
ResultSet rs = null;
List<Test> l = new ArrayList<Test>();
List allList = new ArrayList();
con = createDBCon();
rs = con.createStatement().executeQuery("select * from rubric where sectionid='"+gblCombinedRepSectionID+"' order by orders");
Map parentMap = new HashMap();
while (rs.next()) {
Test rNode = new Test();
String rubrid = rs.getString("id");
final String desc = rs.getString("name");
rNode.setRubricName(desc);
rNode.setRubricID(rubrid);
rNode.setAuthor(rs.getString("repid"));
final int levlId = rs.getInt("levelid");
rNode.setRubLevel(levlId);
rNode.setCrossRef(rs.getString("CROSSREFERENCE"));
final String parentID = rs.getString("PARENTID");
rNode.setParentID(parentID);
rNode.setSectionID(rs.getString("sectionid"));
if (parentID.equals("0")) {
l.add(rNode);
allList.add(rNode);
List rmdyLst = (List) parentMap.get(parentID);
if (rmdyLst == null) {
rmdyLst = new ArrayList();
parentMap.put(parentID, rmdyLst);
rmdyLst.add(rNode);
rs.close();
for (Iterator iterator = allList.iterator(); iterator.hasNext();) {
Test rNodes = (Test) iterator.next();
List remdyLst = (List) parentMap.get(rNodes.getRubricID());
if (remdyLst != null) {
rNodes.setChildren(remdyLst);
for (Iterator iterator2 = remdyLst.iterator(); iterator2.hasNext();) {
Test rn = (Test) iterator2.next();
rn.setParent(rNodes);
}catch(Exception e){
e.printStackTrace();
return l;
}here is my Test Class
public class Test implements Serializable,Cloneable , MutableTreeNode{
private String strRubricID,strOldRubricID,strRubricName,strCrossRef,Author,strParentID,strSectionID;
private int rubLevel;
private List remedyList;
private List children = new ArrayList();
private Test parent;
private int order;
private String AuthorName="";
private String abbr;
private String treeType="";
private int noRem=-1;
private boolean isAddAsChild=false;
private String strRubricHie="";
private String user="";
public static final Enumeration<TreeNode> EMPTY_ENUMERATION = new Enumeration() {
public boolean hasMoreElements() {
return false;
public TreeNode nextElement() {
throw new NoSuchElementException("No more elements");
public Test(){
public void setUser(String user){
this.user = user;
public String getUser(){
return user;
public void setRubricHierarchy(String s){
this.strRubricHie=s;
public String getRubricHierarchy(){
return strRubricHie;
public Test(String treeType){
this.treeType = treeType;
public void setAddAsChild(boolean b){
this.isAddAsChild=b;
public boolean isAddAsChild(){
return isAddAsChild;
public Test getUserObject(){
return this;
public void setRubricID(String id){
this.strRubricID = id;
public String getRubricID(){
return strRubricID ;
public void setOldRubricID(String id){
this.strOldRubricID = id;
public String getOldRubricID(){
return strOldRubricID ;
public void setParent(Test r){
this.parent = r;
public Test getParent(){
return parent;
public void setParentID(String id){
this.strParentID = id;
public String getParentID(){
return strParentID;
public void setSectionID(String id){
this.strSectionID= id;
public String getSectionID(){
return strSectionID;
public void setRubricName(String name){
this.strRubricName = name;
public String getRubricName(){
return strRubricName;
public void setAuthorName(String name){
this.AuthorName = name;
public String getAuthorName(){
return AuthorName;
public void setAuthorAbbrivation(String a){
this.abbr = a;
public String getAuthorAbbrivation(){
return abbr;
public void setRubLevel(int rubLevel) {
this.rubLevel = rubLevel;
public int getRubLevel() {
return rubLevel;
public void setCrossRef(String strCrossRef) {
this.strCrossRef = strCrossRef;
public String getCrossRef() {
return strCrossRef ;
public void setRemedyList(List remedyList) {
this.remedyList = remedyList;
public List getRemedyList() {
return remedyList;
public void setAuthor(String Author) {
this.Author = Author;
public String getAuthor() {
return Author;
public void setChildren(List list) {
this.children = list;
public List getChildren() {
return children;
public void setOrder(int o){
this.order = o;
public int getOrder(){
return order;
public void setNumberOfRemedies(int no)
this.noRem = no;
public int getNumberOfRemedies()
return noRem;
public String toString() {
String value="";
value=strRubricName+ " ("+abbr+")";
return value;
public Object clone(){
Test rubric = new Test();
rubric.Author = Author;
rubric.children = children;
rubric.order = order;
rubric.parent = parent;
rubric.remedyList = remedyList;
rubric.rubLevel = rubLevel;
rubric.strCrossRef = strCrossRef;
rubric.strParentID = strParentID;
rubric.strRubricID = strRubricID;
rubric.strRubricName = strRubricName;
rubric.strSectionID = strSectionID;
return rubric;
@Override
public TreeNode getChildAt(int paramInt) {
if (this.children == null) {
throw new ArrayIndexOutOfBoundsException("node has no children");
final TreeNode node = (TreeNode) children.get(paramInt);
return node;
@Override
public int getChildCount() {
if (this.children == null) {
return 0;
return children.size();
@Override
public int getIndex(TreeNode paramTreeNode) {
// TODO Auto-generated method stub
return 0;
@Override
public boolean getAllowsChildren() {
return true;
@Override
public boolean isLeaf() {
return children.isEmpty();
@Override
public Enumeration children() {
if (this.children == null) {
return EMPTY_ENUMERATION;
Vector v = new Vector(this.children);
return v.elements();
@Override
public void insert(MutableTreeNode newChild, int paramInt) {
if (newChild == null) {
throw new IllegalArgumentException("new child is null");
MutableTreeNode oldParent = (MutableTreeNode) newChild.getParent();
if (oldParent != null) {
oldParent.remove(newChild);
newChild.setParent(this);
if (children == null) {
children = new ArrayList();
children.add(paramInt, newChild);
@Override
public void remove(int childIndex) {
MutableTreeNode child = (MutableTreeNode) getChildAt(childIndex);
children.remove(childIndex);
child.setParent(null);
@Override
public void remove(MutableTreeNode aChild) {
if (aChild == null) {
throw new IllegalArgumentException("argument is null");
if (!isNodeChild(aChild)) {
throw new IllegalArgumentException("argument is not a child");
remove(getIndex(aChild)); // linear search
public boolean isNodeChild(TreeNode aNode) {
boolean retval;
if (aNode == null) {
retval = false;
} else {
if (getChildCount() == 0) {
retval = false;
} else {
retval = (aNode.getParent() == this);
return retval;
@Override
public void setUserObject(Object paramObject) {
// TODO Auto-generated method stub
@Override
public void removeFromParent() {
MutableTreeNode parent = (MutableTreeNode) getParent();
if (parent != null) {
parent.remove(this);
@Override
public void setParent(MutableTreeNode paramMutableTreeNode) {
parent = (Test) paramMutableTreeNode;
* Returns the path from the root, to get to this node. The last element in
* the path is this node.
* @return an array of TreeNode objects giving the path, where the first
* element in the path is the root and the last element is this
* node.
public TreeNode[] getPath() {
return getPathToRoot(this, 0);
* Builds the parents of node up to and including the root node, where the
* original node is the last element in the returned array. The length of
* the returned array gives the node's depth in the tree.
* @param aNode
* the TreeNode to get the path for
* @param depth
* an int giving the number of steps already taken towards the
* root (on recursive calls), used to size the returned array
* @return an array of TreeNodes giving the path from the root to the
* specified node
protected TreeNode[] getPathToRoot(TreeNode aNode, int depth) {
TreeNode[] retNodes;
* Check for null, in case someone passed in a null node, or they passed
* in an element that isn't rooted at root.
if (aNode == null) {
if (depth == 0)
return null;
else
retNodes = new TreeNode[depth];
} else {
depth++;
retNodes = getPathToRoot(aNode.getParent(), depth);
retNodes[retNodes.length - depth] = aNode;
return retNodes;
}You have an O(N**2) algorithm at the end that is rather ill-considered. It seems to me at first glance that it could be combined int the previous loop.
-
Is it possible to get a variable if I only know the variable by it'
Is it possible to get a variable if I only know the variable by it's string name?
In my case I would like to call Resources.GetStringToDisplay("TEXT_0") and get the string "bla bla 0"
public class Resources {
public string GetStringToDisplay(String s)
{ //how can I to return the value of one variable
return ............;
public static String TEXT_0="bla bla 0";
public static String TEXT_1="bla bla 1";
public static String TEXT_2="bla bla 2";
public static String TEXT_3="bla bla 3";
ThanksNO you can not get Variable value by camparing string value in J2ME (because J2ME is not supporting reflection package). But you can do one thing to get same functionality.
public static String TEXT_0="TEXT_0@bla bla 0";
public static String TEXT_1="TEXT_1@bla bla 1";
public static String TEXT_2="TEXT_2@bla bla 2";
public static String TEXT_3="TEXT_3@bla bla 3";
public string GetStringToDisplay(String s)
if(TEXT_0.startsWith(s) )
return TEXT_0.substring (TEXT_0.indexOf('@')+1, TEXT_0.length());
else if(TEXT_1.startsWith(s) )
return TEXT_1.substring (TEXT_1.indexOf('@')+1, TEXT_1.length()); -
Hi,
I am doing RFC to File. I could generate the FILE successfully. But I am not getting Response from RFC. I am getting empty payload. I am doing with out BPM. I did succesfully File-RFC-File. but here RFC is the sender. I have some doubts in defining Interface mapping and Message Mapping. Is this a Syscronous scenario by default ?
If I want to get the resonse of RFC to a file. How many Receivers and Senders do i need to create?
Regards,
Varun
Edited by: Varun on Sep 9, 2008 1:00 PMhi,
Map Rfc.response to the File; hence rfc sender adapter and file receiver adapter..one sender n 1 receiver.Remember:
1. In the report that makes the call to XI , make sure that you use call RFC in a background task.
2. Make sure you use Commit Work at the end of the report.
Follow:
Send RFC to SAP XI Asynchronous
Also pls visit
Re: RFC to FILE
for the same scenario.
Thanks,
Durga
Edited by: NagaDurga Nannapaneni on Sep 9, 2008 10:55 AM -
How do I get a variable, or object from ABAP STACK.
Hey Gurus,
How do I get a variable, or object from ABAP STACK.
Example: I start my FM. I can see in the ABAP STACK the variable I need. I can see the object; I could use to get my variable. I need to use it in my FM; however I need to reference it in the run time. How do I do that?
Is there a method I can use for reading ABAP STACK?
Do I just use command: get reference of u2026?
Does anyone have an example code?
Basis version 7
Thanks in advance
MartinAh, you mean you want to access a variable from another program in the call stack, yes? You can do this using field symbols, but please don't try to change a value while doing this, it could really screw things up.
this example, is using two programs, where the second is accessing variables of the first program. Basically just notice that we are using the program name and the variable name when assigning the field symbol.
report zrich_0006 .
tables: mara.
parameters: p_matnr type mara-matnr..
data: matnr type mara-matnr.
data: imarc type table of marc with header line.
matnr = p_matnr.
select * from marc into table imarc up to 10 rows
where matnr = p_matnr.
perform in in program zrich_0007.
report zrich_0007 .
* FORM in *
form in.
data: field(50).
data: xmarc type marc.
field-symbols: <matnr>.
field-symbols: <imarc> type marc_upl_tt.
* Assign an individual variable
field = '(ZRICH_0006)matnr'.
assign (field) to <matnr>.
* Assign an internal table
field = '(ZRICH_0006)IMARC[]'.
assign (field) to <imarc>.
* Write out your data
write <matnr>.
loop at <imarc> into xmarc.
write: / xmarc-werks.
endloop.
endform.
Regards,
Rich Heilman -
Is there any function module to get the variables used in a query?
Hi experts
Please, do you know if is there any function module to get the variables used in a query?
Thanks and regards
LuisHi Srini
Yes, I have checked the tables but I need a function module
Thanks anyway!
Luis
Maybe you are looking for
-
Illustrator Crashing on open and save of files
PC using Windows 8 I've been using Illustrator CC for 6 months and it worked fine, all of a sudden it can't open or save files without taking very long (5-10 minutes) and occasionally crashes. Please help!
-
My Apple Magic Mouse is no longer recognized, and I have good batteries installed correctly in the mouse.
-
Oracle 9i Real Application Cluster Hardware Recommandation?
Is there any recommandation for hardware setup for Oracle 9i? I am looking for a hardware setup to support Oracle 9i Real Application Cluster. Thanks in advances Laurence
-
Is it possible to get free license for AI if I am a student?
hello. I am a student in UK college, after 1 year i will try to apply to the university. Currently i am studing Art & Design (Visual arts) level 2, for the next year I will apply to Art & Design (Design) level 3. In college we have been using AI and
-
Move or disable BPC Excel log file
Hi all, BPC Excel create a Log folder in My documents in order to store local log file. Is it possible to define another path for this log file or to disable the creation of this log file? regards, Romuald