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

    jax-ws soap protocol handler and white space.

    mignaak

      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) {
      }

      }

        • 1. Re: jax-ws soap protocol handler and white space.
          mignaak

          Anyone?

          MuuuuuuuuuuuuuuuuuuuuublEEEEEEEEEEEEEEEEEEEE...

          • 2. Re: jax-ws soap protocol handler and white space.
            mignaak

            It works fine on websphere 6.1, which has axis2 jax-ws runtime.

            Any help would be appreciated.

            Thanks.

            • 3. Re: jax-ws soap protocol handler and white space.
              mignaak

              Well, i'm going to try geronimo with axis2.
              Hope to have better luck.
              Will let you know.
              Thanks for the support

              Bye

              • 4. Re: jax-ws soap protocol handler and white space.
                asoldano

                Does this still happen with a more recent JBossWS version? Which application server version are you using?
                Perhaps you can create a jira issue for this and attach a minimal example reproducing the issue.

                • 5. Re: jax-ws soap protocol handler and white space.
                  mignaak

                  I'm using jboss 4.2.3 + jbossws native 3.0.4 ga.

                  My application in a client to a web service.
                  Everything worked fine with jboss 4.2.2 and jbossws 2.0.3

                  After jbossws went to 2.0.4 nothing worked anymore.

                  The remote server always responds with a java.io.exception:

                  It seems something is wrong with how jboss connects to the remote service. Notice that the soap message produced by jbossws works fine if run through soapui.

                  Thanks.

                  Caused by: org.jboss.remoting.CannotConnectException: Can not connect http client invoker. Invalid HTTP server response [400] - POST/PUT Must Be Explicitly Terminated. Response: POST/PUT Must Be Explicitly Terminated/400.
                  at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:348)
                  at org.jboss.remoting.transport.http.HTTPClientInvoker.transport(HTTPClientInvoker.java:137)
                  at org.jboss.remoting.MicroRemoteClientInvoker.invoke(MicroRemoteClientInvoker.java:122)
                  at org.jboss.remoting.Client.invoke(Client.java:1634)
                  at org.jboss.remoting.Client.invoke(Client.java:548)
                  at org.jboss.ws.core.client.HTTPRemotingConnection.invoke(HTTPRemotingConnection.java:242)
                  ... 131 more
                  Caused by: org.jboss.ws.WSException: Invalid HTTP server response [400] - POST/PUT Must Be Explicitly Terminated
                  at org.jboss.ws.core.soap.SOAPMessageUnMarshallerHTTP.read(SOAPMessageUnMarshallerHTTP.java:75)
                  at org.jboss.remoting.transport.http.HTTPClientInvoker.readResponse(HTTPClientInvoker.java:518)
                  at org.jboss.remoting.transport.http.HTTPClientInvoker.useHttpURLConnection(HTTPClientInvoker.java:307)

                  • 6. Re: jax-ws soap protocol handler and white space.
                    mignaak

                    After days spent debugging I found a solution.
                    It seems the remote server does not support chunked requests.
                    The remote server is websphere 5.1.

                    The solution is to put chunksize=0 in client config "Standard Client" in file
                    "standard-jaxws-client-config.xml" in jbossws.

                    Hope this solution ca be useful to others.

                    Bye.