Not too sure on how to word the title but is there an easier way of POSTing data to a WCF Service using Retrofit? Currently I am using the @Body attribute and something like this. Service expects json:
This is what I want to send across
public class Photo
{
private String imageData;
private String latitude;
private String longitude;
public Photo(String imageData, String latitude, String longitude)
{
this.imageData = imageData;
this.latitude = latitude;
this.longitude = longitude;
}
public String getImageData()
{
return imageData;
}
public void setImageData(String imageData)
{
this.imageData = imageData;
}
public String getLatitude()
{
return latitude;
}
public void setLatitude(String latitude)
{
this.latitude = latitude;
}
public String getLongitude()
{
return longitude;
}
public void setLongitude(String longitude)
{
this.longitude = longitude;
}
}
With this:
@POST("/PhotoService.svc/addPhoto")
void addPhoto(@Body Photo photo, Callback<String> cb);
And then I am calling it like this:
IPhotoService photoService = restAdapter.create(IPhotoService.class);
photoService .addPhoto(new Photo(photoSerialised, String.valueOf(location.getLatitude()), String.valueOf(location.getLongitude())), new Callback<String>()
This all works fine, but I have multiple Service Endpoints with various parameters. Do I need to create a Model for each 'Body' or is there a simpler way. Similar to doing a GET?
I have tried using @Field where I have multiple parameters, but on my WCF side my parameters come through as null. Simply sending a class with the @Body attribute works fine, but I do not want to create a model class for each available Service endpoint, or is there no other way?