01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.message.impl;
20:
21: import org.apache.axiom.om.OMElement;
22: import org.apache.axiom.soap.SOAPEnvelope;
23: import org.apache.axiom.soap.impl.builder.StAXSOAPModelBuilder;
24: import org.apache.axis2.jaxws.message.Protocol;
25: import org.apache.axis2.jaxws.message.XMLPart;
26: import org.apache.axis2.jaxws.message.factory.XMLPartFactory;
27:
28: import javax.xml.stream.XMLStreamException;
29: import javax.xml.stream.XMLStreamReader;
30: import javax.xml.ws.WebServiceException;
31:
32: /** MessageFactoryImpl */
33: public class XMLPartFactoryImpl implements XMLPartFactory {
34:
35: /** Default Constructor required for Factory */
36: public XMLPartFactoryImpl() {
37: super ();
38: }
39:
40: /* (non-Javadoc)
41: * @see org.apache.axis2.jaxws.message.factory.XMLPartFactory#createFrom(javax.xml.stream.XMLStreamReader)
42: */
43: public XMLPart createFrom(XMLStreamReader reader, Protocol protocol)
44: throws XMLStreamException, WebServiceException {
45: StAXSOAPModelBuilder builder = new StAXSOAPModelBuilder(reader,
46: null); // Pass null has the version to trigger autodetection
47: SOAPEnvelope omEnvelope = builder.getSOAPEnvelope();
48: return createFrom(omEnvelope, protocol);
49: }
50:
51: /* (non-Javadoc)
52: * @see org.apache.axis2.jaxws.message.MessageFactory#createFrom(org.apache.axiom.om.OMElement)
53: */
54: public XMLPart createFrom(OMElement omElement, Protocol protocol)
55: throws XMLStreamException, WebServiceException {
56: return new XMLPartImpl(omElement, protocol);
57: }
58:
59: /* (non-Javadoc)
60: * @see org.apache.axis2.jaxws.message.MessageFactory#create(org.apache.axis2.jaxws.message.Protocol)
61: */
62: public XMLPart create(Protocol protocol) throws XMLStreamException,
63: WebServiceException {
64: return new XMLPartImpl(protocol);
65: }
66:
67: /* (non-Javadoc)
68: * @see org.apache.axis2.jaxws.message.factory.XMLPartFactory#createFrom(javax.xml.soap.SOAPEnvelope)
69: */
70: public XMLPart createFrom(javax.xml.soap.SOAPEnvelope soapEnvelope)
71: throws XMLStreamException, WebServiceException {
72: return new XMLPartImpl(soapEnvelope);
73: }
74:
75: }
|