enunciate

articulate your web api.

Step 1: Write The Code

We'll start by defining the domain of our app. We'll define a persona with an id, an alias, an email address, a name, and a picture. The name is a complex structure, made up of a given name and a surname. We'll also define a link between two personas and a social group consisting of an id, a group leader, the group members, and whether the group is exclusive.

Next, we'll define the services available for our domain data. The PersonaService will define the operations available on a persona. This includes operations for reading a persona, reading multiple personas, storing a persona, and deleting a persona. The LinkageService will carry the operations that deal with linking and grouping personas. These operations include creating a link between two personas, creating a social group, adding someone to a social group, and reading the social groups of a given persona. Note that our two service interfaces are annotated with the @javax.jws.WebService annotation to define them as web serivces, and the two exceptions are annotated with @javax.xml.ws.WebFault to mark them as web faults.

We also define the possible exceptions that can get thrown, including a PermissionDeniedException when trying to create a link between two people, and an ExclusiveGroupException when trying to add a persona to an exclusive group.

After having defined our service interfaces, we create our implementation classes, PersonaServiceImpl and LinkageServiceImpl. Notice that the implementation classes reference their Web service interfaces with the @javax.jws.WebService annotation.

So, we've got our domain defined along with some services that operate on the domain. The source code structure looks like this:

src | |----com | |----ifyouwannabecool | |----api | | | |----ExclusiveGroupException.java | |----LinkageService.java | |----PermissionDeniedException.java | |----PersonaService.java | |----domain | | | |----link | | | | | |----Link.java | | |----SocialGroup.java | | | |----persona | | | |----Name.java | |----Persona.java | |----impl | |----LinkageServiceImpl.java |----PersonaServiceImpl.java

Step 2: Enunciate the API >>