src/share/jaxws_classes/com/sun/xml/internal/ws/client/dispatch/SOAPMessageDispatch.java

Thu, 31 Aug 2017 15:18:52 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:18:52 +0800
changeset 637
9c07ef4934dd
parent 368
0989ad8c0860
parent 0
373ffda63c9a
permissions
-rw-r--r--

merge

     1 /*
     2  * Copyright (c) 1997, 2012, 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  */
    26 package com.sun.xml.internal.ws.client.dispatch;
    28 import com.sun.xml.internal.ws.api.addressing.WSEndpointReference;
    29 import com.sun.xml.internal.ws.api.message.Packet;
    30 import com.sun.xml.internal.ws.api.message.saaj.SAAJFactory;
    31 import com.sun.xml.internal.ws.api.pipe.Tube;
    32 import com.sun.xml.internal.ws.api.client.WSPortInfo;
    33 import com.sun.xml.internal.ws.binding.BindingImpl;
    34 import com.sun.xml.internal.ws.client.WSServiceDelegate;
    35 import com.sun.xml.internal.ws.client.PortInfo;
    36 import com.sun.xml.internal.ws.message.saaj.SAAJMessage;
    37 import com.sun.xml.internal.ws.resources.DispatchMessages;
    38 import com.sun.xml.internal.ws.transport.Headers;
    40 import javax.xml.namespace.QName;
    41 import javax.xml.soap.MimeHeader;
    42 import javax.xml.soap.SOAPException;
    43 import javax.xml.soap.SOAPMessage;
    44 import javax.xml.ws.Service;
    45 import javax.xml.ws.WebServiceException;
    46 import javax.xml.ws.handler.MessageContext;
    48 import java.util.Iterator;
    50 /**
    51  * The <code>SOAPMessageDispatch</code> class provides support
    52  * for the dynamic invocation of a service endpoint operation using
    53  * the <code>SOAPMessage</code> class. The <code>javax.xml.ws.Service</code>
    54  * interface acts as a factory for the creation of <code>SOAPMessageDispatch</code>
    55  * instances.
    56  *
    57  * @author WS Development Team
    58  * @version 1.0
    59  */
    60 public class SOAPMessageDispatch extends com.sun.xml.internal.ws.client.dispatch.DispatchImpl<SOAPMessage> {
    61     @Deprecated
    62     public SOAPMessageDispatch(QName port, Service.Mode mode, WSServiceDelegate owner, Tube pipe, BindingImpl binding, WSEndpointReference epr) {
    63         super(port, mode, owner, pipe, binding, epr);
    64     }
    66     public SOAPMessageDispatch(WSPortInfo portInfo, Service.Mode mode, BindingImpl binding, WSEndpointReference epr) {
    67         super(portInfo, mode, binding, epr);
    68     }
    70     Packet createPacket(SOAPMessage arg) {
    71         Iterator iter = arg.getMimeHeaders().getAllHeaders();
    72         Headers ch = new Headers();
    73         while(iter.hasNext()) {
    74             MimeHeader mh = (MimeHeader) iter.next();
    75             ch.add(mh.getName(), mh.getValue());
    76         }
    77         Packet packet = new Packet(SAAJFactory.create(arg));
    78         packet.invocationProperties.put(MessageContext.HTTP_REQUEST_HEADERS, ch);
    79         return packet;
    80     }
    82     SOAPMessage toReturnValue(Packet response) {
    83         try {
    85             //not sure if this is the correct way to deal with this.
    86             if ( response ==null || response.getMessage() == null )
    87                      throw new WebServiceException(DispatchMessages.INVALID_RESPONSE());
    88             else
    89                 return response.getMessage().readAsSOAPMessage();
    90         } catch (SOAPException e) {
    91             throw new WebServiceException(e);
    92         }
    93     }
    94 }

mercurial