com.sun.xml.ws.addressing.WsaClientTube Maven / Gradle / Ivy
/*
* The contents of this file are subject to the terms
* of the Common Development and Distribution License
* (the License). You may not use this file except in
* compliance with the License.
*
* You can obtain a copy of the license at
* https://glassfish.dev.java.net/public/CDDLv1.0.html.
* See the License for the specific language governing
* permissions and limitations under the License.
*
* When distributing Covered Code, include this CDDL
* Header Notice in each file and include the License file
* at https://glassfish.dev.java.net/public/CDDLv1.0.html.
* If applicable, add the following below the CDDL Header,
* with the fields enclosed by brackets [] replaced by
* you own identifying information:
* "Portions Copyrighted [year] [name of copyright owner]"
*
* Copyright 2006 Sun Microsystems Inc. All Rights Reserved
*/
package com.sun.xml.ws.addressing;
import com.sun.istack.NotNull;
import com.sun.xml.ws.addressing.model.ActionNotSupportedException;
import com.sun.xml.ws.addressing.model.MapRequiredException;
import com.sun.xml.ws.api.WSBinding;
import com.sun.xml.ws.api.message.HeaderList;
import com.sun.xml.ws.api.message.Packet;
import com.sun.xml.ws.api.model.wsdl.WSDLBoundOperation;
import com.sun.xml.ws.api.model.wsdl.WSDLPort;
import com.sun.xml.ws.api.pipe.NextAction;
import com.sun.xml.ws.api.pipe.Tube;
import com.sun.xml.ws.api.pipe.TubeCloner;
import com.sun.xml.ws.resources.AddressingMessages;
import javax.xml.ws.WebServiceException;
/**
* WsaClientTube appears in the Tubeline only if addressing is enabled.
* This tube checks the validity of addressing headers in the incoming messages
* based on the WSDL model.
*
* @author Arun Gupta
*/
public final class WsaClientTube extends WsaTube {
public WsaClientTube(WSDLPort wsdlPort, WSBinding binding, Tube next) {
super(wsdlPort, binding, next);
}
public WsaClientTube(WsaClientTube that, TubeCloner cloner) {
super(that, cloner);
}
public WsaClientTube copy(TubeCloner cloner) {
return new WsaClientTube(this, cloner);
}
public @NotNull NextAction processRequest(Packet request) {
return doInvoke(next,request);
}
public @NotNull NextAction processResponse(Packet response) {
// if one-way then, no validation
if (response.getMessage() != null)
response = validateInboundHeaders(response);
return doReturnWith(response);
}
@Override
public void validateAction(Packet packet) {
//There may not be a WSDL operation. There may not even be a WSDL.
//For instance this may be a RM CreateSequence message.
WSDLBoundOperation wbo = getWSDLBoundOperation(packet);
if (wbo == null) return;
String gotA = packet.getMessage().getHeaders().getAction(addressingVersion, soapVersion);
if (gotA == null)
throw new WebServiceException(AddressingMessages.VALIDATION_CLIENT_NULL_ACTION());
String expected = helper.getOutputAction(packet);
if (expected != null && !gotA.equals(expected))
throw new ActionNotSupportedException(gotA);
}
@Override
protected void checkMandatoryHeaders(Packet packet, boolean foundAction, boolean foundTo, boolean foundMessageID, boolean foundRelatesTo) {
super.checkMandatoryHeaders(packet, foundAction, foundTo, foundMessageID, foundRelatesTo);
// if(!foundRelatesTo)
// // RelatesTo required as per
// // Table 5-3 of http://www.w3.org/TR/2006/WD-ws-addr-wsdl-20060216/#wsdl11requestresponse
// throw new MapRequiredException(addressingVersion.relatesToTag);
}
}