001: /*
002: * Copyright (c) 1998-2007 Caucho Technology -- all rights reserved
003: *
004: * This file is part of Resin(R) Open Source
005: *
006: * Each copy or derived work must preserve the copyright notice and this
007: * notice unmodified.
008: *
009: * Resin Open Source is free software; you can redistribute it and/or modify
010: * it under the terms of the GNU General Public License as published by
011: * the Free Software Foundation; either version 2 of the License, or
012: * (at your option) any later version.
013: *
014: * Resin Open Source is distributed in the hope that it will be useful,
015: * but WITHOUT ANY WARRANTY; without even the implied warranty of
016: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, or any warranty
017: * of NON-INFRINGEMENT. See the GNU General Public License for more
018: * details.
019: *
020: * You should have received a copy of the GNU General Public License
021: * along with Resin Open Source; if not, write to the
022: *
023: * Free Software Foundation, Inc.
024: * 59 Temple Place, Suite 330
025: * Boston, MA 02111-1307 USA
026: *
027: * @author Emil Ong
028: */
029:
030: package com.caucho.soap.jaxws;
031:
032: import com.caucho.soap.reflect.WebServiceIntrospector;
033: import com.caucho.soap.skeleton.Skeleton;
034: import com.caucho.util.L10N;
035: import com.caucho.util.ThreadPool;
036: import com.caucho.xml.stream.StaxUtil;
037: import com.caucho.xml.stream.XMLStreamReaderImpl;
038: import com.caucho.xml.stream.XMLStreamWriterImpl;
039:
040: import javax.activation.DataHandler;
041: import javax.activation.DataSource;
042:
043: import javax.mail.util.ByteArrayDataSource;
044:
045: import javax.xml.bind.JAXBContext;
046: import javax.xml.namespace.QName;
047:
048: import static javax.xml.soap.SOAPConstants.*;
049:
050: import javax.xml.ws.AsyncHandler;
051: import javax.xml.ws.Binding;
052: import javax.xml.ws.BindingProvider;
053: import javax.xml.ws.Dispatch;
054: import javax.xml.ws.Response;
055: import javax.xml.ws.Service;
056: import javax.xml.ws.WebServiceException;
057: import javax.xml.ws.handler.HandlerResolver;
058: import javax.xml.ws.spi.ServiceDelegate;
059:
060: import java.io.ByteArrayInputStream;
061: import java.io.ByteArrayOutputStream;
062: import java.io.InputStream;
063: import java.io.IOException;
064: import java.io.OutputStream;
065: import java.io.OutputStreamWriter;
066:
067: import java.lang.reflect.Proxy;
068:
069: import java.net.MalformedURLException;
070: import java.net.URL;
071: import java.net.URLConnection;
072:
073: import java.util.Iterator;
074: import java.util.Map;
075: import java.util.concurrent.Executor;
076: import java.util.concurrent.Future;
077: import java.util.logging.Logger;
078:
079: import org.w3c.dom.Document;
080: import org.w3c.dom.Node;
081:
082: /**
083: * Dispatch
084: */
085: public class DataSourceDispatch extends AbstractDispatch<DataSource> {
086: private final static Logger log = Logger
087: .getLogger(DataSourceDispatch.class.getName());
088: private final static L10N L = new L10N(DataSourceDispatch.class);
089:
090: public DataSourceDispatch(String bindingId, Binding binding,
091: Service.Mode mode, Executor executor)
092: throws WebServiceException {
093: super (bindingId, binding, mode, executor);
094: }
095:
096: protected void writeRequest(DataSource msg, OutputStream out) {
097: try {
098: new DataHandler(msg).writeTo(out);
099: } catch (IOException e) {
100: throw new WebServiceException(e);
101: }
102: }
103:
104: protected DataSource formatResponse(byte[] response) {
105: return new ByteArrayDataSource(response, "text/xml");
106: }
107: }
|