title: android - Sending SOAP-XML Request and getting SOAP-XML Response via Retrofit 2
body: <p>I need to send the request as the title says. I have a complete request text, here it is:</p>
  
  <pre><code>&lt;soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:api="https://api.myapi.org/api"&gt;
      &lt;soapenv:Header&gt;
          &lt;api:Login soapenv:encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"&gt;
              &lt;login xsi:type="xsd:string"&gt;my_login&lt;/login&gt;
              &lt;password xsi:type="xsd:string"&gt;my_password&lt;/password&gt;
          &lt;/api:Login&gt;
      &lt;/soapenv:Header&gt;
      &lt;soapenv:Body&gt;
          &lt;api:GetHouseInfo&gt;
              &lt;address&gt;
                  &lt;houseId&gt;IDHOUSE&lt;/houseId&gt;
              &lt;/address&gt;
          &lt;/api:GetHouseInfo&gt;
      &lt;/soapenv:Body&gt;
  &lt;/soapenv:Envelope&gt;
  </code></pre>
  
  <p>The only thing that is changing here - houseId, I need to send new houseId with every house selected in app. My application do lots of JSON requests so I use Retrofit 2 to work with em. So I want to set up the model, create this request from the model and send it to server. But how? I saw some info in the Internet, but it was not the same thing - I have two requests in one I'd say - one in the Header section (login/password) and the second in the Body section (houseId).
  I tried to send string as it is, but it doesn't work.. Here's my Presenter code (Moxy MVP):</p>
  
  <pre><code>@InjectViewState
  public class HouseInfoPresenter extends BasePresenter&lt;HouseInfoView&gt; {
  
      private static final String TAG = HouseInfoPresenter.class.getSimpleName();
  
      public void getHouseInfo(String body) {
  
          StringBuilder stringBuilder = new StringBuilder();
          stringBuilder.append(String.format("&lt;soapenv:Envelope xmlns:soapenv=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:api=\"https://api.myapi.org/api\"&gt;&lt;soapenv:Header&gt;&lt;api:Login soapenv:encodingStyle=\"http://schemas.xmlsoap.org/soap/encoding/\"&gt;&lt;login xsi:type=\"xsd:string\"&gt;my_loging&lt;/login&gt;&lt;password xsi:type=\"xsd:string\"&gt;my_password&lt;/password&gt;&lt;/api:Login&gt;&lt;/soapenv:Header&gt;&lt;soapenv:Body&gt;&lt;api:GetHouseInfo&gt;&lt;address&gt;&lt;houseId&gt;%s&lt;/houseId&gt;&lt;/address&gt;&lt;/api:GetHouseInfo&gt;&lt;/soapenv:Body&gt;&lt;/soapenv:Envelope&gt;", body));
  
          String xml = stringBuilder.toString();
  
  
          mCoreServices
                  .getXmlApiService()
                  .getApi()
                  .getHouseInfo(xml)
                  .subscribeOn(Schedulers.io())
                  .observeOn(AndroidSchedulers.mainThread())
                  .doOnSubscribe(() -&gt; getViewState().onShowProgressBar(true))
                  .doOnUnsubscribe(() -&gt; getViewState().onShowProgressBar(false))
                  .subscribe(s -&gt; {
                      getViewState().onSuccess("GOOD");
                  }, new ApiExceptionObservable(TAG) {
              @Override
              public void call(String message) {
                  getViewState().onShowErrorMessage(message);
              }
  
              @Override
              public void unauthorized() {
                  getViewState().showUnauthorizedDialog();
              }
          });
      }
  }
  </code></pre>
  
  <p>But I can't even get the right answer. I worked with XML requests before, but I never used SOAP.</p>