alvinalexander.com | career | drupal | java | mac | mysql | perl | scala | uml | unix  

Axis 2 example source code file (MustUnderstandTests.java)

This example Axis 2 source code file (MustUnderstandTests.java) is included in the DevDaily.com "Java Source Code Warehouse" project. The intent of this project is to help you "Learn Java by Example" TM.

Java - Axis 2 tags/keywords

arraylist, endpointdescription, endpointinterfacedescription, headerparameters, holder, holder, operationdescription, parameter, qname, qname, string, string, util, webparam, webparam, xml

The Axis 2 MustUnderstandTests.java source code

/*
 * 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 org.apache.axis2.description.Parameter;

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);
        Parameter understoodQNamesParameter = axisOperation.getParameter(OperationDescription.HEADER_PARAMETER_QNAMES);
        assertNotNull(understoodQNamesParameter);
        ArrayList understoodQNames = (ArrayList) understoodQNamesParameter.getValue();
        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;
            }
}

Other Axis 2 examples (source code examples)

Here is a short list of links related to this Axis 2 MustUnderstandTests.java source code file:

... this post is sponsored by my books ...

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2024 Alvin Alexander, alvinalexander.com
All Rights Reserved.

A percentage of advertising revenue from
pages under the /java/jwarehouse URI on this website is
paid back to open source projects.