0

I need to read an XML file from a SOAP service in my android app and have a problem. The request object was no problem at all but when trying to read the response I do not get any elements.

The XML looks like

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
    <S:Body>
        <ns2:getTexts xmlns:ns2="http://service.......de/">
            <return>text1</return>
            <return>text2</return>
            <return>text3</return>
            <return>text4</return>
            <return>text5</return>
        </ns2:getTexts>
    </S:Body>
</S:Envelope>

My Modules are

@Root(name = "S:Envelope", strict = false)
class ResponseEnvelope @JvmOverloads constructor(
    @field:Element(name = "S:Body", required = false) var body: GetTexts? = null
)

@Root(name = "S:Body", strict = false)
class GetTexts @JvmOverloads constructor(
    @field:Element(name = "ns2:getTexts", required = false) var response: TextItem? = null
)

@Root(strict = false)
class TextItem @JvmOverloads constructor(
    @field:ElementList(
        name = "ns2:getTexts",
        entry = "return",
        inline = true,
        required = false
    ) var textList: List<String>? = mutableListOf()
)

When trying to access the ResponseEnvelope it is always null. Do I need to write a Converter for each class? Can somebody help me here please?

IMSoP
  • 89,526
  • 13
  • 117
  • 169
lex
  • 77
  • 2
  • 9
  • Check this : https://stackoverflow.com/questions/24102741/simple-framework-skip-soap-envelope-and-body/24225297#24225297 And https://stackoverflow.com/questions/13155056/deserialization-of-xml-with-simplexml-in-java/13193877#13193877 Hope this help you. – Mahesh Shahane Jan 22 '19 at 12:57
  • Hi @MaheshShahane, thanks for the links but I read this two articles already and could not get my code to work. – lex Jan 22 '19 at 14:48

1 Answers1

0

After a while I found out, that I do not need the prefixes to read the XML response. eg.

@Root(name = "S:Envelope", strict = false) should be @Root(name = "Envelope", strict = false)

lex
  • 77
  • 2
  • 9