3 Replies Latest reply on Jul 16, 2009 1:28 AM by alfred.rsa

    Newlines/spaces in SOAPMessage

      Hi guys

      I have code that works when I call it from a stand-alone application, but when I call it from within JBoss, I get a NPE from the Web service I am calling.
      The problem seems to be newline or space characters between the XML tags of the SOAP message. When I use the stand-alone code I get the following output from SOAPMessage().writeTo(System.out)

      <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/"><SOAP-ENV:Body><searchDocDataRequest><f_nr>test_fno</f_nr><userid>cnt_usr</userid><items><cheque format="tiff"><account_nr>62001869538</account_nr></cheque></items></searchDocDataRequest></SOAP-ENV:Body></SOAP-ENV:Envelope>
      

      From within JBoss I get:
      13:41:03,491 INFO [STDOUT] <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Body><searchDocDataRequest><f_nr>test_fno
      13:41:03,491 INFO [STDOUT] </f_nr>
      13:41:03,491 INFO [STDOUT] <userid>cnt_usr
      13:41:03,491 INFO [STDOUT] </userid>
      13:41:03,507 INFO [STDOUT] <items><cheque format='tiff'><account_nr>62001869538
      13:41:03,507 INFO [STDOUT] </account_nr>
      13:41:03,507 INFO [STDOUT] </cheque>
      13:41:03,507 INFO [STDOUT] </items>
      13:41:03,523 INFO [STDOUT] </searchDocDataRequest>
      13:41:03,523 INFO [STDOUT] </env:Body></env:Envelope>

      The only difference being the prefix and the newline/space.
      Does anybody have any idea on how I can remove this?

      Reards
      Alfred

        • 1. Re: Newlines/spaces in SOAPMessage

          Using WireShark to intercept the transmission, I found that the JBoss SOAPElement.setvalue implementation seems
          to add a carriage return linefeed combination to my text which causes the Web Service to crash:

          0000 37 32 0d 0a 3c 65 6e 76 3a 45 6e 76 65 6c 6f 70 72..<env:Envelop
          0010 65 20 78 6d 6c 6e 73 3a 65 6e 76 3d 27 68 74 74 e xmlns:env='htt
          0020 70 3a 2f 2f 73 63 68 65 6d 61 73 2e 78 6d 6c 73 p://schemas.xmls
          0030 6f 61 70 2e 6f 72 67 2f 73 6f 61 70 2f 65 6e 76 oap.org/soap/env
          0040 65 6c 6f 70 65 2f 27 3e 3c 65 6e 76 3a 42 6f 64 elope/'><env:Bod
          0050 79 3e 3c 73 65 61 72 63 68 44 6f 63 44 61 74 61 y><searchDocData
          0060 52 65 71 75 65 73 74 3e 3c 66 5f 6e 72 3e 74 65 Request><f_nr>te
          0070 73 74 5f 66 6e 6f 0d 0a st_fno..

          When I use Sun's SAAJ this doesnot happen
          Any ideas?
          Regards Alfred

          • 2. Re: Newlines/spaces in SOAPMessage
            asoldano

            This reminds me of something related to CR/LF when dealing with signatures.
            Where do you get the soap elements content from? are you reading them from file?

            • 3. Re: Newlines/spaces in SOAPMessage

              Hi Alessio

              Thanks for the reply. No I create the SOAP message by getting an instance of the SOAP MessageFactory and then adding elements to the body.
              When i use the SoapMessage writeTo method to a file, it contains no CRLF pairs, but when I intercept the message using WireShark, I see the CRLF's.
              So it seems as if the SOAPConnection call method or underlying transport is adding the CRLF's

              Using the exact same code in GlassFish, the CRLF's are never added and it works fine, but I do not want to use GlassFish

              Regards
              Alfred