XMLEvent event = eventReader.nextTag();
if (!event.isStartElement()) {
throw new StroapMessageCreationException("Unexpected event: " + event + ", expected StartElement");
}
StartElement startElement = event.asStartElement();
SoapVersion soapVersion = messageFactory.getSoapVersion();
if (!soapVersion.getEnvelopeName().equals(startElement.getName())) {
throw new StroapMessageCreationException(
"Unexpected name: " + startElement.getName() + ", expected " + soapVersion.getEnvelopeName());
}
StroapHeader header = null;
StroapBody body = null;
XMLEvent peekedEvent = eventReader.peek();
while (peekedEvent != null) {
if (peekedEvent.isStartElement()) {
QName headerOrBodyName = peekedEvent.asStartElement().getName();
if (soapVersion.getHeaderName().equals(headerOrBodyName)) {
header = StroapHeader.build(eventReader, messageFactory);
}
else if (soapVersion.getBodyName().equals(headerOrBodyName)) {
body = StroapBody.build(eventReader, messageFactory);
break;
}
else {
throw new StroapMessageCreationException(