I receive (Step 1) a soapString from a server and I would like to forward (Step 2) this String to another server.
public interface StepTwoRestAdapter {
@Headers({"Content-Type:text/xml"})
@POST("/services/step2/forwardSoap")
Observable<String> order(@Body SoapString soapString);
}
In this case above, the afgter my.server.com which is "/webservices/step2/forwardSoap" is constant always. How can I make this part variable?
The trick here is, that the second server (for step 2) is specified in the response of the first reponse.
EDIT: Now, I use the proposal from @Tabish Hussain
public interface StepTwoRestAdapter {
@Headers({"Content-Type:text/xml"})
@POST("/{urlPath}")
Observable<String> order(@Body SoapString soapString, @Path("urlPath") String urlPath);
}
and then I call
restAdapter.create(StepTwoRestAdapter.class).order(new TypedString(soapString), uriPath)
whereas my uriPath is "services/step2/forwardSoap"
But retrofit then calls: https://my.server.com/services%2Fstep2%2FforwardSoap
As you can see '/' was replaces by "%2F"
Yes, you can create two different Service instances.
Do it like this
public interface StepTwoRestAdapter {
@Headers({"Content-Type:text/xml"})
@POST("/services/{soapString}/forwardSoap")
Observable<String> order(@Path("soapString") SoapString soapString);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With