ok. I've got it working:
...
ExtensionRegistry registry = ExtensionRegistry.newInstance();
registry.add(Protos.refundRequest);
// I parse "Request" message saying that I need "RefundRequest" as well.
Protos.Request request = Protos.Request.parseFrom(
data, registry);
Protos.RefundRequest refundRequest =
request2.getExtension(Protos.refundRequest);
// NOW I GET 3 AS EXPECTED
Assert.isTrue( refundRequest.getOrderId() == 3 );
Thank you for your support.
On 1/13/11 7:16 PM, Jason Hsueh wrote:
See other thread
On Thu, Jan 13, 2011 at 3:37 AM, Simeon Mitev<[email protected]>wrote:
Hi all,
I have a strange behavior with java release 2.3.0 and I need your help:
Protos.proto:
...
message Request {
required Api api_call = 1;
extensions 100 to 200;
}
message RefundRequest {
extend Request {
optional RefundRequest refund_request = 100;
}
required int32 orderId = 1;
}
...
Client (java):
Protos.RefundRequest refundRequest =
Protos.RefundRequest.newBuilder()
.setOrderId(2)
.build();
Protos.Request request =
Protos.Request.newBuilder()
.setApiCall(Protos.Api.REFUND)
.setExtension(Protos.RefundRequest.refundRequest, refundRequest)
.build();
Server (java):
...
byte[] data; // data is properly initialized with all bytes transmitted
over the wire.
Protos.Request request = Protos.Request.parseFrom(data);
// request.getApiCall() is correct. now I need to get transmitted order Id.
I do expect to have 2.
ExtensionRegistry registry = ExtensionRegistry.newInstance();
registry.add(Protos.RefundRequest.refundRequest);
RefundRequest refundRequest = Protos.RefundRequest.parseFrom(
data, registry
);
...
here is the problem:
refundRequest.getOrderId() returns always "1" ?!? no exceptions during
encoding, transmitting and receiving the data.
What I do wrong?
--
You received this message because you are subscribed to the Google Groups
"Protocol Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected]<protobuf%[email protected]>
.
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.
--
You received this message because you are subscribed to the Google Groups "Protocol
Buffers" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/protobuf?hl=en.