|
Apache CXF example source code file (client.vm)
The Apache CXF client.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. package $intf.PackageName; /** * Please modify this class to meet your needs * This class is not complete */ import java.io.File; import java.net.MalformedURLException; import java.net.URL; import javax.xml.namespace.QName; #if ($service.PackageName != $intf.PackageName) import ${service.PackageName}.${service.Name}; #end #foreach ($import in $intf.Imports) import ${import}; #end /** * This class was generated by $fullversion * $currentdate * Generated source version: $version * */ public final class ${clientClassName} { private static final QName SERVICE_NAME = new QName("$service.Namespace", "$service.ServiceName"); private ${clientClassName}() { } public static void main(String args[]) throws Exception { URL wsdlURL = ${service.Name}.WSDL_LOCATION; if (args.length > 0) { File wsdlFile = new File(args[0]); try { if (wsdlFile.exists()) { wsdlURL = wsdlFile.toURI().toURL(); } else { wsdlURL = new URL(args[0]); } } catch (MalformedURLException e) { e.printStackTrace(); } } $service.Name ss = new ${service.Name}(wsdlURL, SERVICE_NAME); $intf.Name port = ss.get${port.Name}(); #foreach ($method in $intf.Methods) { System.out.println("Invoking ${method.Name}..."); #foreach ($parameter in $method.Parameters) #set($paramValueName = "_${method.Name}_${parameter.Name}") #if ($parameter.Style.toString() == "IN") ${parameter.writeDefaultValue(${out}, " ", ${method.Name}, ${paramValueName})} #elseif ($parameter.Style.toString() == "INOUT") #set($paramValueName2 = "${paramValueName}Val") ${parameter.writeDefaultValue(${out}, " ", ${method.Name}, ${paramValueName2})} javax.xml.ws.Holder<${parameter.ClassName}> $paramValueName = new javax.xml.ws.Holder<${parameter.ClassName}>(${paramValueName2}); #elseif ($parameter.Style.toString() == "OUT") javax.xml.ws.Holder<${parameter.ClassName}> $paramValueName = new javax.xml.ws.Holder<${parameter.ClassName}>(); #end #end #set($indent = " ") #if($method.Exceptions.size() > 0) #set($indent = " ") try { #end #if($method.return.ClassName != "void")${indent}${method.return.ClassName} _${method.Name}__return = #else${indent}#end port.${method.Name}(#foreach($parameter in $method.Parameters)_${method.Name}_${parameter.Name}#if($velocityCount != $method.parameterCount), #end#end); #if($method.return.Type != "void") ${indent}System.out.println("${method.Name}.result=" + _${method.Name}__return); #end #foreach ($parameter in $method.Parameters) #if ($parameter.Style.toString() != "IN") #set($paramValueName = "_${method.Name}_${parameter.Name}") ${indent}System.out.println("${method.Name}.${paramValueName}=" + ${paramValueName}.value); #end #end #if($method.Exceptions.size() > 0) }#foreach($exception in $method.Exceptions) catch ($exception.ClassName e) { System.out.println("Expected exception: $exception.Name has occurred."); System.out.println(e.toString()); }#end #end ${indent}} #end System.exit(0); } } Other Apache CXF examples (source code examples)Here is a short list of links related to this Apache CXF client.vm source code file: |
... this post is sponsored by my books ... | |
#1 New Release! |
FP Best Seller |
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.