I have created service using service builder and put the sample entity in liferay service.xml file.
My service.xml
<!DOCTYPE service-builder PUBLIC "-//Liferay//DTD Service Builder 6.2.0//EN" "http://www.liferay.com/dtd/liferay-service-builder_6_2_0.dtd">
<service-builder package-path="com.temp">
<namespace></namespace>
<entity name="Student" local-service="true" remote-service="true">
</entity>
<entity name="Foo" uuid="true" local-service="true" remote-service="true">
<!-- PK fields -->
<column name="fooId" type="long" primary="true" />
<!-- Group instance -->
<column name="groupId" type="long" />
<!-- Audit fields -->
<column name="companyId" type="long" />
<column name="userId" type="long" />
<column name="userName" type="String" />
<column name="createDate" type="Date" />
<column name="modifiedDate" type="Date" />
<!-- Other fields -->
<column name="field1" type="String" />
<column name="field2" type="boolean" />
<column name="field3" type="int" />
<column name="field4" type="Date" />
<column name="field5" type="String" />
<!-- Order -->
<order by="asc">
<order-column name="field1" />
</order>
<!-- Finder methods -->
<finder name="Field2" return-type="Collection">
<finder-column name="field2" />
</finder>
<!-- References -->
<reference package-path="com.liferay.portlet.asset" entity="AssetEntry" />
<reference package-path="com.liferay.portlet.asset" entity="AssetTag" />
</entity>
</service-builder>
after building the service I have added one method in FooServiceImpl.java
as below,
@JSON
public JSONObject verifyService (String action){
System.out.println("action----->"+action);
JSONObject actionData=JSONFactoryUtil.createJSONObject();
actionData.put("success", true);
return actionData;
}
I build the service and able to access it via localhost:8080/api/jsonws
with admin credential.
Now when I call this service with below curl command
curl http://localhost:8080/api/jsonws/XXXX-Portlets.foo/verify-service -u test@liferay.com:test -d action='temp'
I am able to get the action parameter value in my implemented method. Now I would like to get below value posted from curl,
curl http://localhost:8080api/jsonws/XXXXX-Portlets.foo/verify-service -u test@liferay.com:test -d '{"action":"verify"}'
I am not able to get this json in my web service!!
I have tried adding the following
curl -H "Content-Type: application/json" -H "Accept: application/json -XPOST ...."
to curl and change the parameter type from string to jsonObject but no luck.
Is there any annotation I'm missing here?