//initialize the chat manager using connection
ChatManager chatManager = xmppConnection.getChatManager();
Chat chat = chatManager.createChat(xmppOutTransportInfo.getDestinationAccount(), null);
boolean waitForResponse =
msgCtx.getOperationContext() != null &&
WSDL2Constants.MEP_URI_OUT_IN.equals(
msgCtx.getOperationContext().getAxisOperation().getMessageExchangePattern());
OMElement msgElement;
String messageToBeSent = "";
if(XMPPConstants.XMPP_CONTENT_TYPE_STRING.equals(xmppOutTransportInfo.getContentType())){
//if request is received from a chat client, whole soap envelope
//should not be sent.
OMElement soapBodyEle = msgCtx.getEnvelope().getBody();
OMElement responseEle = soapBodyEle.getFirstElement();
if(responseEle != null){
msgElement = responseEle.getFirstElement();
}else{
msgElement = responseEle;
}
}else{
//if request received from a ws client whole soap envelope
//must be sent.
msgElement = msgCtx.getEnvelope();
}
messageToBeSent = msgElement.toString();
message.setBody(messageToBeSent);
String key = null;
if(waitForResponse && !msgCtx.isServerSide()){
PacketFilter filter = new PacketTypeFilter(message.getClass());
xmppConnection.addPacketListener(xmppClientSidePacketListener,filter);
key = UUID.randomUUID().toString();
xmppClientSidePacketListener.listenForResponse(key, msgCtx);
message.setProperty(XMPPConstants.SEQUENCE_ID, key);
}
chat.sendMessage(message);
log.debug("Sent message :"+message.toXML());
//If this is on client side, wait for the response from server.
//Is this the best way to do this?
if(waitForResponse && !msgCtx.isServerSide()){