我是azure逻辑应用的新手。我的目标是将一些变量发送到逻辑应用程序(通过java服务代码,然后使用提供的POST URL作为REST API调用请求触发器)并获取响应为JSON。
目前我已创建了一个请求触发器,JSON架构如下所示: -
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {},
"id": "http://example.com/example.json",
"properties": {
"CustomerName": {
"type": "string"
},
"InvoiceFee": {
"type": "integer"
},
"InvoiceNo": {
"type": "integer"
}
},
"required": [
"CustomerName",
"InvoiceFee",
"InvoiceNo"
],
"type": "object"
}
从请求触发器,我将指向响应操作,并将以下内容作为JSON响应返回。
{
"CustomerName": @{triggerBody()['CustomerName']},
"InvoiceFee": @{triggerBody()['InvoiceFee']},
"InvoiceNo": @{triggerBody()['InvoiceNo']}
}
屏幕截图如下: -
请您提供一些如何从java服务访问逻辑应用程序的参考链接?
我不知道如何传递自定义创建的对象,使对象的参数映射到“CustomerName”,“InvoiceNo”,“InvoiceFee”属性。
我创建的java服务代码如下: -
InvoiceDTO invoiceDTOObject2 = new InvoiceDTO();
invoiceDTOObject2.setCustomerName("Sakthivel");
invoiceDTOObject2.setInvoiceNo(123);
invoiceDTOObject2.setInvoiceFee(4000);
ResteasyClient client = new ResteasyClientBuilder().build();
ResteasyWebTarget target = client.target("URL TO PROVID").resolveTemplate("properties", invoiceDTOObject2);
Response response = target.request().get();
String jsonResponse = response.readEntity(String.class);
System.out.println("JSON Reponse "+jsonResponse);
答案 0 :(得分:0)
查看您的代码
Response response = target.request().post( InvoiceDTO.entity(invoiceDTOObject2, MediaType.APPLICATION_JSON));
您正在进行GET操作。您的Logic App HTTP Trigger将要求您使用InvoiceDTO-entity作为正文(序列化为JSON)执行POST操作。
所以应该看起来像这样:
declaration: true
不确定它是否100%正确,我的java有点生疏,但这是一般的想法。