01: /*
02: * $Id: SOAPPart1_1Impl.java,v 1.1.1.1 2006/01/27 13:10:57 kumarjayanti Exp $
03: */
04:
05: /*
06: * Copyright 2006 Sun Microsystems, Inc. All Rights Reserved.
07: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
08: *
09: * This code is free software; you can redistribute it and/or modify it
10: * under the terms of the GNU General Public License version 2 only, as
11: * published by the Free Software Foundation. Sun designates this
12: * particular file as subject to the "Classpath" exception as provided
13: * by Sun in the LICENSE file that accompanied this code.
14: *
15: * This code is distributed in the hope that it will be useful, but WITHOUT
16: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
17: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
18: * version 2 for more details (a copy is included in the LICENSE file that
19: * accompanied this code).
20: *
21: * You should have received a copy of the GNU General Public License version
22: * 2 along with this work; if not, write to the Free Software Foundation,
23: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24: *
25: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara,
26: * CA 95054 USA or visit www.sun.com if you need additional information or
27: * have any questions.
28: */
29:
30: /**
31: *
32: * @author SAAJ RI Development Team
33: */package com.sun.xml.internal.messaging.saaj.soap.ver1_1;
34:
35: import java.util.logging.Level;
36: import java.util.logging.Logger;
37:
38: import javax.xml.soap.SOAPConstants;
39: import javax.xml.soap.SOAPException;
40: import javax.xml.transform.Source;
41:
42: import com.sun.xml.internal.messaging.saaj.soap.*;
43: import com.sun.xml.internal.messaging.saaj.soap.impl.EnvelopeImpl;
44: import com.sun.xml.internal.messaging.saaj.util.LogDomainConstants;
45: import com.sun.xml.internal.messaging.saaj.util.XMLDeclarationParser;
46:
47: public class SOAPPart1_1Impl extends SOAPPartImpl implements
48: SOAPConstants {
49:
50: protected static Logger log = Logger
51: .getLogger(LogDomainConstants.SOAP_VER1_1_DOMAIN,
52: "com.sun.xml.internal.messaging.saaj.soap.ver1_1.LocalStrings");
53:
54: public SOAPPart1_1Impl() {
55: super ();
56: }
57:
58: public SOAPPart1_1Impl(MessageImpl message) {
59: super (message);
60: }
61:
62: protected String getContentType() {
63: return isFastInfoset() ? "application/fastinfoset" : "text/xml";
64: }
65:
66: protected Envelope createEnvelopeFromSource() throws SOAPException {
67: // Record the presence of xml declaration before the envelope gets
68: // created.
69: XMLDeclarationParser parser = lookForXmlDecl();
70: Source tmp = source;
71: source = null;
72: EnvelopeImpl envelope = (EnvelopeImpl) EnvelopeFactory
73: .createEnvelope(tmp, this );
74:
75: if (!envelope.getNamespaceURI().equals(
76: SOAPConstants.URI_NS_SOAP_1_1_ENVELOPE)) {
77: log.severe("SAAJ0304.ver1_1.msg.invalid.SOAP1.1");
78: throw new SOAPException(
79: "InputStream does not represent a valid SOAP 1.1 Message");
80: }
81:
82: if (!omitXmlDecl) {
83: envelope.setOmitXmlDecl("no");
84: envelope.setXmlDecl(parser.getXmlDeclaration());
85: envelope.setCharsetEncoding(parser.getEncoding());
86: }
87: return envelope;
88: }
89:
90: protected Envelope createEmptyEnvelope(String prefix)
91: throws SOAPException {
92: return new Envelope1_1Impl(getDocument(), prefix, true, true);
93: }
94:
95: protected SOAPPartImpl duplicateType() {
96: return new SOAPPart1_1Impl();
97: }
98:
99: }
|