Before you start developing applications using the Concord Developer Outbound API with Java you will need the following:
JDK
You will need JDK, Download the latest version from http://www.oracle.com/technetwork/java/javase/downloads/index.html
Using WSImport
Generate Java Proxy Code
From the command prompt run
WSImport -keep -p FaxWS https://ws.concordfax.com/fax/v5/FaxWS.wsdl
This will generate the proxy classes (Including sources).
Using Proxy Code
import FaxWS.*;
import java.io.*;
public class SimpleSendFaxClass{
public static void main(String[] args){
String strUserId = ""; // User Id provided by Concord to you
String strPassword = ""; // Password
String strName = "test"; // Recipient Name
String strFaxNumber = "1xxxxxxxxxx"; // Fax number
String strFileName = "Default.tif"; // Fax file
// Read fax file to buffer
File file = new File(strFileName);
try
{
//create FileInputStream object
FileInputStream fin = new FileInputStream(file);
/*
* Create byte array large enough to hold the content of the file.
* Use File.length to determine size of the file in bytes.
*/
byte fileContent[] = new byte[(int)file.length()];
/*
* To read content of the file in byte array, use
* int read(byte[] byteArray) method of java FileInputStream class.
*
*/
fin.read(fileContent);
// Call Fax Method
FaxWS faxws= new FaxWS();
FaxWSPortType faxwsClient = faxws.getFaxWS();
System.out.println(faxwsClient.simpleSendFax(strUserId,strPassword,strName,strFaxNumber,fileContent));
}
catch(FileNotFoundException e)
{
System.out.println("File not found" + e);
}
catch(IOException ioe)
{
System.out.println("Exception while reading the file " + ioe);
}
}
} | |
Using WSDL2Java
You will need WSDL2Java tool for building Java proxies and skeletons from WSDL. Download it from http://ws.apache.org/axis/java/releases.html
Unzip to a folder and rename the folder to AXIS_HOME e.g c:\AXIS_HOME\
Environment Variables
After Installing the above, set these variables
Set CLASSPATH in Environment Variables, give path of jsse.jar
e.g C:\Program Files\Java\jdk1.5.0_06\jre\lib\jsse.jar;
Set PATH in Environment Varible, give Path of bin dir
e.g C:\Program Files\Java\jdk1.5.0_06\bin
Set JAVA_HOME in system variables, give path of JDK dir
e.g C:\Program Files\Java\jdk1.5.0_06
Set AXIS_HOME to C:\AXIS_HOME\webapps\axis
Set AXIS_LIB %AXIS_HOME%\web-inf\lib
Set AXISCLASSPATH to %AXIS_LIB%\axis.jar;%AXIS_LIB%\commons-discovery-0.2.jar;%AXIS_LIB%\commons-logging-1.0.4.jar;%AXIS_LIB%\jaxrpc.jar;%AXIS_LIB%\saaj.jar;%AXIS_LIB%\log4j-1.2.8.jar;%AXIS_LIB%\xml-apis.jar;%AXIS_LIB%\xercesImpl.jar;%AXIS_LIB%\tools.jar;%AXIS_LIB%\wsdl4j-1.5.1.jar
Append to CLASSPATH ;%AXISCLASSPATH%;
Generate java proxy classes
Run java org.apache.axis.wsdl.WSDL2Java (WSDL-file-URL)
e.g. java org.apache.axis.wsdl.WSDL2Java https://ws.concordfax.com/fax/v5/faxws.wsdl