01: /*
02: * Licensed to the Apache Software Foundation (ASF) under one
03: * or more contributor license agreements. See the NOTICE file
04: * distributed with this work for additional information
05: * regarding copyright ownership. The ASF licenses this file
06: * to you under the Apache License, Version 2.0 (the
07: * "License"); you may not use this file except in compliance
08: * with the License. You may obtain a copy of the License at
09: *
10: * http://www.apache.org/licenses/LICENSE-2.0
11: *
12: * Unless required by applicable law or agreed to in writing,
13: * software distributed under the License is distributed on an
14: * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15: * KIND, either express or implied. See the License for the
16: * specific language governing permissions and limitations
17: * under the License.
18: */
19: package org.apache.axis2.jaxws.provider;
20:
21: import org.apache.axiom.soap.SOAPEnvelope;
22: import org.apache.axiom.soap.SOAPHeaderBlock;
23: import org.apache.axis2.AxisFault;
24: import org.apache.axis2.context.MessageContext;
25:
26: import javax.xml.namespace.QName;
27:
28: import java.util.HashMap;
29: import java.util.Iterator;
30:
31: /**
32: * Plugin to remove "understood" headers for the SoapMessageMUProviderTests. This class must
33: * be configured in the axis2.xml file on both the client and the server.
34: */
35: public class SoapMessageMUProviderChecker extends
36: org.apache.axis2.handlers.AbstractHandler {
37:
38: public InvocationResponse invoke(MessageContext msgContext)
39: throws AxisFault {
40: // Get the list of headers for the roles we're acting in, then mark any we understand
41: // as processed.
42: SOAPEnvelope envelope = msgContext.getEnvelope();
43: if (envelope.getHeader() == null) {
44: return InvocationResponse.CONTINUE;
45: }
46: // These are the headers the test expects to be understood
47: String ns1 = "http://ws.apache.org/axis2";
48: String clientLocalName = "muclientunderstood";
49: String serverLocalName = "muserverunderstood";
50:
51: QName clientQN = new QName(ns1, clientLocalName);
52: QName serverQN = new QName(ns1, serverLocalName);
53:
54: Iterator headerBlocks = envelope.getHeader()
55: .getHeadersToProcess(null);
56: while (headerBlocks.hasNext()) {
57: SOAPHeaderBlock headerBlock = (SOAPHeaderBlock) headerBlocks
58: .next();
59: QName headerQN = headerBlock.getQName();
60: if (clientQN.equals(headerQN)) {
61: // System.out.println("Marking as processed CLIENT QN: " + clientQN);
62: headerBlock.setProcessed();
63: } else if (serverQN.equals(headerQN)) {
64: // System.out.println("Marking as processed SERVER QN: " + serverQN);
65: headerBlock.setProcessed();
66: }
67: }
68:
69: return InvocationResponse.CONTINUE;
70: }
71: }
|