## 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 $service.PackageName;

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

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

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

    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 {
        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;
    }

    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);
    }

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

}
