apiAdaptor = new BookingsAPIAdaptor();
}
public SOAPMessage handleSOAPRequest(SOAPMessage request) throws SOAPException {
SOAPBody soapBody = request.getSOAPBody();
@SuppressWarnings("rawtypes")
Iterator iterator = soapBody.getChildElements();
AuthenticateResponse authResponse = null;
Object responsePojo = null;
while (iterator.hasNext()) {
Object next = iterator.next();
if (next instanceof SOAPElement) {
SOAPElement soapElement = (SOAPElement) next;
QName qname = soapElement.getElementQName();
if (AUTHENTICATE_QNAME.equals(qname)) {
authResponse = handleAuthRequest(soapElement);
break;
} else if (MYVILLAGE_SIGNUP_QNAME.equals(qname)) {
responsePojo = handleMyVillageSignupRequest(soapElement);
break;
}
}
}
SOAPMessage soapResponse = messageFactory.createMessage();
soapBody = soapResponse.getSOAPBody();
if (authResponse == null)
{
SOAPFault fault = soapBody.addFault();
fault.setFaultString("Missing authetication data");
return soapResponse;
} else if (!authResponse.isReturn())
{
SOAPFault fault = soapBody.addFault();
fault.setFaultString("Failed authentication");
return soapResponse;
}
if (responsePojo != null) {
JAXB.marshal(responsePojo, new SAAJResult(soapBody));
} else {
SOAPFault fault = soapBody.addFault();
fault.setFaultString("Unrecognized SOAP request.");
}
return soapResponse;
}