src/share/jaxws_classes/com/sun/xml/internal/ws/api/message/saaj/SAAJFactory.java

Print this page
rev 472 : 8036030: Update JAX-WS RI integration to latest version
   1 /*
   2  * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.api.message.saaj;
  27 
  28 import java.util.Iterator;
  29 
  30 import javax.xml.soap.AttachmentPart;
  31 import javax.xml.soap.MessageFactory;
  32 import javax.xml.soap.SAAJMetaFactory;
  33 import javax.xml.soap.SOAPException;
  34 import javax.xml.soap.SOAPFactory;
  35 import javax.xml.soap.SOAPMessage;
  36 import javax.xml.stream.XMLStreamException;
  37 
  38 import org.xml.sax.SAXException;

  39 
  40 import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
  41 import com.sun.xml.internal.ws.api.SOAPVersion;
  42 import com.sun.xml.internal.ws.api.message.Attachment;
  43 import com.sun.xml.internal.ws.api.message.AttachmentEx;
  44 import com.sun.xml.internal.ws.api.message.Message;
  45 import com.sun.xml.internal.ws.api.message.Packet;
  46 import com.sun.xml.internal.ws.message.saaj.SAAJMessage;
  47 import com.sun.xml.internal.ws.util.ServiceFinder;
  48 import com.sun.xml.internal.ws.util.xml.XmlUtil;
  49 
  50 /**
  51  * Factory SPI for SAAJ implementations
  52  *
  53  * @since 2.2.6
  54  */
  55 public class SAAJFactory {
  56         private static final SAAJFactory instance = new SAAJFactory();
  57 
  58     /**


 248         }
 249 
 250         /**
 251          * Creates Message from SOAPMessage
 252          * @param saaj SOAPMessage
 253          * @return created Message
 254          */
 255         public Message createMessage(SOAPMessage saaj) {
 256                 return new SAAJMessage(saaj);
 257         }
 258 
 259         /**
 260          * Reads Message as SOAPMessage.  After this call message is consumed.
 261          * @param soapVersion SOAP version
 262          * @param message Message
 263          * @return Created SOAPMessage
 264          * @throws SOAPException if SAAJ processing fails
 265          */
 266         public SOAPMessage readAsSOAPMessage(final SOAPVersion soapVersion, final Message message) throws SOAPException {
 267         SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
 268         SaajStaxWriter writer = new SaajStaxWriter(msg);
 269         try {
 270             message.writeTo(writer);
 271         } catch (XMLStreamException e) {
 272             throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
 273         }
 274         msg = writer.getSOAPMessage();
 275         addAttachmentsToSOAPMessage(msg, message);
 276         if (msg.saveRequired())
 277                 msg.saveChanges();
 278         return msg;
 279         }
 280 
 281     public SOAPMessage readAsSOAPMessageSax2Dom(final SOAPVersion soapVersion, final Message message) throws SOAPException {
 282         SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
 283         SAX2DOMEx s2d = new SAX2DOMEx(msg.getSOAPPart());
 284         try {
 285             message.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
 286         } catch (SAXException e) {
 287             throw new SOAPException(e);
 288         }


   1 /*
   2  * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any
  23  * questions.
  24  */
  25 
  26 package com.sun.xml.internal.ws.api.message.saaj;
  27 
  28 import java.util.Iterator;
  29 
  30 import javax.xml.soap.AttachmentPart;
  31 import javax.xml.soap.MessageFactory;
  32 import javax.xml.soap.SAAJMetaFactory;
  33 import javax.xml.soap.SOAPException;
  34 import javax.xml.soap.SOAPFactory;
  35 import javax.xml.soap.SOAPMessage;
  36 import javax.xml.stream.XMLStreamException;
  37 
  38 import org.xml.sax.SAXException;
  39 import com.sun.xml.internal.org.jvnet.staxex.util.SaajStaxWriter;
  40 
  41 import com.sun.xml.internal.bind.marshaller.SAX2DOMEx;
  42 import com.sun.xml.internal.ws.api.SOAPVersion;
  43 import com.sun.xml.internal.ws.api.message.Attachment;
  44 import com.sun.xml.internal.ws.api.message.AttachmentEx;
  45 import com.sun.xml.internal.ws.api.message.Message;
  46 import com.sun.xml.internal.ws.api.message.Packet;
  47 import com.sun.xml.internal.ws.message.saaj.SAAJMessage;
  48 import com.sun.xml.internal.ws.util.ServiceFinder;
  49 import com.sun.xml.internal.ws.util.xml.XmlUtil;
  50 
  51 /**
  52  * Factory SPI for SAAJ implementations
  53  *
  54  * @since 2.2.6
  55  */
  56 public class SAAJFactory {
  57         private static final SAAJFactory instance = new SAAJFactory();
  58 
  59     /**


 249         }
 250 
 251         /**
 252          * Creates Message from SOAPMessage
 253          * @param saaj SOAPMessage
 254          * @return created Message
 255          */
 256         public Message createMessage(SOAPMessage saaj) {
 257                 return new SAAJMessage(saaj);
 258         }
 259 
 260         /**
 261          * Reads Message as SOAPMessage.  After this call message is consumed.
 262          * @param soapVersion SOAP version
 263          * @param message Message
 264          * @return Created SOAPMessage
 265          * @throws SOAPException if SAAJ processing fails
 266          */
 267         public SOAPMessage readAsSOAPMessage(final SOAPVersion soapVersion, final Message message) throws SOAPException {
 268         SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
 269         SaajStaxWriter writer = new SaajStaxWriter(msg, soapVersion.nsUri);
 270         try {
 271             message.writeTo(writer);
 272         } catch (XMLStreamException e) {
 273             throw (e.getCause() instanceof SOAPException) ? (SOAPException) e.getCause() : new SOAPException(e);
 274         }
 275         msg = writer.getSOAPMessage();
 276         addAttachmentsToSOAPMessage(msg, message);
 277         if (msg.saveRequired())
 278                 msg.saveChanges();
 279         return msg;
 280         }
 281 
 282     public SOAPMessage readAsSOAPMessageSax2Dom(final SOAPVersion soapVersion, final Message message) throws SOAPException {
 283         SOAPMessage msg = soapVersion.getMessageFactory().createMessage();
 284         SAX2DOMEx s2d = new SAX2DOMEx(msg.getSOAPPart());
 285         try {
 286             message.writeTo(s2d, XmlUtil.DRACONIAN_ERROR_HANDLER);
 287         } catch (SAXException e) {
 288             throw new SOAPException(e);
 289         }