Hi,
I need some help please.
I use a DomainService with following service method and autocomplete:
-------------------------------------
@Named("DeliverableService")
@DomainService(menuOrder = "3", repositoryFor = Deliverable.class)
public class DeliverableService {
...
@NotContributed
@MemberOrder(sequence = "2")
@Named("Create New Deliverable")
public Deliverable createNew(final @Named("DeliverableName") String
deliverableName,
final @Named("DeliverableDescription") String
deliverableDescription,
final @Named("DeliGroup") DeliGroup deliGroup
) {
Deliverable deliverable =
container.newTransientInstance(Deliverable.class);
deliverable.setDeliverableName(deliverableName);
deliverable.setDeliverableDescription(deliverableDescription);
deliverable.setDeliGroup(deliGroup);
deliGroup.addToDeliverables(deliverable);
container.persistIfNotAlready(deliverable);
return deliverable;
}
public List<DeliGroup> autoComplete2CreateNew(final @MinLength(1)
String search) {
return DBUtils.findAllByNameContains(container,
DeliGroup.class, search);
}
...
-------------------------------------
now I want to call this service over the rest interface.
I think the URL should be
http://localhost:8080/restful/services/DeliverableService/actions/createNew/invoke
I tried to test it over the "RESTClient" Plugin for Firefox with following JSON
String
JSON String:
{
"deliverableName": {"value": "NAME_ABC"},
"deliverableDescription": {"value": "DESC_ABC"},
"deliGroup": {
"historyId": { "value": "1"},
"deliGroupName": { "value": "Factored" }
}
}
After removing the "deliGroup" part in DomainService class, and in the JSON
String, it was working.
{
"deliverableName": {"value": "NAME_ABC"},
"deliverableDescription": {"value": "DESC_ABC"}
}
How has the JSON String to look?
Or when I try to connect over RestEasy, how to pass the parameters?
DefaultHttpClient client = new DefaultHttpClient();
UsernamePasswordCredentials credentials = new
UsernamePasswordCredentials("sven", "pass");
client.getCredentialsProvider().setCredentials(new AuthScope(AuthScope.ANY),
credentials);
ClientExecutor executor = createAuthenticatingExecutor(client);
ClientRequest request = new
ClientRequest("http://localhost:8080/restful/services/DeliverableService/actions/createNew/invoke",executor);
How to set the right parameters to post deliverableName, deliverableDescription
and DeliGroup?
ClientResponse<Deliverable> response = request.post(Deliverable.class);
Or are there other, better ways?
Sorry about the stupid questions, but I think I miss something in my knowledge.
br
Andreas