Search code examples
androidxmlsoapretrofitsimple-framework

Unable to satisfy @org.simpleframework.xml.Element(data=false, name=soap:Body, required=true, type=void) on field 'body'


I'm trying to deserialize this little xml and no luck. I'm getting the exception;

Unable to satisfy @org.simpleframework.xml.Element(data=false, name=soap:Body, required=true, type=void) on field 'body'

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
    <soap:Body>
        <Response xmlns="http://asdasdasd.com/">
            <Result>true</Result>
            <AppPath />
            <Message />
        </Response>
    </soap:Body>
</soap:Envelope>

Can anyone figure out the problem? Oh! The classes:

The envelope class:

@Root(name = "soap:Envelope", strict = false)
@NamespaceList({
        @Namespace(prefix = "xsd", reference = "http://www.w3.org/2001/XMLSchema"),
        @Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
        @Namespace(prefix = "soap", reference = "http://schemas.xmlsoap.org/soap/envelope/")
})
public class ResponseEnvelope {

    @Element(name = "soap:Body")
    private CheckVersionResponseBody body;

    public CheckVersionResponseBody getBody() {
        return body;
    }

    public void setBody(CheckVersionResponseBody body) {
        this.body = body;
    }

    public ResponseEnvelope() {
    }

    public ResponseEnvelope(CheckVersionResponseBody body) {
        this.body = body;
    }
}

The body class

@Root(name = "soap:Body")
public class CheckVersionResponseBody {

    @Element(name = "Response")
    @Namespace(reference = "http://asdasdasd.com/")
    Response response;

    public CheckVersionResponseBody() {
    }

    public CheckVersionResponseBody(Response response) {
        this.response = response;
    }

    public Response getVersionControlGeneralResponse() {
        return versionControlGeneralResponse;
    }
}

Solution

  • Well, i found the answer if anyone else in the "FUTURE" has this problem.

    Just get rid of the prefix in the body. That.

    @Root(name = "Body")
    public class CheckVersionResponseBody {
    
        @Element(name = "Response")
        @Namespace(reference = "http://asdasdasd.com/")
        Response response;
    
        public CheckVersionResponseBody() {
        }
    
        public CheckVersionResponseBody(Response response) {
            this.response = response;
        }
    
        public Response getVersionControlGeneralResponse() {
            return versionControlGeneralResponse;
        }
    }