Uploaded image for project: 'ServiceMix Components'
  1. ServiceMix Components
  2. SMXCOMP-224

Error in writeDetails method when I need return fault messages

    XMLWordPrintableJSON

Details

    Description

      Hi!

      Today I chage version of servicemix 3.1-incubating to 3.1.2. But now I don't return in my service fault message.

      I see in SoapWriter class in writeDetails method that:

      SoapWriter.java
         private void writeDetails(XMLStreamWriter writer, Source details) throws ParserConfigurationException, 
                                                     IOException, SAXException, TransformerException, XMLStreamException {
              SourceTransformer st = new SourceTransformer();
              DOMSource domDetails = st.toDOMSource(details);
              Node detailsNode = domDetails.getNode().getFirstChild();
              if ( SoapMarshaler.MULTIPLE_DETAILS_NODE_WRAPPER.equals(detailsNode.getNodeName()) ) {
                  NodeList children = detailsNode.getChildNodes();
                  for ( int i = 0; i < children.getLength(); i++ ) {
                      Node node = children.item(i);
                      if ( node.getNodeType() == Node.ELEMENT_NODE ) {
                          XMLStreamReader reader = marshaler.getSourceTransformer().toXMLStreamReader(new DOMSource(node));
                          XMLStreamHelper.copy(reader, writer);
                      }
                  }
              } else {
                  XMLStreamReader reader = marshaler.getSourceTransformer().toXMLStreamReader(details);  // ERROR
                  XMLStreamHelper.copy(reader, writer);
              }
          }
      

      The correct code are:

      SoapWriter.java
         private void writeDetails(XMLStreamWriter writer, Source details) throws ParserConfigurationException, 
                                                     IOException, SAXException, TransformerException, XMLStreamException {
              SourceTransformer st = new SourceTransformer();
              DOMSource domDetails = st.toDOMSource(details);
              Node detailsNode = domDetails.getNode().getFirstChild();
              if ( SoapMarshaler.MULTIPLE_DETAILS_NODE_WRAPPER.equals(detailsNode.getNodeName()) ) {
                  NodeList children = detailsNode.getChildNodes();
                  for ( int i = 0; i < children.getLength(); i++ ) {
                      Node node = children.item(i);
                      if ( node.getNodeType() == Node.ELEMENT_NODE ) {
                          XMLStreamReader reader = marshaler.getSourceTransformer().toXMLStreamReader(new DOMSource(node));
                          XMLStreamHelper.copy(reader, writer);
                      }
                  }
              } else {
                  XMLStreamReader reader = marshaler.getSourceTransformer().toXMLStreamReader(domDetails);  // OK
                  XMLStreamHelper.copy(reader, writer);
              }
          }
      

      Because if details param is a StreamSource when I do "st.toDOMSource(details);" I read the stream and when I create XMLStreamReader this Stream its empty

      Thanks

      Attachments

        Activity

          People

            gnodet Guillaume Nodet
            junglika Jorge Rodríguez Pedrianes
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: