1
I am using Retrofit 2.2.0 and Retrofit Simplexml Converter 2.2.0. I added the simplexmlconverter at the time of the retrofit with the addConverterFactory method.
The problem is that when I get the response from the server, the following error happens
java.lang.RuntimeException: org.simpleframework.xml.core.ElementException: Element 'Body' does not have a match in class ResponseEnvelope at line 1
I’m getting a response from the XML server as follows:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Body>
<ns:autenticarUsuarioPorEmailResponse xmlns:ns="http://business.curitiba.org.br">
<ns:return xsi:type="ax2471:AutenticaUsuarioPorEmailSaida" xmlns:ax2471="http://saidas.curitiba.org/xsd" xmlns:ax2469="http://entities.curitiba.org/xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ax2467="http://entradas.curitiba.org/xsd">
<ax2471:idCredencial>3282</ax2471:idCredencial>
<ax2471:tokenAcesso>635E3DA9-7C02-4DB7-9653-E7688C66B02C</ax2471:tokenAcesso>
</ns:return>
</ns:autenticarUsuarioPorEmailResponse>
</soapenv:Body>
</soapenv:Envelope>
Responseenvelope.java
@Root(name = "soapenv:Envelope")
@Namespace(prefix = "soapenv", reference = "http://schemas.xmlsoap.org/soap/envelope/")
public class ResponseEnvelope {
@Element(name = "soapenv:Body", required = false)
private ResponseBody body;
public ResponseBody getBody() {
return body;
}
public void setBody(ResponseBody body) {
this.body = body;
}
}
Responsebody.java.
@Root(name = "soapenv:Body", strict = false)
public class ResponseBody {
@Element(name = "ns:cadastrarCredencialEmailResponse", required = false)
private ResponseData requestData;
public ResponseData getRequestData() {
return requestData;
}
public void setRequestData(ResponseData requestData) {
this.requestData = requestData;
}
}
Responsedata.java
@Root(name = "ns:cadastrarCredencialEmailResponse", strict = false)
@Namespace(prefix = "ns", reference = "http://business.curitiba.org")
public class ResponseData {
@Element(name = "ns:return", required = false)
private ResponseInfo info;
public ResponseInfo getInfo() {
return info;
}
public void setInfo(ResponseInfo info) {
this.info = info;
}
}
Responseinfo.java
@Root(name = "ns:return", strict = false)
@NamespaceList({
@Namespace(prefix = "ax2471", reference = "http://saidas.curitiba.org/xsd"),
@Namespace(prefix = "ax2469", reference = "http://entities.curitiba.org/xsd"),
@Namespace(prefix = "xsi", reference = "http://www.w3.org/2001/XMLSchema-instance"),
@Namespace(prefix = "ax2467", reference = "http://entradas.curitiba.org/xsd")
})
public class ResponseInfo {
@Element(name = "ax2471:codigoAtivacao", required = false)
private String codigoAtivacao;
@Element(name = "ax2471:idCredencial", required = false)
private String idCredencial;
public String getCodigoAtivacao() {
return codigoAtivacao;
}
public void setCodigoAtivacao(String codigoAtivacao) {
this.codigoAtivacao = codigoAtivacao;
}
public String getIdCredencial() {
return idCredencial;
}
public void setIdCredencial(String idCredencial) {
this.idCredencial = idCredencial;
}
}
I think the problem is in the Responseinfo class, because I don’t know how to add the attribute xsi:type and I think this is causing the problem.
If anyone can help, I’d appreciate it.