KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > axis > soap > MessageFactoryImpl


1 /*
2  * Copyright 2002-2004 The Apache Software Foundation.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */

16 package org.apache.axis.soap;
17
18 import org.apache.axis.Message;
19 import org.apache.axis.message.SOAPEnvelope;
20
21 import javax.xml.soap.MimeHeaders JavaDoc;
22 import javax.xml.soap.SOAPException JavaDoc;
23 import javax.xml.soap.SOAPMessage JavaDoc;
24 import java.io.IOException JavaDoc;
25 import java.io.InputStream JavaDoc;
26
27 /**
28  * Message Factory implementation
29  *
30  * @author Davanum Srinivas (dims@yahoo.com)
31  */

32 public class MessageFactoryImpl extends javax.xml.soap.MessageFactory JavaDoc {
33     /**
34      * Creates a new <CODE>SOAPMessage</CODE> object with the
35      * default <CODE>SOAPPart</CODE>, <CODE>SOAPEnvelope</CODE>,
36      * <CODE>SOAPBody</CODE>, and <CODE>SOAPHeader</CODE> objects.
37      * Profile-specific message factories can choose to
38      * prepopulate the <CODE>SOAPMessage</CODE> object with
39      * profile-specific headers.
40      *
41      * <P>Content can be added to this message's <CODE>
42      * SOAPPart</CODE> object, and the message can be sent "as is"
43      * when a message containing only a SOAP part is sufficient.
44      * Otherwise, the <CODE>SOAPMessage</CODE> object needs to
45      * create one or more <CODE>AttachmentPart</CODE> objects and
46      * add them to itself. Any content that is not in XML format
47      * must be in an <CODE>AttachmentPart</CODE> object.</P>
48      * @return a new <CODE>SOAPMessage</CODE> object
49      * @throws SOAPException if a SOAP error occurs
50      */

51     public SOAPMessage JavaDoc createMessage() throws SOAPException JavaDoc {
52         SOAPEnvelope env = new SOAPEnvelope();
53         env.setSAAJEncodingCompliance(true);
54         Message message = new Message(env);
55         message.setMessageType(Message.REQUEST);
56         return message;
57     }
58
59     /**
60      * Internalizes the contents of the given <CODE>
61      * InputStream</CODE> object into a new <CODE>SOAPMessage</CODE>
62      * object and returns the <CODE>SOAPMessage</CODE> object.
63      * @param mimeheaders the transport-specific headers
64      * passed to the message in a transport-independent fashion
65      * for creation of the message
66      * @param inputstream the <CODE>InputStream</CODE> object
67      * that contains the data for a message
68      * @return a new <CODE>SOAPMessage</CODE> object containing the
69      * data from the given <CODE>InputStream</CODE> object
70      * @throws IOException if there is a
71      * problem in reading data from the input stream
72      * @throws SOAPException if the message is invalid
73      */

74     public SOAPMessage JavaDoc createMessage(
75             MimeHeaders JavaDoc mimeheaders, InputStream JavaDoc inputstream)
76             throws IOException JavaDoc, SOAPException JavaDoc {
77         Message message = new Message(inputstream, false, mimeheaders);
78         message.setMessageType(Message.REQUEST);
79         return message;
80     }
81 }
82
Popular Tags