|
| Step 1: Setup your development environment | |
|
We will be using
| |
| | |
| Step 2: Authentication: ( https://www.ebsuite.com/cxf/SessionAuthenticatorAPI?wsdl ) | |
| 2A> Generating Java Classes from WSDL | |
|
C:> WSDL2Java https://www.ebsuite.com/cxf/SessionAuthenticatorAPI?wsdl This should generate several web service classes in your file system. | |
Using WSDL2Java to generate Stub Classes
| |
Result Folder
| |
| 2B> Using these classes to authenticate:
Code Sample 1: SimpleTest1 (com.ebsuite.common.tutorial)
| |
package com.ebsuite.common.tutorial;
import java.io.*;
import java.util.*;
import com.ebsuite.login.SessionAuthenticatorAPIServiceSoapBindingStub;
public class SimpleTest1 {
public static void doTest() throws Exception
{
java.net.URL _endpoint = new java.net.URL( "https://www.ebsuite.com/cxf/SessionAuthenticatorAPI" );
SessionAuthenticatorAPIServiceSoapBindingStub _stub =
new SessionAuthenticatorAPIServiceSoapBindingStub(_endpoint, new org.apache.axis.client.Service() );
System.out.println( "[" + _stub.simpleAuthenticate( "******", "*************************" ) + "]" );
}
public static void main ( String[] params )
{
try { doTest(); } catch (Exception e) { e.printStackTrace(); }
}
}
| |
| Compile, Run, and Result If success, the result should start with "[SESSIONID:" . Otherwise it should display the error message.
| |
Alternatively, we can use loginAuthenticate(company_name,user_name,password) to authenticate.
package com.ebsuite.common.tutorial;
import java.io.*;
import java.util.*;
import com.ebsuite.login.SessionAuthenticatorAPIServiceSoapBindingStub;
public class SimpleTest1 {
public static void doTest() throws Exception
{
java.net.URL _endpoint = new java.net.URL( "https://www.ebsuite.com/cxf/SessionAuthenticatorAPI" );
SessionAuthenticatorAPIServiceSoapBindingStub _stub =
new SessionAuthenticatorAPIServiceSoapBindingStub(_endpoint, new org.apache.axis.client.Service() );
System.out.println( "[" + _stub.loginAuthenticate( "*****", "*****", "*****" ) + "]" );
}
public static void main ( String[] params )
{
try { doTest(); } catch (Exception e) { e.printStackTrace(); }
}
}
| |
| | |
| Step 3: Post Authentication: Query Organization Records. ( https://www.ebsuite.com/cxf/OrgAPI?wsdl ) | |
| 3A> Generating Java Classes from WSDL | |
|
C:> WSDL2Java https://www.ebsuite.com/cxf/OrgAPI?wsdl This should generate several web service classes in your file system. | |
Using WSDL2Java to generate Stub Classes
| |
Result Folder
| |
| 3B> Using these classes to query Organization Records:
Code Sample 2: SimpleTest2 (com.ebsuite.common.tutorial)
| |
package com.ebsuite.common.tutorial;
import java.io.*;
import java.util.*;
import com.ebsuite.login.SessionAuthenticatorAPIServiceSoapBindingStub;
import com.ebsuite.sales.api.OrgAPIServiceSoapBindingStub;
import com.ebsuite.sales.api.OrganizationList;
import com.ebsuite.sales.api.Organization;
public class SimpleTest2 {
public static void doTest() throws Exception
{
java.net.URL _endpoint = new java.net.URL( "https://www.ebsuite.com/cxf/SessionAuthenticatorAPI" );
SessionAuthenticatorAPIServiceSoapBindingStub _stub =
new SessionAuthenticatorAPIServiceSoapBindingStub(_endpoint, new org.apache.axis.client.Service() );
String authResult = _stub.simpleAuthenticate( "******", "*******************" );
System.out.println( "[" + authResult + "]" );
if ( authResult.startsWith("SESSIONID:") )
{
String sessId = authResult.substring( 10 );
OrgAPIServiceSoapBindingStub orgApiStub = new OrgAPIServiceSoapBindingStub(
new java.net.URL( "https://www.ebsuite.com/cxf/OrgAPI" ), new org.apache.axis.client.Service() );
OrganizationList ol = orgApiStub.searchOrganizations( sessId, "ebs" );
Organization[] org = ol.getList();
System.out.println( " getAllOrganizations() return row # = " + org.length );
}
}
public static void main ( String[] params )
{
try { doTest(); } catch (Exception e) { e.printStackTrace(); }
}
}
| |
| Compile, Run, and Result In this example, there are 45 records returned for search result "ebs"
|