}
public void invoke(MessageContext context)
throws Exception
{
InMessage message = context.getInMessage();
if (message.hasHeader()) return;
XMLStreamReader reader = message.getXMLStreamReader();
Map namespaces = new HashMap();
context.setProperty(DECLARED_NAMESPACES, namespaces);
boolean end = !reader.hasNext();
while (!end && reader.hasNext())
{
int event = reader.next();
switch (event)
{
case XMLStreamReader.START_DOCUMENT:
String encoding = reader.getCharacterEncodingScheme();
message.setEncoding(encoding);
break;
case XMLStreamReader.END_DOCUMENT:
end = true;
return;
case XMLStreamReader.END_ELEMENT:
break;
case XMLStreamReader.START_ELEMENT:
if (reader.getLocalName().equals("Header"))
{
readHeaders(context,namespaces);
}
else if (reader.getLocalName().equals("Body"))
{
readNamespaces(reader, namespaces);
event = reader.nextTag();
checkForFault(context, message, reader);
return;
}
else if (reader.getLocalName().equals("Envelope"))
{
readNamespaces(reader, namespaces);
message.setSoapVersion(reader.getNamespaceURI());
if (message.getSoapVersion() == null)
{
throw new XFireFault("Invalid SOAP version: " + reader.getNamespaceURI(),
XFireFault.SENDER);
}
}