Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

Introduction

8/15/2019 - The elandings system has had public SOAP webservices available for use since ~2012. The 2012 webservices make use of older technology that make them them challenging to work with. Some of these technologies are likely to be retired from out from under us in the coming years, as Java upgrades.

The 2012 webservices require that you get an XML XSD definition from elandings staff, so that you can parse XML responses into Java or C# Objects.

The 2012 webservices make use of long lists of unnamed arguments. For example findUserLandingReports_001() has 25 arguements, that could appear to the developer as "arg1, arg2, arg3..." These long lists are arguements are hard for developers to work with.

The 2019 Webservices attempt to address these weaknesses.

The 2019 Webservices WSDL includes the XML XSD definition, so that Java or C# can automatically generate the Object classes for you.

The 2019 Webservices allow you to pass Objects with named elements to represent the complex list of arguments. These objects tend to be far easier to understand, think about and work with. This also allows IDEs to offer code completion recommendations to get and set values by name

The 2019 Webservices make use of updated libraries that should be safe as Java upgrades in the near future.

We would encourage 3rd-party systems to migrate to the 2019 webservices sooner rather than later. This will allow eLandings and our partners to be better positioned to navigate the changing seas of Java.

WSDL Locations

As with the 2012 Public Webservices, the 2019 Public Webservices have three environments: TEST, TRAINING and PRODUCTION

TEST

https://elandingstest.alaska.gov/elandings/ReportManagementV1Service?wsdl

TRAINING

https://elandingst.alaska.gov/elandings/ReportManagementV1Service?wsdl

PRODUCTION

https://elandings.alaska.gov/elandings/ReportManagementV1Service?wsdl

Credentials

Just like the 2012 Public webservices, the 2019 Public webservices require that you have a user_id and password. Processors are able to create the user_id and password for 3rd party contractors in production. In Test and Training, an eLandings support person can create the user_id and password.

Unlike the 2012 Public webservices, the 2019 Public webservices require an application id GUID. An elandings support person can create the applicaiton id GUID to identify your company.

Your application id GUID will be different for TEST, TRAINING and PRODUCTION.

Example

In this example we are using Apache Netbeans 11.0.

Before running netbeans, edit the /etc/netbeans.conf to include:

-J-Djavax.xml.accessExternalSchema=all

For more details see https://netbeans.org/kb/docs/websvc/jax-ws.html

Image Added


Create a new project of type Web Application

Image Added


Image Added


Image Added

Create a new class of type Web Service from WSDL 

Note: this will not be visible if you have not edited your netbeans.conf file

Image Added

https://elandingstest.alaska.gov/elandings/ReportManagementV1Service?wsdl

Image Added

Image Added

Netbeans will generate the elandings.java class for you.

Image Added

Notice that Netbeans was able to look at the WSDL and generate a number of Java Object classes. 

We will use the generated class ReportManagementV1Service.java to create our webservice connection.

Image Added

We will use the generated java class FindLandingReports.java as a parameter object to tell the webservice findLandingReports() what data we want to get from the server. In our case we will ask for a landing report by id (or landing report id). However, we could pass in as a parameter a fish ticket number or proc code or adfg vessel number, etc.

Image Added

Now Create the content of the MyClient.java class

Image Added

package com.mycompany.elandingsclient2019;

import java.math.BigInteger;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.xml.ws.BindingProvider;
import org.psmfc.er.webservices.FindLandingReports;
import org.psmfc.er.webservices.FindLandingReportsResponse;
import org.psmfc.er.webservices.GetToken;
import org.psmfc.er.webservices.GetTokenResponse;
import org.psmfc.er.webservices.InvalidInputException_Exception;
import org.psmfc.er.webservices.LandingReport;
import org.psmfc.er.webservices.ReportManagementV1;
import org.psmfc.er.webservices.ReportManagementV1Service;
import org.psmfc.er.webservices.SecurityAuthorizationException_Exception;
import org.psmfc.er.webservices.ServiceException_Exception;

public class MyClient {
String wsdlURL = "https://elandingstest.alaska.gov/elandings/ReportManagementV1Service?wsdl";
String applicationID = "...";//Ask for one of these from elandings support staff.
ReportManagementV1 serviceInstance;
String tokenId;

public MyClient(){
ReportManagementV1Service service = new ReportManagementV1Service();
serviceInstance = service.getReportManagementV1Port();
((BindingProvider) serviceInstance).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, wsdlURL);
}

public void login(String userId, String password) throws InvalidInputException_Exception, SecurityAuthorizationException_Exception, ServiceException_Exception{
GetToken parameters = new GetToken();
parameters.setUserId(userId);
parameters.setPassword(password);
GetTokenResponse token = serviceInstance.getToken(parameters, applicationID);
Logger.getLogger(MyClient.class.getName()).log(Level.INFO, "Token: "+token.getReturn());
tokenId = token.getReturn();
}

public LandingReport getLandingReport(BigInteger id) throws InvalidInputException_Exception, SecurityAuthorizationException_Exception, ServiceException_Exception{
FindLandingReports parameters = new FindLandingReports();
parameters.setId(id);
FindLandingReportsResponse r = serviceInstance.findLandingReports(parameters, applicationID, tokenId);
return r.getReturn().get(0);
}

public static void main(String[] args){

try {
MyClient c = new MyClient();
String userId = "...";//Get from Processor or elandings support
String password = "...";//Get from Processor or elandings support
c.login(userId, password);
BigInteger landingReportId = BigInteger.valueOf(18378245);
LandingReport lr = c.getLandingReport(landingReportId);
Logger.getLogger(MyClient.class.getName()).log(Level.INFO, "Landing Report ID: "+lr.getLandingReportId() + " last edited by "+lr.getDataEntryUser());
} catch (InvalidInputException_Exception ex) {
Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null, ex);
} catch (SecurityAuthorizationException_Exception ex) {
Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null, ex);
} catch (ServiceException_Exception ex) {
Logger.getLogger(MyClient.class.getName()).log(Level.SEVERE, null, ex);
}

}

}//End of Class


Image Added

Get a user id and password from elandings support or a processor (if working against production).

In this example we will attempt to pull a landing report that we know exists from elandings test for the user tturbot.

Image Added

If we run our file we should get an output of:

INFO: Landing Report ID: 18378245 last edited by AMARX

Image Added