Versions Compared

Key

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

...

Code Block
java
java
package com.example.customerservice;

@XmlAccessorType( XmlAccessType.FIELD )
public class Customer {
    String name;
    String\[\] address;
    int numOrders;
    double revenue;
    BigDecimal test;
    Date birthDate;
    CustomerType type;
}

...

Code Block
package com.example.customerservice;

@WebFault(name="NoSuchCustomer")
@XmlAccessorType( XmlAccessType.FIELD )
public class NoSuchCustomerException extends RuntimeException {
	    /**
	      * We only define the fault details here. Additionally each fault has a message
	      * that should not be defined separately
	      */
	    String customerName;
}

Service definition

Code Block
java
java
package com.example.customerservice;

@WebService
public interface CustomerService {
    public Customer[] getCustomersByName(@WebParam(name="name") String name) throws NoSuchCustomerException;
}

As you can see only two annotations are necessary here. @WebService marks the interface as a service and @Webparam is necessary as Java will else loose lose the name of the parameter and the wsdl will contain arg0 instead of the desired name. Using the @WebService annotation you can also customize the port name and service name.

...