Sha*_*ifA 0 java web-services acumatica
有没有人用Java语言编写Acumatica Web服务?我们需要Acumatica中任何屏幕的示例代码.
谢谢谢里夫A.
谢里夫
这是我很久以前写的命令行示例.在此示例中使用以下假设:
导入Web服务WSDL定义文件,并在AR303000包中生成代理类.
private static String getCookie(BindingProvider port) {
Map<String, ?> headers = (Map<String, ?>) port.getResponseContext().get(MessageContext.HTTP_RESPONSE_HEADERS);
StringBuilder sb = new StringBuilder();
List<String> cookie = (List<String>) headers.get("Set-Cookie");
for (String c : cookie) {
int idx = c.indexOf(";");
if (idx != -1) {
sb.append(c.substring(0, idx));
} else
sb.append(c);
sb.append("; ");
}
return sb.toString();
}
private static void setCookie(BindingProvider port, String value) {
port.getRequestContext().put(MessageContext.HTTP_REQUEST_HEADERS, Collections.singletonMap("Cookie", Collections.singletonList(value)));
}
public static void main(String[] args) {
Screen service = new Screen();
ScreenSoap screen = service.getScreenSoap();
LoginResult lres = screen.login("admin", "123");
String cookie = getCookie((BindingProvider) screen);
setCookie((BindingProvider) screen, cookie);
Content content = screen.getSchema();
ArrayOfCommand commands = new ArrayOfCommand();
commands.getCommand().add(content.getCustomerSummary().getServiceCommands().getEveryCustomerID());
commands.getCommand().add(content.getCustomerSummary().getCustomerName());
commands.getCommand().add(content.getGeneralInfoMainAddress().getCity());
ArrayOfArrayOfString result = screen.export(commands, null, 0, true, true);
List<ArrayOfString> lines = result.getArrayOfString();
for (int i = 0; i < lines.size(); i++)
{
List<String> currentLine = lines.get(i).getString();
System.out.printf("%s (%s)\n", currentLine.get(0), currentLine.get(1));
}
}
}
Run Code Online (Sandbox Code Playgroud)