//JAVA - stubs created using AXIS 2 client using WSDL2JAVA //Install AXIS2 WSDL2JAVA to create stubs //Command line stubs creation: //c:\axis2-1.6.2\axis2-1.6.2\bin>wsdl2java.bat -d adb -g -u -uri http://pcmiler.alk.com/APIs/SOAP/v1.0/service.svc?wsdl GetReports gr = new GetReports(); ReportRequest rr = new ReportRequest(); RequestHeader rh = new RequestHeader(); rh.setDataVersion(ver); rh.setRequestType("myRequest"); rr.setHeader(rh); ReportRequestBody repReqBody = new ReportRequestBody(); ReportRoute[] reportRoute = new ReportRoute[1]; ArrayOfReportRoute arrReportRoutes = new ArrayOfReportRoute(); ArrayOfStopLocation stopLocArr = new ArrayOfStopLocation(); StopLocation[] stopLocation = new StopLocation[2]; stopLocation[0] = new StopLocation(); Address add1 = new Address(); Address add2 = new Address(); add1.setZip(NewJFrame.oZip.getText()); add2.setZip(NewJFrame.dZip.getText()); //Set stop with Coords or Address - use only 1 // Coordinates coords0 = new Coordinates(); // coords0.setLat(NewJFrame.oZip.getText()); // coords0.setLon(NewJFrame.oLon.getText()); //stopLocation[0].setCoords(coords0); stopLocation[0].setRegion(DataRegion.NA); stopLocation[0].setAddress(add1); stopLocation[1] = new StopLocation(); add2.setZip(NewJFrame.dZip.getText()); stopLocation[1].setAddress(add2); stopLocArr.setStopLocation(stopLocation); reportRoute[0] = new ReportRoute(); reportRoute[0].setRouteId("ks"); reportRoute[0].setStops(stopLocArr); ReportOptions repOpts = new ReportOptions(); // repOpts.setTollDiscount("All"); //Tolls are premium feature repOpts.setIncludeFerryDistance(NewJFrame.includeFerrydist.isSelected()); RouteOptions routeOpts = new RouteOptions(); routeOpts.setBordersOpen(NewJFrame.bordersOpen.isSelected()); routeOpts.setOverrideRestrict(NewJFrame.overrideRest.isSelected()); routeOpts.setHighwayOnly(NewJFrame.hwyOnly.isSelected()); reportRoute[0].setReportingOptions(repOpts); reportRoute[0].setOptions(routeOpts); ArrayOfReportType aor = new ArrayOfReportType(); ReportType[] rt = new ReportType[0]; rt[0] = new MileageReportType(); aor.setReportType(rt); reportRoute[0].setReportTypes(aor); arrReportRoutes.setReportRoute(reportRoute); repReqBody.setReportRoutes(arrReportRoutes); rr.setBody(repReqBody); rr.setHeader(rh); gr.setRequest(rr); AuthHeader authHdr = new AuthHeader(); authHdr.setAuthorization(NewJFrame.apiKey.getText()); authHdr.setDate(rfc1123); GetReportsResponse rsp = null; try { rsp = svcStub.GetReports(gr, authHdr); repRsp = rsp.getGetReportsResult(); Report rpt = repRsp.getBody().getReports().getReport()[0]; if (rpt.getClass().equals(MileageReport.class)) { setMileageFields(repRsp.getBody().getReports().getReport()[0]); } } catch (Exception ex) { } private static void setMileageFields(Report report) { MileageReport mr = null; mr = (MileageReport) report; int mrptlen = mr.getReportLines().getStopReportLine().length - 1; String origin = "Origin: " + mr.getReportLines().getStopReportLine()[0].getStop().getAddress().getCity() + " ," +mr.getReportLines().getStopReportLine()[0].getStop().getAddress().getState() + " ," + mr.getReportLines().getStopReportLine()[0].getStop().getAddress().getZip(); String destination = "Origin: " + mr.getReportLines().getStopReportLine()[mrptlen].getStop().getAddress().getCity() + " ," +mr.getReportLines().getStopReportLine()[mrptlen].getStop().getAddress().getState() + " ," + mr.getReportLines().getStopReportLine()[mrptlen].getStop().getAddress().getZip(); String miles = mr.getReportLines().getStopReportLine()[mrptlen].getTMiles(); String totTime = mr.getReportLines().getStopReportLine()[mrptlen].getTHours(); }
This sample may use features that are only available in our Premium WebServices. Please refer to our Features page to confirm what feature level you currently subscribe to.