src/share/jaxws_classes/com/sun/xml/internal/ws/addressing/WsaClientTube.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, 2013, 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.addressing;
    28 import com.sun.istack.internal.NotNull;
    29 import com.sun.xml.internal.ws.addressing.model.ActionNotSupportedException;
    30 import com.sun.xml.internal.ws.api.WSBinding;
    31 import com.sun.xml.internal.ws.api.message.AddressingUtils;
    32 import com.sun.xml.internal.ws.api.message.Packet;
    33 import com.sun.xml.internal.ws.api.model.wsdl.WSDLBoundOperation;
    34 import com.sun.xml.internal.ws.api.model.wsdl.WSDLPort;
    35 import com.sun.xml.internal.ws.api.pipe.NextAction;
    36 import com.sun.xml.internal.ws.api.pipe.Tube;
    37 import com.sun.xml.internal.ws.api.pipe.TubeCloner;
    38 import com.sun.xml.internal.ws.resources.AddressingMessages;
    40 import javax.xml.ws.WebServiceException;
    42 /**
    43  * WsaClientTube appears in the Tubeline only if addressing is enabled.
    44  * This tube checks the validity of addressing headers in the incoming messages
    45  * based on the WSDL model.
    46  * @author Rama Pulavarthi
    47  * @author Arun Gupta
    48  */
    49 public class WsaClientTube extends WsaTube {
    50     // capture if the request expects a reply so that it can be used to
    51     // determine if its oneway for response validation.
    52     protected boolean expectReply = true;
    53     public WsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next) {
    54         super(wsdlPort, binding, next);
    55     }
    57     public WsaClientTube(WsaClientTube that, TubeCloner cloner) {
    58         super(that, cloner);
    59     }
    61     public WsaClientTube copy(TubeCloner cloner) {
    62         return new WsaClientTube(this, cloner);
    63     }
    65     @Override
    66     public @NotNull NextAction processRequest(Packet request) {
    67         expectReply = request.expectReply;
    68         return doInvoke(next,request);
    69    }
    71     @Override
    72     public @NotNull NextAction processResponse(Packet response) {
    73         // if one-way then, no validation
    74         if (response.getMessage() != null) {
    75             response = validateInboundHeaders(response);
    76             response.addSatellite(new WsaPropertyBag(addressingVersion,soapVersion,response));
    77             String msgId = AddressingUtils.
    78               getMessageID(response.getMessage().getHeaders(),
    79                       addressingVersion, soapVersion);
    80             response.put(WsaPropertyBag.WSA_MSGID_FROM_REQUEST, msgId);
    81         }
    83         return doReturnWith(response);
    84     }
    87     @Override
    88     protected void validateAction(Packet packet) {
    89         //There may not be a WSDL operation.  There may not even be a WSDL.
    90         //For instance this may be a RM CreateSequence message.
    91         WSDLBoundOperation wbo = getWSDLBoundOperation(packet);
    93         if (wbo == null)    return;
    95         String gotA = AddressingUtils.getAction(
    96                 packet.getMessage().getHeaders(),
    97                 addressingVersion, soapVersion);
    98         if (gotA == null)
    99             throw new WebServiceException(AddressingMessages.VALIDATION_CLIENT_NULL_ACTION());
   101         String expected = helper.getOutputAction(packet);
   103         if (expected != null && !gotA.equals(expected))
   104             throw new ActionNotSupportedException(gotA);
   105     }
   107 }

mercurial