I'm using rest service. My service accepts Employee object as an input for my JSON Post request. I'm using worklight adapter to call the service. Can any one help me in writing an example of how the code looks like.
我正在使用休息服务。我的服务接受Employee对象作为我的JSON Post请求的输入。我正在使用worklight适配器来调用该服务。任何人都可以帮我写一个代码如何的例子。
Sample:
public class Employee{
String id;
String name;
String address;
...
...
}
示例:public class Employee {String id;字符串名称;字符串地址; ......}
@Post
@Consumes(JSON)
@Produces(JSON)
public ResponseObject getSomeInfo(Employee emp){
.......
}
@Post @Consumes(JSON)@Produces(JSON)public ResponseObject getSomeInfo(Employee emp){.......}
Can any one help me with the code to write this adapter request?
任何人都可以帮我编写这个适配器请求的代码吗?
1 个解决方案
#1
3
I don't really understand what your question is asking, but if you are attempting to write a POST request inside a Worklight adapter you should start by reading the documentation around Worklight Adapters:
我真的不明白你的问题是什么,但如果你试图在Worklight适配器中编写POST请求,你应该首先阅读Worklight Adapters周围的文档:
Adapter Framework Overview: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_01_Adapter_framework_overview.pdf
适配器框架概述:http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_01_Adapter_framework_overview.pdf
HTTP适配器:http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_02_HTTP_adapter_-_Communicating_with_HTTP_back-end_systems.pdf
Invoking Adapter Procedures From the Client: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_06_Invoking_adapter_procedures_from_client_applications.pdf
从客户端调用适配器过程:http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_06_Invoking_adapter_procedures_from_client_applications.pdf
As a quick example I can show you the structure of a really basic POST request adapter:
作为一个简单的例子,我可以向您展示一个非常基本的POST请求适配器的结构:
function postSomeInfo(Employee emp){
var input = {
method : 'post',
returnedContentType : 'application/json',
path : path,
body:{
contentType:'application/json',
content: emp.id
}
};
return WL.Server.invokeHttp(input); }
Looking at your method above it seems you are trying to create a GET method though (getsSomeInfo). Can you please elaborate on your question further if this does not help solve it.
看看上面的方法,你似乎正在尝试创建一个GET方法(getsSomeInfo)。如果这无法解决问题,请您进一步详细说明您的问题。
#1
3
I don't really understand what your question is asking, but if you are attempting to write a POST request inside a Worklight adapter you should start by reading the documentation around Worklight Adapters:
我真的不明白你的问题是什么,但如果你试图在Worklight适配器中编写POST请求,你应该首先阅读Worklight Adapters周围的文档:
Adapter Framework Overview: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_01_Adapter_framework_overview.pdf
适配器框架概述:http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_01_Adapter_framework_overview.pdf
HTTP适配器:http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_02_HTTP_adapter_-_Communicating_with_HTTP_back-end_systems.pdf
Invoking Adapter Procedures From the Client: http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_06_Invoking_adapter_procedures_from_client_applications.pdf
从客户端调用适配器过程:http://public.dhe.ibm.com/software/mobile-solutions/worklight/docs/v610/04_06_Invoking_adapter_procedures_from_client_applications.pdf
As a quick example I can show you the structure of a really basic POST request adapter:
作为一个简单的例子,我可以向您展示一个非常基本的POST请求适配器的结构:
function postSomeInfo(Employee emp){
var input = {
method : 'post',
returnedContentType : 'application/json',
path : path,
body:{
contentType:'application/json',
content: emp.id
}
};
return WL.Server.invokeHttp(input); }
Looking at your method above it seems you are trying to create a GET method though (getsSomeInfo). Can you please elaborate on your question further if this does not help solve it.
看看上面的方法,你似乎正在尝试创建一个GET方法(getsSomeInfo)。如果这无法解决问题,请您进一步详细说明您的问题。