Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8172297

In java 8, the marshalling with JAX-WS does not escape carriage return

XMLWordPrintable

    • team

        JAXWS implementation incorrectly processes new line and carriage-return symbols in webservice string parameters.
        In case of simple WS that echoes input parameter the reponse returned to the client differs from the parameter value sent in request.
        For example, WS can be illustrated by such implementation:
            @WebService(endpointInterface = "ws.HelloWorld")
            public class HelloWorldImpl implements HelloWorld {

                @Override
                public String getHelloWorldAsString(String name) {
                    System.out.println("Server-side parameter value: '"
                            + name.replaceAll("\r", "#CR")
                                  .replaceAll("\n", "#NL") + "'");
                    return name;
                }
            }

        and usage of WS:
            String response = hello.getHelloWorldAsString(request);

        After the round trip client/server communication the following values can be observed:
        request value:'CarrigeReturn and NewLine symbols:#CR#NL#NL#CR#CR#NL'
        server-side value:'CarrigeReturn and NewLine symbols:#NL#NL#NL#NL'
        sesponse value:'CarrigeReturn and NewLine symbols:#NL#NL#NL#NL'

              aefimov Aleksej Efimov
              shadowbug Shadow Bug
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: