我正在尝试使用AMF连接API发送AMF消息,但收到如下所示的错误。
ClientStatusException
message: Unsupported AMF version
我使用blazeds-core-4.0.1.21287.jar来实现此目的。
下面是我的代码。
String url = "https://10.222.73.251:9443/vsphere-client/#";
try {
amfConnection.connect(url);
System.out.println(amfConnection.getUrl());
} catch (ClientStatusException cse) {
System.out.println("Error connecting url: " + cse);
return;
}
try {
amfConnection.addHttpRequestHeader("Cookie",
"6250CED9FBC7D5894B79973DEC1503A6");
amfConnection.addHttpRequestHeader("Content-type",
"application/x-amf");
amfConnection.setAmfTrace(new AmfTrace());
//amfConnection.setObjectEncoding(3);
System.out.println(amfConnection.getObjectEncoding());
CommandMessage cmsg = new CommandMessage();
cmsg.setOperation(CommandMessage.CLIENT_PING_OPERATION);
cmsg.setMessageId(UUIDUtils.createUUID());
cmsg.setHeader(Message.FLEX_CLIENT_ID_HEADER, "706E5399-D81A-11C8-11F7-BE5F1940632E");
cmsg.setHeader(Message.ENDPOINT_HEADER, "amf");
AcknowledgeMessage ack = (AcknowledgeMessage)amfConnection.call(null, cmsg);
任何帮助都是感激不尽的。:)
1条答案
按热度按时间2uluyalo1#
我遇到了同样的问题,原因是服务器需要一个“自包含的AMF包”。
请访问https://en.wikipedia.org/wiki/Action_Message_Format#AMF_self-contained_packet
这基本上意味着您需要在“正常”AMF消息前面添加以下字节: