title: Retrofit2 + SimpleXML + SOAP request in Kotlin
body: <p>I'm trying to create a service in the Android App that consumes a SOAP API. Sent values and returned values are XML.
  Previously i used FormUrlEncoded + JSON in another API and worked, but with XML i'm struggling as the API seems that is not being called (HttpLoggingInterceptor don't show and also the Mockup service don't show any petition).</p>
  
  <p>If i change to FormUrlEncoded my service i can see that the request is done (i checked it with HttpLoggingInterceptor, but if i remove the FormUrlEncoded seems like service is not called never.</p>
  
  <p>My NetModule where is create the retrofir, parser, etc:</p>
  
  <pre><code>@Module
  class NetModule {
  
      @Provides
      @Singleton
      fun provideRetrofit(): Retrofit {
          val client =
              OkHttpClient.Builder()
                  .addInterceptor(HttpLoggingInterceptor().apply {
                      level = HttpLoggingInterceptor.Level.BODY
                  })
                  .build()
  
          val strategy = AnnotationStrategy()
          val serializer = Persister(strategy)
  
          return Retrofit.Builder()
              .baseUrl(BuildConfig.API_URL)
              .client(client)
              .addConverterFactory(SimpleXmlConverterFactory.create(serializer))
              .addCallAdapterFactory(RxJava2CallAdapterFactory.create())
              .build()
  
      }
  
      @Provides
      @Singleton
      fun provideFilesService(retrofit: Retrofit): FilesService =
          retrofit.create(FilesService::class.java)
  }
  </code></pre>
  
  <p>My FilesService.kt where the interface is defined is:</p>
  
  <pre><code>import com.liderasoluciones.enviotest.data.model.FileSendResponse
  import com.liderasoluciones.enviotest.data.model.FileSendEnvelope
  import io.reactivex.Flowable
  import retrofit2.http.*
  
  interface FilesService {
      @Headers(
          "Content-Type: application/soap+xml",
          "Accept-Charset: utf-8"
      )
      @POST("mockWSSMTSoap")
      fun sendFile(@Body body: FileSendEnvelope): Flowable&lt;FileSendResponse&gt;
  
  }
  </code></pre>
  
  <p>My model for the Body, Request and data is FileSendEnvelope.kt and is:</p>
  
  <pre><code>import org.simpleframework.xml.Element
  import org.simpleframework.xml.Root
  import org.simpleframework.xml.Namespace;
  import org.simpleframework.xml.NamespaceList;
  
  @Root(name = "GetInfoByState", strict = false)
  @Namespace(reference = "http://www.webservicetest.net")
  
  class FileSendData {
  
      @Element(name = "FileName", required = false)
      var name: String? = null
  
  }
  
  @Root(name = "soap12:Body", strict = false)
  class FileSendBody {
  
      @Element(name = "GetInfoByFile", required = false)
      var fileSendData: FileSendData? = null
  
  }
  
  @Root(name = "soap12:Envelope")
  @NamespaceList(
      Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
      Namespace(prefix = "xsd", reference = "http://www.w3.org/2001/XMLSchema"),
      Namespace(prefix = "soap12", reference = "http://www.w3.org/2003/05/soap-envelope")
  )
  class FileSendEnvelope {
  
      @Element(name = "soap12:Body", required = false)
      var body: FileSendBody? = null
  }
  </code></pre>
  
  <p>From the RemoteDataSource class is where i call the api:</p>
  
  <pre><code>class RemoteFilesDataSource(private val filesService: FilesService,
                              private val genericResponseEntityMapper: GenericResponseEntityMapper):
      FilesDataSource {
  
      override fun sendFile(userToken: String): Flowable&lt;GenericResponseEntity&gt; {
          var petitionEnvelope = FileSendEnvelope()
          var petitionBody = FileSendBody()
          var petitionData = FileSendData()
          petitionData.name = "test.png"
  
          petitionBody.fileSendData = petitionData
          petitionEnvelope.body =
  
          return filesService.sendFile(petitionEnvelope)
              .map { it.result }
              .map { genericResponseEntityMapper.transform(it) }
      }
  
  
  }
  </code></pre>
  
  <p>At this moment i'm not taking so much care about the XML sent or parse the response, i just "want to check" that the API is called.</p>
  
  <p>I tried to follow this info:
  <a href="https://github.com/asanchezyu/RetrofitSoapSample" rel="nofollow noreferrer">https://github.com/asanchezyu/RetrofitSoapSample</a>
  <a href="http://geekcalledk.blogspot.com/2014/08/use-simple-xml-with-retrofit-for-making.html" rel="nofollow noreferrer">http://geekcalledk.blogspot.com/2014/08/use-simple-xml-with-retrofit-for-making.html</a></p>
  
  <p>Even are java examples and i'm using Kotlin but no luck.</p>
  
  <p>Any help is appreciated.
  Thanks in advance.</p>