Methods Summary |
---|
private static final java.lang.String | carname(int pid)
switch (pid % 4) {
case 1:
return "AM-Vantage-2k6";
case 2:
return "BMW-M3-2k6";
case 3:
return "MB-SLR-2k6";
case 0:
default:
return "Porsche-911-2k6";
}
|
private static final void | displayPhotoAndPrice(Quote quote)
if (quote.getPhoto() != null) {
try {
String carName = carname(pid);
File file = new File(carName + ".jpeg");
ImageIO.write((BufferedImage)quote.getPhoto(), "jpeg", file);
String imageLocation = file.getAbsolutePath();
System.out.printf("Photo is copied to \"%s\" file.\n", imageLocation);
} catch (IOException e) {
e.printStackTrace();
}
} else {
System.out.println("No photo received.");
}
System.out.println("Quoted price: " + quote.getPrice());
System.out.println("Success!");
|
public static Quote | getQuote(java.lang.String endpoint, java.lang.String spid)Invokes the web service.
RetailerQuoteService service;
try {
service = new RetailerQuoteService(new URL(WSDL_LOCATION), SERVICE);
} catch (MalformedURLException e) {
throw new WebServiceException(e);
}
if (endpoint == null || endpoint.equals("")) {
endpoint = ENDPOINT;
}
if (spid != null && spid != "")
pid = Integer.valueOf(spid);
RetailerPortType port = service.getRetailerPort();
System.out.printf("Invoking endpoint address \"%s\" for product id \"%s\".\n", endpoint, spid);
((BindingProvider)port).getRequestContext().put(BindingProvider.ENDPOINT_ADDRESS_PROPERTY, endpoint);
Quote quote = port.getPrice(pid);
return quote;
|
public static void | main(java.lang.String[] args)
String endpoint = System.getProperty("endpoint");
String pid = System.getProperty("pid");
Quote quote = getQuote(endpoint, pid);
displayPhotoAndPrice(quote);
|