Versions Compared

Key

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

Introduction

...

Netbeans will generate the elandings.java class for you.

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 Modified

package com.mycompany.elandingsclient2019;

...

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, String fishTicketNumber) throws InvalidInputException_Exception, SecurityAuthorizationException_Exception, ServiceException_Exception{
FindLandingReports parameters = new FindLandingReports();
parameters.setId(id);
parameters.setFishTicket(fishTicketNumber);
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);
String fishTicketNumber = "E19 144148";
LandingReport lr = c.getLandingReport(landingReportId, fishTicketNumber);
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

...

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

Image Modified

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

INFO: Landing Report ID: 18378245 last edited by AMARX

Image Modified