使用“pafau k”,我们有 Java 服务器——它使用 protobuf——但它是写入套接字的。我认为我们有一些误解,因为 flex 可能适用于“http”协议——我说的对吗?
var callService:CallcenterService = new CallcenterService();
var simpleWebRPC:SimpleWebRPC = new SimpleWebRPC("0.0.0.0:1234/");
callService.sendFunction = xmlsock.send;
callService.getDefaults(new EmptyMessage(), function(result:*):void {
var response:Defaults = result as Defaults;
if (response){
trace("RPC call succeeded:", response);
}
else{
trace("RPC call failed:", ErrorEvent(result).text);
}
});
callService 是从 proto 生成的
message EmptyMessage {}
message Defaults {
required string xmlContents = 1;
}
service CallcenterService {
rpc getDefaults (EmptyMessage) returns (Defaults);
}
这是来自 java 服务器的错误:
com.googlecode.protobuf.pro.duplex.handler.ServerConnectRequestHandler exceptionCaught
WARNING: Exception caught during RPC connection handshake.
com.google.protobuf.InvalidProtocolBufferException: Protocol message tag had invalid wire type.
at com.google.protobuf.InvalidProtocolBufferException.invalidWireType(InvalidProtocolBufferException.java:78)
at com.google.protobuf.UnknownFieldSet$Builder.mergeFieldFrom(UnknownFieldSet.java:498)
at com.google.protobuf.GeneratedMessage$Builder.parseUnknownField(GeneratedMessage.java:438)
at com.googlecode.protobuf.pro.duplex.wire.DuplexProtocol$WirePayload$Builder.mergeFrom(DuplexProtocol.java:2565)
at com.googlecode.protobuf.pro.duplex.wire.DuplexProtocol$WirePayload$Builder.mergeFrom(DuplexProtocol.java:2450)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:300)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:238)
at com.google.protobuf.AbstractMessageLite$Builder.mergeFrom(AbstractMessageLite.java:202)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:738)
at com.google.protobuf.AbstractMessage$Builder.mergeFrom(AbstractMessage.java:238)
at org.jboss.netty.handler.codec.protobuf.ProtobufDecoder.decode(ProtobufDecoder.java:101)
at org.jboss.netty.handler.codec.oneone.OneToOneDecoder.handleUpstream(OneToOneDecoder.java:72)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:302)
at org.jboss.netty.handler.codec.frame.FrameDecoder.unfoldAndFireMessageReceived(FrameDecoder.java:317)
at org.jboss.netty.handler.codec.frame.FrameDecoder.callDecode(FrameDecoder.java:299)
at org.jboss.netty.handler.codec.frame.FrameDecoder.messageReceived(FrameDecoder.java:216)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:274)
at org.jboss.netty.channel.Channels.fireMessageReceived(Channels.java:261)
at org.jboss.netty.channel.socket.nio.NioWorker.read(NioWorker.java:349)
at org.jboss.netty.channel.socket.nio.NioWorker.processSelectedKeys(NioWorker.java:281)
at org.jboss.netty.channel.socket.nio.NioWorker.run(NioWorker.java:201)
at org.jboss.netty.util.internal.IoWorkerRunnable.run(IoWorkerRunnable.java:46)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)