我正在尝试从我的原生 android 应用程序中发布一些数据。
本机代码:
WLProcedureInvocationData invocationData = new WLProcedureInvocationData("TaskAdapter", "updateTask");
int taskId = Integer.parseInt(tvTaskId.getText().toString());
String assignedTo = tvAssignedTo.getText().toString();
String address = "";
String description = "";
String latitude = "5.0";
String longitude = "5.0";
String status = "5.0";
String comments = "5.0";
String lastupdate = "5.0";
String userLatitude = "5.0";
String userLongitude = "5.0";
String userLocation = "5.0";
String photoData = "5.0";
Object[] parameters = new Object[]{
taskId,
assignedTo,
description,
address,
latitude,
longitude,
status,
comments,
lastupdate,
userLatitude,
userLongitude,
userLocation,
photoData
};
invocationData.setParameters(parameters);
WLRequestOptions options = new WLRequestOptions();
options.setTimeout(30000);
client.getInstance().invokeProcedure(invocationData, new MyInvokeListener(), options);
适配器代码:
function updateTask(id) {
var input = {
method : 'PUT',
returnedContentType : 'json',
path : '/Api/Task?taskid=' + id
};
return WL.Server.invokeHttp(input);
}
适配器 XML:
<?xml version="1.0" encoding="UTF-8"?>
<!--
Licensed Materials - Property of IBM
5725-I43 (C) Copyright IBM Corp. 2011, 2013. All Rights Reserved.
US Government Users Restricted Rights - Use, duplication or
disclosure restricted by GSA ADP Schedule Contract with IBM Corp.
-->
<wl:adapter name="TaskAdapter" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:wl="http://www.ibm.com/mfp/integration" xmlns:http="http://www.ibm.com/mfp/integration/http">
<displayName>TaskAdapter</displayName>
<description>TaskAdapter</description>
<connectivity>
<connectionPolicy xsi:type="http:HTTPConnectionPolicyType">
<protocol>http</protocol>
<domain>testmeternative.vdot.virginia.gov</domain>
<port>80</port>
<connectionTimeoutInMilliseconds>30000</connectionTimeoutInMilliseconds>
<socketTimeoutInMilliseconds>30000</socketTimeoutInMilliseconds>
<maxConcurrentConnectionsPerNode>50</maxConcurrentConnectionsPerNode>
<!-- Following properties used by adapter's key manager for choosing specific
certificate from key store <sslCertificateAlias></sslCertificateAlias> <sslCertificatePassword></sslCertificatePassword> -->
</connectionPolicy>
</connectivity>
<procedure name="getAllTasks" />
<procedure name="updateTask" />
</wl:adapter>
我不确定我是否以正确的方式发送身体。此外,我如何将id
(参数)发送到适配器函数。
当我在 Eclipse 中单击Call Mobile First Adapter时,它向我显示过程名称,但GET
下拉菜单中的 REST 调用类型,我希望它为PUT
.