{
writer.close();
}
catch (XMLStreamException e)
{
throw new XFireException("Couldn't close stream.", e);
}
}
else
{
// Send a response from the Channel to the client
MessageContext oldContext = (MessageContext)context.getProperty( OLD_CONTEXT );
Channel channel = oldContext.getOutMessage().getChannel();
sendViaNewChannel( context, oldContext, message, channel, (String)context.getProperty( SENDER_URI ) );
}
}
else
{
// Send a request from the channel to the service
MessageContext receivingContext = new MessageContext();
receivingContext.setXFire( context.getXFire() );
receivingContext.setService( getService( context.getXFire(), message.getUri() ) );
receivingContext.setProperty( OLD_CONTEXT, context );
receivingContext.setProperty( SENDER_URI, getUri() );
receivingContext.setSession( session );
final Channel channel;
final String uri = message.getUri();
try
{
channel = getTransport().createChannel( uri );
}
catch( Exception e )
{
throw new XFireException( "Couldn't create channel.", e );
}
sendViaNewChannel( context, receivingContext, message, channel, uri );
}
}