Community

how to update the MessageContext

created by suresh inala in JBoss Web Services - View the full discussion

Hi Everyone,

 

while sending the request from the consumer with the client-handlers i want to update the messagecontext.
for that the below code which i am working on. when iam doing this i am getting the null response.
i am getting the soap response from the bytes but those byte are not setting into the StreamSource

 

public boolean handleMessage (MessageContext msgContext) {
        SOAPMessageContext smc = (SOAPMessageContext) msgContext;
        SOAPMessage msg = smc.getMessage();
        SOAPPart sp = msg.getSOAPPart();
        StreamSource source = new StreamSource(new ByteArrayInputStream(getMessageBytes()));
        sp.setContent(source);
    return false;
}

 

protected byte[] getMessageBytes (MessageContext msgContext) {
        byte[] result = null;
        try {
            ByteArrayOutputStream bos = new ByteArrayOutputStream();
            ((SOAPMessageContext)msgContext).getMessage().writeTo(bos);
            result = bos.toByteArray();
            bos.close();
            log.trace("setting byte message (length="+result.length+")");
        } catch (Exception e) {
            throw new WebServiceException("Error extracting SOAP request message as bytes", e);
        }
        return result;
    }

 


can any one plese help me out how can i set the bytes into MessageContext/StreamSource

 

Thanks & Regards
     Suresh

Reply to this message by going to Community

Start a new discussion in JBoss Web Services at Community