use of org.example.customers.Customer in project tesb-rt-se by Talend.
the class CustomerServiceClient method useCustomerServiceSoap.
public void useCustomerServiceSoap(String[] args) throws Exception {
final String address = "http://localhost:" + port + "/services/jaxws";
System.out.println("Using SOAP CustomerService");
Service service = Service.create(CustomerServiceService.SERVICE);
service.addPort(CustomerServiceService.CustomerServicePort, SOAPBinding.SOAP11HTTP_BINDING, address);
CustomerService customerService = service.getPort(CustomerService.class);
Customer customer = createCustomer("Barry");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Barry");
printCustomerDetails(customer);
try {
customerService.getCustomerByName("Smith");
throw new RuntimeException("Exception is expected");
} catch (NoSuchCustomerException ex) {
System.out.println("NoSuchCustomerException : Smith");
}
}
use of org.example.customers.Customer in project tesb-rt-se by Talend.
the class CustomerServiceClient method useCustomerServiceRest.
public void useCustomerServiceRest(String[] args) throws Exception {
JAXBElementProvider provider = new JAXBElementProvider();
provider.setUnmarshallAsJaxbElement(true);
provider.setMarshallAsJaxbElement(true);
List<Object> providers = new ArrayList<Object>();
providers.add(provider);
providers.add(new ResponseExceptionMapper<NoSuchCustomerException>() {
@Override
public NoSuchCustomerException fromResponse(Response r) {
return new NoSuchCustomerException();
}
});
CustomerService customerService = JAXRSClientFactory.createFromModel("http://localhost:" + port + "/services/jaxrs", CustomerService.class, "classpath:/data/model/CustomerService-jaxrs.xml", providers, null);
System.out.println("Using RESTful CustomerService");
Customer customer = createCustomer("Smith");
customerService.updateCustomer(customer);
customer = customerService.getCustomerByName("Smith");
printCustomerDetails(customer);
customer = customerService.getCustomerByName("Barry");
if (customer != null) {
throw new RuntimeException("Barry should not be found");
}
System.out.println("Status : " + WebClient.client(customerService).getResponse().getStatus());
try {
customerService.getCustomerByName("John");
throw new RuntimeException("Exception is expected");
} catch (NoSuchCustomerException ex) {
System.out.println("NoSuchCustomerException : John");
}
}
use of org.example.customers.Customer in project tesb-rt-se by Talend.
the class CustomerServiceImpl method getCustomersByName.
public List<Customer> getCustomersByName(String name) throws NoSuchCustomerException {
Customer customer = getCustomerByName(name);
List<Customer> customers = new ArrayList<Customer>();
customers.add(customer);
return customers;
}
use of org.example.customers.Customer in project tesb-rt-se by Talend.
the class CustomerServiceClient method createCustomer.
private Customer createCustomer(String name) {
Customer cust = new Customer();
cust.setName(name);
cust.getAddress().add("Pine Street 200");
Date bDate = new GregorianCalendar(2009, 01, 01).getTime();
cust.setBirthDate(bDate);
cust.setNumOrders(1);
cust.setRevenue(10000);
cust.setShares(new BigDecimal(1.5));
cust.setType(CustomerType.BUSINESS);
return cust;
}
Aggregations