0 Replies Latest reply on May 26, 2010 2:26 PM by inalasuresh

    how to update the MessageContext

    inalasuresh

      Hi Everyone,

      i am new to webservices working with jboss native jaxws services.

      while sending the request from the clinet/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