Click here to Skip to main content
15,886,362 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have created a java program that reads barcode data from a handheld scanner. I then want to send the data to a website via a webservice. the webservice is expecting the barcode data as a string. When I pass the barcode data I have read to the webservice function it does nothing. If I declare a string in java and initialize it to a string of barcodes I enter, it works fine, so the service is working correctly, it just seems to be not excepting my barcode string read from the scanner. I contain display the barcodes from the scanner in a message box and they look fine. Here is some of the code.

This reads the barcodes from the scanner and puts them in a comma separated string.

public String readbuttonGetPacket() {
byte[] bd = new byte[100];
String BCreturn = "";
int MaxLen = 80;
int stat2 = 0;


csp2DLL csp2 = csp2DLL.INSTANCE;

if (initscanner()) {
stat = csp2.csp2ReadData();
for(int i=0; i<stat; i++) {
stat2 = csp2.csp2GetPacket(bd,i,MaxLen);
if (i + 1 == stat) {
BCreturn = BCreturn + Native.toString(bd);
} else {
BCreturn = BCreturn + Native.toString(bd) + ',';
}
}
}
return BCreturn;
}

This is the code when you press the read button.

public String BCstring = "";
if (READ_COMMAND.equals(command)) {
ButtonClick readev = new ButtonClick();
stat = readev.readbuttonClick();

BCstring = readev.readbuttonGetPacket();

String response = importBarcodes(ReadScannerApplication.acctnum,ReadScannerApplication.username,
ReadScannerApplication.po,ReadScannerApplication.gridid,BCstring);
JOptionPane.showMessageDialog(readPanel,response);

This is the definition of the webservice function:

private static String importBarcodes(java.lang.String acctnum, java.lang.String username, java.lang.String po, java.lang.String gridid, java.lang.String barcodes) {
localhost._58191.OrderLinkWebService service = new localhost._58191.OrderLinkWebService();
localhost._58191.OrderLinkWebServiceSoap port = service.getOrderLinkWebServiceSoap();
return port.importBarcodes(acctnum, username, po, gridid, barcodes);
}
Posted
Comments
Richard MacCutchan 17-Apr-15 13:04pm    
You should use your debugger to check exactly what is getting posted to the webservice.
Member 11536627 20-Apr-15 11:14am    
Thanks, I figured it out. It wasn't even making it to the debugger in visual studio to see what it was passing in. But using the debugger in Netbeans I found it was adding a "\b" character to the beginning of each barcode. I took those out and it works fine now.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900