Setting up Netbeans for Java Development Against the API

The purpose of this document is to help API users set up their Java environment for JustWare API development using the Netbeans IDE.
  1. Install Java JDK (includes the JRE)     http://www.oracle.com/technetwork/java/javaee/downloads/index.html
  2. Install Netbeans IDE (Java EE Bundle)     http://netbeans.org/downloads/index.html
  3. Create a new Java Application
  4. Consume the API WSDL
    1. Add a new "Web Service Client" to your project (Note: If you do not have the option, make sure the "SOAP Web Services" plugin is installed).
    2. Specify the API WSDL URL - https://yourdomain/API_Directory/JustWareApi.svc?wsdl
    3. Click finish

Note:  At this point, you may see an error indicating that two schema declarations cause a collision in the ObjectFactory class.  To fix this, we need to set the jaxb property, generateElementProperty, to false.  We can accomplish this by adding a custom binding file to the web service client.  To do that:

  1. Save the following text as an .xml file:
    1. <jxb:bindings version="2.0" xmlns:jxb="http://java.sun.com/xml/ns/jaxb" xmlns:xs="http://www.w3.org/2001/XMLSchema"><jxb:globalBindings generateElementProperty="false" /></jxb:bindings>
  2. Right-click the web service client and select "Edit Web Service Attributes" 
  3. Go to the "WSDL Customization" tab and scroll to the bottom for "External Binding Files". 
  4. Add the .xml file from above and click OK.
The IDE will regenerate the source files and then you should be ready to start.  Try the following code snippet to determine if your setup is working properly:

public static void main(String[] args) {
        String userName = "domain\\username";
        String password = "password";

        // Create a client
        JustWareApi service = new JustWareApi(JustWareApi.class.getResource("https://localhost/JustWareApi/JustWareApi.svc?wsdl"));
        IJustWareApi client = service.getJustWareApi();
        ((BindingProvider) client).getRequestContext().put(BindingProvider.USERNAME_PROPERTY, userName);
        ((BindingProvider) client).getRequestContext().put(BindingProvider.PASSWORD_PROPERTY, password);

        //Verify you can hit the API
        int callerNameID = client.getCallerNameID();
        System.out.println("Caller Name ID: " + callerNameID);
    }

Feedback and Knowledge Base