1. | Find the Implementation of the GetPersonNames method. Depending on your patch version this could be something like: |
MyPersonNameStructure result = (MyPersonNameStructure)sql( MyPersonNameStructure.class, "GET_PERSON_NAMES" , new Object[]{ id } );
/* delete following 2 lines if you want HTT 204 success code in case of an empty recordset */
if(result==null)
throw new javax.ws.rs.WebApplicationException(404);
return result;
2. | Copy this code (this entire text) to the clipboard. |
3. | Go to the Implementation of the PutPersonNames method and append the copied text to this code. Depending on your patch version of USoft, the result of this paste action could be something like: |
Integer count = (Integer) sql(Integer.class, "SET_PERSON_NAMES", new Object[]{ objMyPersonNameStructure, id } );
/* return http error 404 if no records updated */
if(count.intValue() == 0)
throw new javax.ws.rs.WebApplicationException(404);
MyPersonNameStructure result = (MyPersonNameStructure)sql( MyPersonNameStructure.class, "GET_PERSON_NAMES" , new Object[]{ id } );
/* delete following 2 lines if you want HTT 204 success code in case of an empty recordset */
if(result==null)
throw new javax.ws.rs.WebApplicationException(404);
return result;
4. | Notice that you now have 2 different code snippets dealing with the eventuality that no records were updated. Shorten the code by choosing just one, and erasing the other, so that the end result becomes something like: |
Integer count = (Integer) sql(Integer.class, "SET_PERSON_NAMES", new Object[]{ objMyPersonNameStructure, id } );
MyPersonNameStructure result = (MyPersonNameStructure)sql( MyPersonNameStructure.class, "GET_PERSON_NAMES" , new Object[]{ id } );
/* delete following 2 lines if you want HTT 204 success code in case of an empty recordset */
if(result==null)
throw new javax.ws.rs.WebApplicationException(404);
return result;
5. | For the PutPersonNames method, manually add a return parameter in the Parameters tab with the following settings: |
•Name: Result •Type: MyPersonNameStructure •Return Parameter: Yes
6. | Publish and Restart the server where you are publishing your REST service. Test that the REST call of the previous help topic: |
http://localhost:8090/mycustomservice/PersonNames/17
| now returns not just the "200 OK" HTTP status code, but also the result data of the manipulation. |
|