Je dois envoyer la demande comme indiqué dans le titre. J'ai un texte de demande complète, voici:android - Envoi de demande SOAP-XML et obtention d'une réponse SOAP-XML via Retrofit 2
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="https://api.myapi.org/api">
<soapenv:Header>
<api:Login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/">
<login xsi:type="xsd:string">my_login</login>
<password xsi:type="xsd:string">my_password</password>
</api:Login>
</soapenv:Header>
<soapenv:Body>
<api:GetHouseInfo>
<address>
<houseId>IDHOUSE</houseId>
</address>
</api:GetHouseInfo>
</soapenv:Body>
</soapenv:Envelope>
La seule chose qui change ici - houseId, je dois envoyer un nouveau houseId avec chaque maison sélectionnée dans l'application. Mon application fait beaucoup de requêtes JSON donc j'utilise Retrofit 2 pour travailler avec em. Je veux donc configurer le modèle, créer cette requête à partir du modèle et l'envoyer au serveur. Mais comment? J'ai vu quelques infos sur Internet, mais ce n'était pas la même chose - j'ai deux demandes dans une, je dirais - une dans la section Header (login/mot de passe) et la seconde dans la section Body (houseId). Je essayé d'envoyer la chaîne comme il est, mais il ne fonctionne pas .. Voici mon code Présentateur (Moxy MVP):
@InjectViewState
public class HouseInfoPresenter extends BasePresenter<HouseInfoView> {
private static final String TAG = HouseInfoPresenter.class.getSimpleName();
public void getHouseInfo(String body) {
StringBuilder stringBuilder = new StringBuilder();
stringBuilder.append(String.format("<soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:api=\"https://api.myapi.org/api\"><soapenv:Header><api:Login soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"><login xsi:type=\"xsd:string\">my_loging</login><password xsi:type=\"xsd:string\">my_password</password></api:Login></soapenv:Header><soapenv:Body><api:GetHouseInfo><address><houseId>%s</houseId></address></api:GetHouseInfo></soapenv:Body></soapenv:Envelope>", body));
String xml = stringBuilder.toString();
mCoreServices
.getXmlApiService()
.getApi()
.getHouseInfo(xml)
.subscribeOn(Schedulers.io())
.observeOn(AndroidSchedulers.mainThread())
.doOnSubscribe(() -> getViewState().onShowProgressBar(true))
.doOnUnsubscribe(() -> getViewState().onShowProgressBar(false))
.subscribe(s -> {
getViewState().onSuccess("GOOD");
}, new ApiExceptionObservable(TAG) {
@Override
public void call(String message) {
getViewState().onShowErrorMessage(message);
}
@Override
public void unauthorized() {
getViewState().showUnauthorizedDialog();
}
});
}
}
Mais je ne peux même pas la bonne réponse. J'ai déjà travaillé avec des requêtes XML, mais je n'ai jamais utilisé SOAP.