I am invoking a web service from the camel, and when I try to evaluate its response, I get an error. This is the camel code:
<!-- Transformatio to the ws backend -->
<process id="_transformToValidaAccesoUsuario" ref="transformToValidaAccesoUsuario"/>
<!-- Invoke the ws -->
<to id="invokeAutenticaSesion" uri="cxf:bean:autenticaSesionProxy?defaultOperationName=validarAccesoUsuario"/>
<!-- Validate the response -->
<choice id="validacionAutenticaUsuario">
<when id="validacionUsuarioOK">
<simple>${body.getResponseStatus.getDescripcionRespuesta} == 'OK'</simple>
<log id="logValidacionUsuario" message="validacionUsuario correcto"/>
</when>
<otherwise id="validacionUsuarioError">
<log id="logValidacionUsuario2" message="validacionUsuario incorrecto"/>
</otherwise>
</choice>
I have this error when I run the service:
<faultstring>Failed to invoke method: getResponseStatus on null due to: org.apache.camel.component.bean.MethodNotFoundException: Method with name: getResponseStatus not found on bean: [pe.gob.sis.esb.negocio.consultaafiliados.proxy.autenticasesion.ValidarAccesoUsuarioResponseType@f482049] of type: org.apache.cxf.message.MessageContentsList. Exchange[]</faultstring>
Edit: The class already has the method getResponseStatus()
package pe.gob.sis.esb.negocio.consultaafiliados.proxy.autenticasesion;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlType;
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "ValidarAccesoUsuarioResponseType", namespace = "http://sis.gob.pe/esb/tecnico/autenticaSesion/messages/validarAccesoUsuario/v1/", propOrder = {
"responseStatus",
"login"
})
public class ValidarAccesoUsuarioResponseType {
protected ResponseStatus responseStatus;
protected Login login;
public ResponseStatus getResponseStatus() {
return responseStatus;
}
public void setResponseStatus(ResponseStatus value) {
this.responseStatus = value;
}
public Login getLogin() {
return login;
}
public void setLogin(Login value) {
this.login = value;
}
}
Ah its maybe the crappy MessageContentsList
from camel-cxf / CXF. Its a design fault in camel-cxf I think. So what you can do is to convert the message body to not include that, by
<setBody><simple>${body[0]}</simple></setBody>
Which will take the first element from that MessageContentsList
and store that as the message body, which will be that POJO class.
It depends a bit how you configure camel-cxf / CXF and what is stored as the message body. But the MessageContentsList
is a smell.