You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-dev@axis.apache.org by Sanjiva Weerawarana <sa...@opensource.lk> on 2007/06/24 08:51:22 UTC
[axis2] header processing by !handlers (was: Re: svn commit: r549924
- in /webservices/axis2/trunk/java/modules: kernel/src/org/apache/axis2/description/
kernel/src/org/apache/axis2/engine/ metadata/src/org/apache/axis2/jaxws/description/impl/
metadata/test/org/apache/axis2/jaxws/description/)
Jeff, was this idea discussed/proposed on the list? If so apologies for
missing it.
IMO this is a departure from the principle that headers are handled by
handlers.
Sanjiva.
barrettj@apache.org wrote:
> Author: barrettj
> Date: Fri Jun 22 11:33:38 2007
> New Revision: 549924
>
> URL: http://svn.apache.org/viewvc?view=rev&rev=549924
> Log:
> Add ability for other components (such as message recievers) to indicate they will handle certain mustUnderstand headers.
> Add registration of JAXWS header paramaters as headers that will be understood by the JAXWS Message Receiver; add associated test.
>
> Added:
> webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/MustUnderstandTests.java
> Modified:
> webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
> webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
> webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
>
> Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java?view=diff&rev=549924&r1=549923&r2=549924
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java (original)
> +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/description/AxisOperation.java Fri Jun 22 11:33:38 2007
> @@ -59,6 +59,20 @@
>
> // to store mepURL
> private String mepURI;
> + // List of Header QNames that have been registered as understood, for example by message receivers.
> + // This list DOES NOT contain QNames for headers understood by handlers (e.g. security or sandesha)
> + // This list is used in the Axis2 Engine checkMustUnderstand processing to identify headers
> + // marked as mustUnderstand which have not yet been processed (via dispatch handlers),
> + // but which will be processed by the message receiver.
> + // REVIEW: (1) This only supports a single list of understood headers; should there be
> + // different lists for INPUT messages and OUTPUT messages?
> + // (2) This probably needs to support SOAP actors/roles
> + // (3) Strictly speaking, per the SOAP spec, all mustUnderstand checks should be performed
> + // before processing begins on the message. So, ideally, even the QoSes should register
> + // the headers (and roles) they understand and the mustUnderstand checks should be done before
> + // they are invoked. There are issues with that, however, in terms of targeting the operation, and
> + // the possible encryption of headers.
> + private ArrayList understoodHeaderQNames = new ArrayList();
>
> private MessageReceiver messageReceiver;
>
> @@ -555,4 +569,29 @@
> return getChildren();
> }
>
> + /**
> + * Return the list of SOAP header QNames that have been registered as understood by
> + * message receivers, for example. Note that this list DOES NOT contain the QNames that are
> + * understood by handlers run prior to the message receiver. This is used in the Axis2
> + * Engine checkMustUnderstand processing to identify headers marked as mustUnderstand which
> + * have not yet been processed (via dispatch handlers), but which will be processed by
> + * the message receiver.
> + *
> + * @return ArrayList of handler QNAames registered as understood by the message receiver.
> + */
> + public ArrayList getUnderstoodHeaderQNames() {
> + return understoodHeaderQNames;
> + }
> +
> + /**
> + * Add a SOAP header QName to the list of headers understood by this operation. This is used
> + * by other (non dispatch handler) components such as a message receiver to register that it
> + * will process a header.
> + * @param understoodHeader
> + */
> + public void registerUnderstoodHeaderQName(QName understoodHeader) {
> + if (understoodHeader != null) {
> + understoodHeaderQNames.add(understoodHeader);
> + }
> + }
> }
>
> Modified: webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java?view=diff&rev=549924&r1=549923&r2=549924
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java (original)
> +++ webservices/axis2/trunk/java/modules/kernel/src/org/apache/axis2/engine/AxisEngine.java Fri Jun 22 11:33:38 2007
> @@ -70,11 +70,29 @@
>
> while (headerBlocks.hasNext()) {
> SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks.next();
> + QName headerQName = headerBlock.getQName();
>
> // if this header block has been processed or mustUnderstand isn't
> // turned on then its cool
> if (headerBlock.isProcessed() || !headerBlock.getMustUnderstand()) {
> continue;
> + }
> + // Check if another component, such as the message receiver, has registered that
> + // they will process this header
> + AxisOperation axisOperation = msgContext.getAxisOperation();
> + if (axisOperation != null) {
> + ArrayList understoodHeaderList = (ArrayList) axisOperation.getUnderstoodHeaderQNames();
> + if (understoodHeaderList != null && !understoodHeaderList.isEmpty()) {
> + if (understoodHeaderList.contains(headerQName)) {
> + if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
> + log.debug("MustUnderstand header registered as understood on AxisOperation: " + headerQName);
> + }
> + continue;
> + }
> + }
> + }
> + if (LoggingControl.debugLoggingAllowed && log.isDebugEnabled()) {
> + log.debug("MustUnderstand header not processed or registered as understood " + headerQName);
> }
>
> // Oops, throw an appropriate MustUnderstand fault!!
>
> Modified: webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java?view=diff&rev=549924&r1=549923&r2=549924
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java (original)
> +++ webservices/axis2/trunk/java/modules/metadata/src/org/apache/axis2/jaxws/description/impl/OperationDescriptionImpl.java Fri Jun 22 11:33:38 2007
> @@ -18,10 +18,12 @@
>
> package org.apache.axis2.jaxws.description.impl;
>
> +import org.apache.axis2.AxisFault;
> import org.apache.axis2.description.AxisMessage;
> import org.apache.axis2.description.AxisOperation;
> import org.apache.axis2.description.AxisOperationFactory;
> import org.apache.axis2.description.AxisService;
> +import org.apache.axis2.description.Parameter;
> import org.apache.axis2.description.WSDL2Constants;
> import org.apache.axis2.jaxws.ExceptionFactory;
> import org.apache.axis2.jaxws.description.EndpointDescriptionJava;
> @@ -205,7 +207,9 @@
> } else {
> this.axisOperation = createAxisOperation();
> }
> - }
> + // Register understood headers on axisOperation
> + registerMustUnderstandHeaders();
> +}
>
> /**
> * Create an AxisOperation for this Operation. Note that the ParameterDescriptions must be
> @@ -346,6 +350,8 @@
> parameterDescriptions = createParameterDescriptions();
> faultDescriptions = createFaultDescriptions();
> }
> + // Register understood headers on axisOperation
> + registerMustUnderstandHeaders();
> }
>
> public EndpointInterfaceDescription getEndpointInterfaceDescription() {
> @@ -1617,5 +1623,48 @@
> return string.toString();
> }
> return string.toString();
> + }
> +
> + /**
> + * Adds a list of SOAP header QNames that are understood by JAXWS for this operation to the
> + * AxisOperation. This will be used by Axis2 to verify that all headers marked as
> + * mustUnderstand have been or will be processed.
> + *
> + * Server side headers considered understood [JAXWS 2.0 Sec 10.2.1 page 117]
> + * - SEI method params that are in headers
> + * - Headers processed by application handlers (TBD)
> + *
> + * Client side headers considered understood: None
> + *
> + */
> + private void registerMustUnderstandHeaders() {
> +
> + // REVIEW: If client side (return value, OUT or INOUT params) needs to be supported then
> + // this needs to process client and server differently.
> +
> + AxisOperation theAxisOperation = getAxisOperation();
> + if (theAxisOperation == null) {
> + if (log.isDebugEnabled()) {
> + log.debug("The axis operation is null, so header QNames could not be registered. OpDesc = " + this);
> + }
> + return;
> + }
> +
> + // If any IN or INOUT parameters are in the header, then add their QNames to the list
> + ParameterDescription paramDescs[] = getParameterDescriptions();
> + if (paramDescs != null && paramDescs.length > 0) {
> + for (ParameterDescription paramDesc : paramDescs) {
> + if (paramDesc.isHeader()
> + && (paramDesc.getMode() == WebParam.Mode.IN
> + || paramDesc.getMode() == WebParam.Mode.INOUT)) {
> + QName headerQN = new QName(paramDesc.getTargetNamespace(),
> + paramDesc.getParameterName());
> + theAxisOperation.registerUnderstoodHeaderQName(headerQN);
> + if (log.isDebugEnabled()) {
> + log.debug("OpDesc: understoodQName added to AxisOperation (if not null) " + headerQN);
> + }
> + }
> + }
> + }
> }
> }
>
> Added: webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/MustUnderstandTests.java
> URL: http://svn.apache.org/viewvc/webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/MustUnderstandTests.java?view=auto&rev=549924
> ==============================================================================
> --- webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/MustUnderstandTests.java (added)
> +++ webservices/axis2/trunk/java/modules/metadata/test/org/apache/axis2/jaxws/description/MustUnderstandTests.java Fri Jun 22 11:33:38 2007
> @@ -0,0 +1,82 @@
> +/*
> + * Licensed to the Apache Software Foundation (ASF) under one
> + * or more contributor license agreements. See the NOTICE file
> + * distributed with this work for additional information
> + * regarding copyright ownership. The ASF licenses this file
> + * to you under the Apache License, Version 2.0 (the
> + * "License"); you may not use this file except in compliance
> + * with the License. You may obtain a copy of the License at
> + *
> + * http://www.apache.org/licenses/LICENSE-2.0
> + *
> + * Unless required by applicable law or agreed to in writing,
> + * software distributed under the License is distributed on an
> + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
> + * KIND, either express or implied. See the License for the
> + * specific language governing permissions and limitations
> + * under the License.
> + */
> +package org.apache.axis2.jaxws.description;
> +
> +import org.apache.axis2.description.AxisOperation;
> +
> +import javax.jws.WebParam;
> +import javax.jws.WebService;
> +import javax.xml.namespace.QName;
> +import javax.xml.ws.Holder;
> +
> +import java.util.ArrayList;
> +
> +import junit.framework.TestCase;
> +
> +/**
> + *
> + */
> +public class MustUnderstandTests extends TestCase {
> +
> + public void testHeaderParameters() {
> + // Test IN and INOUT header paramaters in SEI
> + ServiceDescription svcDesc = DescriptionFactory.createServiceDescription(HeaderParameters.class);
> + assertNotNull(svcDesc);
> + EndpointDescription epDescs[] = svcDesc.getEndpointDescriptions();
> + assertNotNull(epDescs);
> + assertEquals(1, epDescs.length);
> + EndpointInterfaceDescription epiDesc = epDescs[0].getEndpointInterfaceDescription();
> + assertNotNull(epiDesc);
> +
> + OperationDescription opDescs[] = epiDesc.getOperations();
> + assertNotNull(opDescs);
> + assertEquals(1, opDescs.length);
> + OperationDescription opDesc = opDescs[0];
> + assertEquals("echoString", opDesc.getOperationName());
> +
> + AxisOperation axisOperation = opDesc.getAxisOperation();
> + assertNotNull(axisOperation);
> + ArrayList understoodQNames = axisOperation.getUnderstoodHeaderQNames();
> + assertNotNull(understoodQNames);
> + assertEquals(4, understoodQNames.size());
> +
> + assertTrue(understoodQNames.contains(new QName("webservice.namespace", "renamedParam1")));
> + assertTrue(understoodQNames.contains(new QName("webservice.namespace", "arg1")));
> + assertTrue(understoodQNames.contains(new QName("webparam.namespace", "arg2")));
> + assertFalse(understoodQNames.contains(new QName("webservice.namespace", "outOnly")));
> + assertFalse(understoodQNames.contains(new QName("webservice.namespace", "arg3")));
> + assertTrue(understoodQNames.contains(new QName("webservice.namespace", "inOut")));
> + assertFalse(understoodQNames.contains(new QName("webservice.namespace", "arg4")));
> + assertFalse(understoodQNames.contains(new QName("webservice.namespace", "notInHeader")));
> + assertFalse(understoodQNames.contains(new QName("webservice.namespace", "arg5")));
> + }
> +}
> +
> +@WebService(targetNamespace="webservice.namespace")
> +class HeaderParameters {
> + public String echoString(
> + @WebParam(name="renamedParam1", header=true) String param1,
> + @WebParam(header=true) String param2,
> + @WebParam(targetNamespace="webparam.namespace", header=true) String param3,
> + @WebParam(mode=WebParam.Mode.OUT, header=true) Holder<String> outOnly,
> + @WebParam(name="inOut", mode=WebParam.Mode.INOUT, header=true) Holder<String> inOut,
> + String notInHeader) {
> + return null;
> + }
> +}
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-cvs-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-cvs-help@ws.apache.org
>
>
--
Sanjiva Weerawarana, Ph.D.
Founder & Director; Lanka Software Foundation; http://www.opensource.lk/
Founder, Chairman & CEO; WSO2, Inc.; http://www.wso2.com/
Director; Open Source Initiative; http://www.opensource.org/
Member; Apache Software Foundation; http://www.apache.org/
Visiting Lecturer; University of Moratuwa; http://www.cse.mrt.ac.lk/
---------------------------------------------------------------------
To unsubscribe, e-mail: axis-dev-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-dev-help@ws.apache.org