0 Replies Latest reply on Jun 15, 2006 10:12 AM by Steven Croy

    Problem with  on attributes on Document type web services

    Steven Croy Newbie

      I have had a problem with web services stripping &#A; from inbound attributes on message based web services. This happened on Axis so I though I would give yours a try and it does it too. Is this the standard or should it keep them? I debugged it and found and fixed where it is happening. Could you look at the solution attached and see if it is correct?

      Problem happens because document is turned to a string using default DOMWriter without canonical set to true. The following snippet would fix it.

      public class DOMEnvelopeBuilder implements SAAJEnvelopeBuilder {
      ......
      public SOAPEnvelope build(InputStream ins) throws IOException, SOAPException {
      .....
      else if (style == Style.DOCUMENT)
      {
      Element srcElement = (Element)domBodyElement;
      SOAPBodyElementDoc destElement = new SOAPBodyElementDoc(beName);
      destElement = (SOAPBodyElementDoc)soapBody.addChildElement(destElement);

      // BEGIN POTENTIAL BUG FIX STEVEN E CROY the webservice cuts out
      from attributes Attr="&#A;" becomes Attr=" "
      StringWriter strw = new StringWriter();
      new DOMWriter(strw).setPrettyprint(false).setCanonical(true).print(srcElement);
      String xmlFragment = strw.toString();
      // String xmlFragment = DOMWriter.printNode(srcElement, false);
      // END POTENTIAL BUG FIX STEVEN E CROY
      destElement.setXMLFragment(xmlFragment);
      }
      ...