6 Replies Latest reply on Nov 18, 2008 3:00 AM by Mirko Ravagnan

    jax-ws soap protocol handler and white space.

    Mirko Ravagnan Newbie

      I have an issue with a soap protocol handler that works fine in jbossws 2.0.3.
      Since 2.0.4 it has stopped working because it seems every white space character is stripped away from the message by the runtime.

      This handler adds a header to the soap envelope and fills this header with lines of text separated with a newline character.

      Any hint as to what is happening?

      Many thanks

      Here is the source code.

      public class MefHandlerClient implements SOAPHandler {

      public Set getHeaders() {
      return null;
      }

      public boolean handleMessage(SOAPMessageContext smc) {
      try {
      Boolean outboundProperty = (Boolean) smc.get(MessageContext.MESSAGE_OUTBOUND_PROPERTY);
      if (outboundProperty.booleanValue() == true) {
      SOAPMessage sm = smc.getMessage();
      SOAPPart part = sm.getSOAPPart();
      SOAPEnvelope envelope = part.getEnvelope();
      SOAPHeader sh = envelope.getHeader();
      if (sh == null)
      sh = envelope.addHeader();
      QName n = new QName(
      "http://schemas.xmlsoap.org/ws/2002/04/secext",
      "BinarySecurityToken",
      "wsse");
      envelope.addNamespaceDeclaration("wsse", "http://schemas.xmlsoap.org/ws/2002/04/secext");
      SOAPHeaderElement she = sh.addHeaderElement(n);
      QName id = new QName("Id");
      she.addAttribute(id, "SecurityToken");
      QName eType= new QName("EncodingType");
      she.addAttribute(eType, "wsse:Base64Binary");
      QName vType= new QName("ValueType");
      she.addAttribute(vType, "wsse:X509v3");
      InputStream firma = getClass().getClassLoader().getResourceAsStream("cert.pem");
      BufferedReader br = new BufferedReader(new InputStreamReader(firma));
      String temp = br.readLine();
      while (temp != null) {
      String temp2 = br.readLine();
      if (!temp.contains("CERTIFICATE")) {
      if (temp2 != null)
      temp += System.getProperty("line.separator");
      SOAPElement riga = she.addTextNode(temp);
      }
      temp = temp2;
      }
      }
      } catch(Throwable x) {
      System.out.println(x);
      }
      return true;
      }

      public boolean handleFault(SOAPMessageContext smc) {
      return true;
      }

      public void close(MessageContext messageContext) {
      }

      }