小编Sas*_*imm的帖子

Spring Integration 3.0.1 Restful http-inbound-gateway不会将请求主体转换为对象

我试图使用Spring集成(3.0.1),以实现支持RESTful服务 XML和JSON请求和响应格式,使用INT-HTTP:入站网关.

我的代码基于Spring集成示例(尽管这不使用消息有效负载):

https://github.com/spring-projects/spring-integration-samples/tree/master/intermediate/rest-http

服务激活类:

@Service("httpOrderGateway")
public class HttpOrderGateway implements OrderGateway {

    private static final Logger LOGGER = Logger.getLogger(HttpOrderGateway.class);

    @Override
    public Message<CreateOrderResponse> createOrder(Message<CreateOrderRequest> orderRequest) {
        LOGGER.info("Received CreateOrderRequest headers: " + orderRequest.getHeaders());
        LOGGER.info("Received: " + orderRequest.getPayload());

        return MessageBuilder.withPayload(new CreateOrderResponse("Thank you for your order")).build();
    }

}
Run Code Online (Sandbox Code Playgroud)

Spring集成XML:

<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xsi:schemaLocation="http://www.springframework.org/schema/beans 
                            http://www.springframework.org/schema/beans/spring-beans.xsd
                            http://www.springframework.org/schema/integration 
                            http://www.springframework.org/schema/integration/spring-integration.xsd
                            http://www.springframework.org/schema/integration/http 
                            http://www.springframework.org/schema/integration/http/spring-integration-http.xsd
                            http://www.springframework.org/schema/oxm 
                            http://www.springframework.org/schema/oxm/spring-oxm.xsd"
       xmlns:int="http://www.springframework.org/schema/integration"
       xmlns:oxm="http://www.springframework.org/schema/oxm"
       xmlns:int-http="http://www.springframework.org/schema/integration/http">

    <int:annotation-config />  

    <int:channel id="orderRequestChannel" />
    <int:channel id="orderResponseChannel" />

    <int-http:inbound-gateway id="inboundOrderRequestGateway" 
                              supported-methods="POST"
                              request-channel="orderRequestChannel"
                              reply-channel="orderResponseChannel"
                              view-name="/order"
                              path="/services/order"
                              reply-timeout="50000">
    </int-http:inbound-gateway> …
Run Code Online (Sandbox Code Playgroud)

java spring spring-integration

5
推荐指数
1
解决办法
6572
查看次数

如何存入墨水!智能合约

我对智能合约有一些想法,我将使用 Ink 来实现它们!在基板上。

大多数这些想法都涉及调用者将存款存入智能合约,该合约将无限期持有,然后调用者可能能够在未来的某个时间点提取,具体取决于其他因素。

我找到了一个允许调用者退出智能合约的示例:

https://github.com/paritytech/ink/blob/master/examples/contract-transfer/lib.rs

这暗示了调用者进行存款的方法 - 该self.env().transferred_value()方法表明调用者可以/已经发送/发送价值。

我正在努力寻找一个将资金存入智能合约的示例。也许我在这里遗漏了一些基本的东西?

理想情况下,我想避免实现一个需要 2 个地址并从一个地址转移到另一个地址的函数(合约已经拥有并知道自己的地址!),而是有利于调用者发送金额,并将其存入智能合约。

我认为这可能通过智能合约方法实现,该方法不带参数,但不确定且完全不清楚合约将如何接收和持有资金。

寻找一个具体的代码示例来展示它是如何完整工作的,但也感谢任何评论来澄清或纠正我的(很可能是不正确的)理解。

提前致谢!

smartcontracts substrate rust-ink

1
推荐指数
1
解决办法
699
查看次数