简体   繁体   English

smartGWT rpc的服务器端访问数据

[英]Server side access data for smartGWT rpc

On the server side I want to know how to access data used in an RPCRequest from SmartGwt. 在服务器端,我想知道如何从SmartGwt访问RPCRequest中使用的数据。

Here is the SmartGwt client code: 这是SmartGwt客户端代码:

  private void update() {
        RPCRequest request = new RPCRequest();
        request.setData("RPC text from client");
        request.setActionURL("/Empi-MT/resources/empi/update");
        request.setContentType("text/xml");

        RPCManager.sendRequest(request,
            new RPCCallback() {

                public void execute(RPCResponse response, Object obj, RPCRequest request) {
                    SC.say("Response from the server:" + obj);
                }
            });
    }

Here is the RESTful java server code . 这是RESTful Java服务器代码。

    @POST
    @Consumes("text/xml")
    @Produces("text/xml")
    @Path("/update")
    public String update() {
        return "We got to here";
    }

This trivial code works fine, but now I need to know how to access the data that was put into the RPCRequest. 这个简单的代码可以正常工作,但是现在我需要知道如何访问RPCRequest中的数据。 How do I do that in the server code? 如何在服务器代码中做到这一点?

Thanks, 谢谢,

You look like you may be heading in the wrong direction; 您看起来好像朝着错误的方向前进; if this "update" operation is a CRUD operation on some object, you want to using DataSources - take a look at the QuickStart overview of Data Integration, focusing on RestDataSource. 如果此“更新”操作是对某些对象的CRUD操作,则要使用DataSources-查看“数据集成”的“快速入门”概述,重点是RestDataSource。

http://www.smartclient.com/releases/SmartGWT_Quick_Start_Guide.pdf http://www.smartclient.com/releases/SmartGWT_Quick_Start_Guide.pdf

Also you seem to be starting down the road of using generated REST services, this is almost always wrong - see this FAQ: 另外,您似乎正在开始使用生成的REST服务,这几乎总是错误的-请参阅以下常见问题解答:

http://forums.smartclient.com/showthread.php?t=8159#aExistingRest http://forums.smartclient.com/showthread.php?t=8159#aExistingRest

Finally if this really is not a CRUD operation, you want to set useSimpleHttp on the RPCRequest, and then the docs for this property explain the different ways data can be sent. 最后,如果这真的不是CRUD操作,则要在RPCRequest上设置useSimpleHttp,然后此属性的文档说明可以发送数据的不同方式。

http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/rpc/RPCRequest.html#getUseSimpleHttp () http://www.smartclient.com/smartgwtee/javadoc/com/smartgwt/client/rpc/RPCRequest.html#getUseSimpleHttp ()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM