Key in your Email here. You will be entered into a Special Lucky Draw!
 

Creating a Barcode Web Service with SmartCodeWebControl

This tutorial demonstrates the creation of a barcode web service using SmartCodeWebControl. When the service is hosted, you will be able to use a HTTP request to retrieve a barcode image in the PNG format.

1) To get started, go to File::New Web Site in Visual Studio, and select ASP.NET Web Service. Name the service WebSite2 as shown in the picture below.


2) Add a reference to SmartCodeWebControl. Right click on the WebSite2 project and select Add Reference.


3) Click the Browse Tab and navigate to SmartCodeWebControl.dll. The default location for the dll is at
C:\Program Files\TechnoRiver\SmartCodeWebControl\SmartCodeWebControl.dll


4) We will now write a web method CreateCode39ASCII for our web service. Copy and paste the block of code into the Service.cs file of the project.

What the code does is to create an instance of SmartCodeWebControl, and set the data to be encoded to be inputstr. After that, we obtain a bitmap from the barcode control and convert it into PNG format. Finally, we return the PNG image as an array of bytes at the last line.

[WebMethod]
public byte[] CreateCode39ASCII(string inputstr)
{
TechnoRiver.SmartCodeWeb.SmartCodeWebControl scwc = new TechnoRiver.SmartCodeWeb.SmartCodeWebControl();
scwc.Symbology = TechnoRiver.SmartCodeWeb.SmartCodeWebControl.BarcodeSymbology.CODE39ASCII;
scwc.BarcodeData = inputstr;
System.Drawing.Bitmap bmp = scwc.GetBitMap();

System.IO.MemoryStream stream = new System.IO.MemoryStream();
bmp.Save(stream, System.Drawing.Imaging.ImageFormat.Png);
stream.Close();
return stream.ToArray();

}



5) We can now build the solution and test the web service. By running the web application (Debug::Start Without Debugging), you should see something as follows. Notice the CreateCode39ASCII method that we have created previously is listed.


6) Click on the CreateCode39ASCII link and you will be directed to a web page as shown. Test the web method by entering values into the inputstr and click the Invoke button.


7) The web service will return an XML file with a tag for base64binary like below.


8) We will now write a Windows Forms application to consume the web service. To simplify things we will create the Windows Forms application within the same project. This will allow it to connect to the Web Service locally.

Right click your solution and add a new project.


9) Choose the Windows Application template and name it WebserviceConsume.


10) Add a Web Reference to the service we created in our previous steps..


11) Choose "Web services in this solution"


12) Click on the link "Service"


13) Name the web reference "BarcodeService" and click the "Add Reference" button.


14) We now return to the form of our Windows Application and insert a label with the text "Web Service Client". Next, we drop a picture box to hold the barcode image returned from the web service. Name the picture box "pic1"


15) Add a Form_Load event to the form and create an instance of the web service. Invoke the CreateCode39ASCII method we defined earlier to retrieve the barcode image.

The returned PNG image is stored as an array of byte in the imgbyte variable. Convert the byte array into an Image and set it to the picture box (pic1). The code should look like the following.

private void Form1_Load(object sender, EventArgs e)
{
BarcodeService.Service bs = new WebserviceConsume.BarcodeService.Service();
byte[] imgbyte = bs.CreateCode39ASCII("TestWebService");
System.IO.MemoryStream ms = new System.IO.MemoryStream(imgbyte);
Image img = Image.FromStream(ms);
pic1.Image = img;
}



16) We are now ready to run the WebserviceConsume application. The result should look as follows. The "L" at the end of the barcode data is the check digit of the Code 39 ASCII barcode.


July 23, 2008

TechnoRiverStudio(v5.0) - New!
This version introduces OCR Text (Optical Character Recognition) into TechnoRiverStudio. With the OCR Text feature, you will be able to create labels and documents that can be scanned with great accuracy. The OCR characters also integrate well with the Human Readable of the barcode. TechnoRiverStudio currently supports the OCR-A and OCR-B character sets, both based on the ANSI standard.

more info

Feb 25, 2008

TechnoRiverStudio(v4.5)
(formerly SmartCodeStudio)
Technoriver brings labeling to the next level by introducing the Autowrap Fitting Text into its barcode labeling software. This text object allows easir handling of long text strings by breaking them down into several lines and then resizing them to fit within a bounding box. The barcodes produced in this version are also updated with the latest barcode specifications. This includes ISBN 13, the new 13-digit ISMN, GS1 DataBar-14, GS1 DataBar Limited, GS1 DataBar Stacked, GS1 DataBar Truncated and GS1-128.

more info

Oct 3, 2007

SmartCodeStudio(v4.0)
This version updates the software with a MICR (Magnetic Ink Character Recognition) feature that facilitates the printing of checks using magnetic ink. A new datasource, known as Pick List, is introduced to let users define a list of items quickly as an alternative to database. Also, a few barcodes helpers are improved and the UCCEAN dialog has been extended to support custom application identifiers.

more info

Aug 1, 2007

SmartCodeDeveloper 2.8
SmartCodeDeveloper .Net Barcode Software Control updated to work with Crystal Reports, Web Services, Databinding and Windows Presentation Foundation (.Net 3).

more info

TechnoRiverStudio is  one of the most innovative and  productive label design and print tools available. It is currently being used by many Fortune 500 companies including hospitals, universities, manufacturers, retailers, municipalities, and government institutions in many different countries around the world.

Product Overview
Product Brochure (PDF)
Editions
Frequently Asked Questions
General Support
Downloads
Resellers
Awards
Testimonials

COPYRIGHT (C) 2004-2006 ALL RIGHTS RESERVED, TECHNORIVER
HOME  ::  PURCHASE  ::  DOWNLOADS  ::  SUPPORT  ::  OUR PRODUCTS  ::  RESELLERS  ::  ABOUT US