Right, Descriptor.toProto() returns a DescriptorProto, which is itself a protobuf type. So, calling newBuilderForType() on that is going to return a builder for DescriptorProto, not a builder for the type described.
What you want is com.google.protobuf.DynamicMessage. Note that DynamicMessage is slower than the message classes produced by protoc. So if the type in question is actually compiled in to your app, you should use it instead. Typically what you'd do is pass around the type's default instance (MyMessageType.getDefaultInstance()) instead of passing around the descriptor. Note that the Service interface also provides a method getRequestPrototype(MethodDescriptor) which returns the default instance for the type, on which you can then call newBuilderForType(). On Sat, Feb 20, 2010 at 12:54 PM, ph <pkirsa...@gmail.com> wrote: > I'm trying to build service return message using > Descriptors.ServiceDescriptor. > This does not work: > serviceDescriptor.findMethodByName > ( methodName ).getOutputType.toProto.newBuilderForType.mergeFrom > ( msg ).build > "msg" is byte array > It builds DesscriptorProtos.DescriptorProto instead of Message. > > Is there a way to build message from byte array using method > descriptor? > > -- > You received this message because you are subscribed to the Google Groups > "Protocol Buffers" group. > To post to this group, send email to proto...@googlegroups.com. > To unsubscribe from this group, send email to > protobuf+unsubscr...@googlegroups.com<protobuf%2bunsubscr...@googlegroups.com> > . > 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 proto...@googlegroups.com. To unsubscribe from this group, send email to protobuf+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/protobuf?hl=en.