I see that in V4 there are projects like the Eclipse plugin to support referencing ServiceStack from Java, we are currently still on V3 and I am pretty sure this approach will not work from there.
I have also attempted to build a Java client using the swagger codegen without much success, for example the class ResponseStatus fails due to the property Errors (of type List
Is there any good story for those wishing to generate a Java client against a ServiceStack V3 instance?
There’s no support for v3, but the way ServiceStack is designed you just need to generate Java DTO’s which you can use with the generic Java Service Client so you should still be able to leverage a lot of the Java Add Service Reference support in v4 to at least generate the Java DTO’s, which you can do by creating an empty v4 project that just has all the Service Models with empty services stub, e.g:
public class Request1 : IReturn<Request1Response> { ... }
public class Request2 : IReturn<Request2Response> { ... }
public class StubServices : Service
{
public object Any(Request1 request) { return request; }
public object Any(Request2 request) { return request; }
}
Once you have all the DTO’s and an empty Service you can get the Java DTO’s from the /types/javalanguage types path which will return all the Java DTO’s in a single static class, e.g: http://techstacks.io/types/java
These Java DTO’s can be used with the AndroidServiceClient in the Android Java Package for Android Clients or the JsonServiceClient in the Java 1.7 package for pure Java clients.
The JSON Serialization hasn’t changed too much since v3 but there’s going to be some functionality that’s missing so not everything will work smoothly. You may need to customize the Gson configuration if you’re using some of the unsupported types if you’re lucky, otherwise you may need to modify the source code of the Java Clients required to support v3.
Thanks for that. I already generate my DTOs (in C# and Java) from T4 templates and am using them with a Java Client I had built myself (just a mix of GSON and Apache Http). I just had a customer who wanted something a bit more dynamic, I think they will have to wait until we upgrade to SS V4.