[
https://issues.apache.org/jira/browse/THRIFT-5085?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=17031681#comment-17031681
]
Andres Camilo Martinez Cano edited comment on THRIFT-5085 at 2/6/20 3:37 PM:
-----------------------------------------------------------------------------
Okay [~jensg] thank you for your answer. I'm sorry for not explaining my point
well enough. The problem I currently have is that I have a service that
supports two versions at the same time. And I'm trying to use a method that
only belongs to the V2 of that service. I'm using the V2 client to execute a
call to the endpoint that belongs only to the V2. But for some reason I end up
hitting the V1 of the service, therefore I get the "Invalid method name"
response from the server.
There's something else worth pointing out. After compiling my actual thrift
file I got the following result for "ListPositions":
{code:java}
// Parameters:
// - InputDTO
func (p *PositionServiceV2Client) ListPositions(ctx context.Context, inputDTO
*ListPositionInputDTO) (r *OwnerStoresListDTO, err error) {
var_args85 PositionServiceV2ListPositionsArgs
_args85.InputDTO= inputDTO
var_result86 PositionServiceV2ListPositionsResult
if err= p.Client_().Call(ctx, "listPositions", &_args85, &_result86); err !=nil
{ return }
switch {
case _result86.E!=nil:
return r, _result86.E
case _result86.Ex!=nil:
return r, _result86.Ex
}
return _result86.GetSuccess(), nil
}
{code}
I modified the line that says
{code:java}
p.Client_().Call(ctx, "listPositions", &_args85, &_result86){code}
And used instead:
{code:java}
p.Client_().Call(ctx, "PositionServiceV2:listPositions", &_args85,
&_result86){code}
Which partially worked because I checked the logs of the position Service and
it reflected the request being processed by the Position Service but, I got an
error saying "PositionServiceV2:listPositions: wrong method name", more exactly
here on this method(thrift/lib/go/client.go):
{code:java}
func (p *TStandardClient) Recv(iprot TProtocol, seqId int32, method string,
result TStruct) error {
rMethod, rTypeId, rSeqId, err:= iprot.ReadMessageBegin() if err !=nil {
return err
}
if method != rMethod {
return NewTApplicationException(WRONG_METHOD_NAME, fmt.Sprintf("%s: wrong
method name", method))
} else if seqId != rSeqId {
return NewTApplicationException(BAD_SEQUENCE_ID, fmt.Sprintf("%s: out of
order sequence response", method))
} else if rTypeId == EXCEPTION {
var exception tApplicationException
if err := exception.Read(iprot); err !=nil {
return err
}
if err := iprot.ReadMessageEnd(); err != nil {
return err
}
return &exception
} else if rTypeId != REPLY {
return NewTApplicationException(INVALID_MESSAGE_TYPE_EXCEPTION,
fmt.Sprintf("%s: invalid message type", method))
}
if err:= result.Read(iprot); err !=nil {
return err
}
return iprot.ReadMessageEnd()
}
{code}
This is the first time I'm consuming a service like this one, the other ones
didn't have such definition. Any help is appreciated
was (Author: amartinez):
Okay [~jensg] thank you for your answer. I'm sorry for not explaining my point
well enough. The problem I currently have is that I have a service that
supports two versions at the same time. And I'm trying to use a method that
only belongs to the V2 of that service. I'm using the V2 client to execute a
call to the endpoint that belongs only to the V2. But for some reason I end up
hitting the V1 of the service, therefore I get the "Invalid method name"
response from the server.
There's something else worth pointing out. After compiling my actual thrift
file I got the following result for "ListPositions":
// Parameters:
// - InputDTO
func (p *PositionServiceV2Client) ListPositions(ctx context.Context, inputDTO
*ListPositionInputDTO) (r *OwnerStoresListDTO, err error) \{
var_args85 PositionServiceV2ListPositionsArgs
_args85.InputDTO= inputDTO
var_result86 PositionServiceV2ListPositionsResult
if err= p.Client_().Call(ctx, "listPositions", &_args85, &_result86); err !=nil
{
return
}
switch \{
case _result86.E!=nil:
return r, _result86.E
case _result86.Ex!=nil:
return r, _result86.Ex
}
return _result86.GetSuccess(), nil
}
I modified the line that says
{code:java}
p.Client_().Call(ctx, "listPositions", &_args85, &_result86){code}
And used instead:
{code:java}
p.Client_().Call(ctx, "PositionServiceV2:listPositions", &_args85,
&_result86){code}
Which partially worked because I checked the logs of the position Service and
it reflected the request being processed by the Position Service but, I got an
error saying "PositionServiceV2:listPositions: wrong method name", more exactly
here on this method(thrift/lib/go/client.go):
{code:java}
func (p *TStandardClient) Recv(iprot TProtocol, seqId int32, method string,
result TStruct) error {
rMethod, rTypeId, rSeqId, err:= iprot.ReadMessageBegin() if err !=nil {
return err
}
if method != rMethod {
return NewTApplicationException(WRONG_METHOD_NAME, fmt.Sprintf("%s: wrong
method name", method))
} else if seqId != rSeqId {
return NewTApplicationException(BAD_SEQUENCE_ID, fmt.Sprintf("%s: out of
order sequence response", method))
} else if rTypeId == EXCEPTION {
var exception tApplicationException
if err := exception.Read(iprot); err !=nil {
return err
}
if err := iprot.ReadMessageEnd(); err != nil {
return err
}
return &exception
} else if rTypeId != REPLY {
return NewTApplicationException(INVALID_MESSAGE_TYPE_EXCEPTION,
fmt.Sprintf("%s: invalid message type", method))
}
if err:= result.Read(iprot); err !=nil {
return err
}
return iprot.ReadMessageEnd()
}
{code}
This is the first time I'm consuming a service like this one, the other ones
didn't have such definition. Any help is appreciated
> How do I execute a call to a server that supports multiple versions?
> --------------------------------------------------------------------
>
> Key: THRIFT-5085
> URL: https://issues.apache.org/jira/browse/THRIFT-5085
> Project: Thrift
> Issue Type: Question
> Components: Go - Compiler, Go - Library
> Affects Versions: 0.13.0
> Environment: OS:macOS
> On the client-side, I've got auto-generated code for go
> On the server-side, I've got auto-generated code for java
> Reporter: Andres Camilo Martinez Cano
> Assignee: Jens Geyer
> Priority: Major
>
> Hi, my apologies beforehand If I say something strange or weird. I'm still
> quite new to thrift but I love it so far.
> I have a thrift file that supports two services like so(both services use the
> same structs):
> {code:java}
> service PositionService {
> PositionDTO findPosition(1:PositionInputDTO) throws (1:
> PositionServiceException e);
> }
> service PositionServiceV2 {
> PositionDTO findPosition(1:PositionInputDTO) throws (1:
> PositionServiceException e),
> OwnerStoresListDTO listPositions(1:ListPositionInputDTO) throws
> (1:PositionServiceException e);
> }
> {code}
> What I'm currently trying to do is to call the method \{{listPositions from
> the {{PositionServiceV2 }}but when I execute the call I keep receiving the
> error message "Invalid method name: listPositions" which makes me think that
> my call is being directed towards the PositionService even though I'm using
> the PostionServiceV2Client to make the call for this. Please help I don't
> know how to make this work.
>
--
This message was sent by Atlassian Jira
(v8.3.4#803005)