Use thrift and php as the client. The thrift protocol is as follows: {code...} the call code is as follows: {code...} isn't thrift -- genphp: rest does not support nested struct parameters? Use thrift and php as the client.
The thrift protocol is as follows:
servicestruct A{ required i32 a1}struct B{ required i32 b1, required A a}service TestService{ resa testa(1:required a reqa); resb testb(1:required B reqb);}
The call code is as follows:
// Socket $ socket = new \ Thrift \ Transport \ TSocket ($ host, $ port, $ name); $ socket-> setSendTimeout ($ timeout ); $ socket-> setRecvTimeout ($ timeout); // transport $ transport = new \ Thrift \ Transport \ TFramedTransport ($ socket); $ transport-> open (); // protocol $ protocol = new \ Thrift \ Protocol \ TBinaryProtocol ($ transport); $ clientName = "\ thritclient \ {$ name} Client "; $ restName = "\ thrifle tclient \\{$ name} Rest"; $ connection = new $ restName (new $ clientName ($ protocol )); // call successful $ connection-> testa (json_encode (['A1' => 2]); // The parameter is a nested struct, call $ connection-> testb (json_encode (['b1 '=> 1, a => ['A1' => 2]);
Is thrift -- gen php: rest does not support nested struct parameters?
Reply content:
Use thrift and php as the client.
The thrift protocol is as follows:
servicestruct A{ required i32 a1}struct B{ required i32 b1, required A a}service TestService{ resa testa(1:required a reqa); resb testb(1:required B reqb);}
The call code is as follows:
// Socket $ socket = new \ Thrift \ Transport \ TSocket ($ host, $ port, $ name); $ socket-> setSendTimeout ($ timeout ); $ socket-> setRecvTimeout ($ timeout); // transport $ transport = new \ Thrift \ Transport \ TFramedTransport ($ socket); $ transport-> open (); // protocol $ protocol = new \ Thrift \ Protocol \ TBinaryProtocol ($ transport); $ clientName = "\ thritclient \ {$ name} Client "; $ restName = "\ thrifle tclient \\{$ name} Rest"; $ connection = new $ restName (new $ clientName ($ protocol )); // call successful $ connection-> testa (json_encode (['A1' => 2]); // The parameter is a nested struct, call $ connection-> testb (json_encode (['b1 '=> 1, a => ['A1' => 2]);
Is thrift -- gen php: rest does not support nested struct parameters?