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

Apache CXF example source code file (service.vm)

This example Apache CXF source code file (service.vm) 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 - Apache CXF tags/keywords

apache, asf, license, license, net, network, qname, qname, see, service, service, url, url, webendpoint, webservicefeature, wsdl_location, xml

The Apache CXF service.vm 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.

/*
 * $service.packageJavaDoc
 */

package $service.PackageName;

import java.net.MalformedURLException;
import java.net.URL;
import javax.xml.namespace.QName;
import javax.xml.ws.WebEndpoint;
import javax.xml.ws.WebServiceClient;
import javax.xml.ws.WebServiceFeature;
#foreach ($import in ${service.Imports}) 
import ${import};
#end

/**
 * This class was generated by $fullversion
 * $currentdate
 * Generated source version: $version
 * 
 */

#if ($service.classJavaDoc != "")
/**
 * $service.classJavaDoc
 */
#end

@WebServiceClient(name = "${service.ServiceName}", 
#if ($wsdlLocation != "")
                  wsdlLocation = "$wsdlLocation",
#end
                  targetNamespace = "$service.Namespace") 
#foreach ($annotation in $service.Annotations)
$annotation
#end
public class ${service.Name} extends ${serviceSuperclass} {

    public final static URL WSDL_LOCATION;
    public final static QName SERVICE = new QName("$service.Namespace", "$service.ServiceName");
#foreach ($port in ${service.Ports})
    public final static QName $port.Name = new QName("$service.Namespace", "$port.PortName");
#end
    static {
#if ($wsdlLocation != "")
        URL url = null;
        try {
            url = new URL("$wsdlLocation");
        } catch (MalformedURLException e) {
            System.err.println("Can not initialize the default wsdl from $wsdlLocation");
            // e.printStackTrace();
        }
        WSDL_LOCATION = url;
#else
        WSDL_LOCATION = null;
#end
    }

    public ${service.Name}(URL wsdlLocation) {
        super(wsdlLocation, SERVICE);
    }

    public ${service.Name}(URL wsdlLocation, QName serviceName) {
        super(wsdlLocation, serviceName);
    }

    public ${service.Name}() {
        super(WSDL_LOCATION, SERVICE);
    }
    
#if ($jaxws22)     
    public ${service.Name}(WebServiceFeature ... features) {
        super(WSDL_LOCATION, SERVICE, features);
    }
    public ${service.Name}(URL wsdlLocation, WebServiceFeature ... features) {
        super(wsdlLocation, SERVICE, features);
    }

    public ${service.Name}(URL wsdlLocation, QName serviceName, WebServiceFeature ... features) {
        super(wsdlLocation, serviceName, features);
    }
#end

#foreach ($port in $service.Ports)
    /**
     * 
     * @return
     *     returns ${port.InterfaceClass}
     */
    @WebEndpoint(name = "${port.PortName}")
    public ${port.InterfaceClass} get${port.Name}() {
        return super.getPort($port.Name, ${port.InterfaceClass}.class);
    }

    /**
     * 
     * @param features
     *     A list of {@link javax.xml.ws.WebServiceFeature} to configure on the proxy.  Supported features not in the <code>features parameter will have their default values.
     * @return
     *     returns ${port.InterfaceClass}
     */
    @WebEndpoint(name = "${port.PortName}")
    public ${port.InterfaceClass} get${port.Name}(WebServiceFeature... features) {
        return super.getPort($port.Name, ${port.InterfaceClass}.class, features);
    }
#end

}

Other Apache CXF examples (source code examples)

Here is a short list of links related to this Apache CXF service.vm source code file:

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

#1 New Release!

FP Best Seller

 

new blog posts

 

Copyright 1998-2021 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.