templates.webclient.ksoap.ksoap.class.vm Maven / Gradle / Ivy
#parse("${include}/generic.include.vm")
#parse("${include}/webclient.ksoap.include.vm")
#set ( $className ="${sourceinfo.interfaceClass.simpleName}WebserviceByKSoap")
$codewriter.setCurrentJavaFilename("$pkg", "${className}.java")
package $pkg;
#outputImports()
#include("${include}/webclient.ksoap.${sourceinfo.interfaceClass.simpleName}.import.vm")
import ${sourceinfo.stubClassName};
/**
*
* 基于于KSOAP的stub,实现 {@link #typeName(${sourceinfo.interfaceClass})}的Webservice接口
* 所有自来服务器端的{@link ServiceRuntime}异常都被封装在{@link RuntimeException}中抛出,
* 可以通过调用{@link ServiceRuntime#getServerStackTraceMessage()}获取服务器端异常的堆栈信息,
* 例如:
*
* try{
* double sim = faceapi.detectAndCompare2Face(
* TestFaceAPI.class.getResourceAsStream("/images/guyadong-1.jpg")
* , null
* , TestFaceAPI.class.getResourceAsStream("/images/guyadong-2.jpg")
* , null);
* System.out.printf("similarity=%f\n",sim);
* }catch(RuntimeException e){
* if(e.getCause() instanceof ServiceRuntime){
* ((ServiceRuntime)e.getCause()).printServerStackTrace();
* }else
* e.printStackTrace();
* }
*
* $GENERAED_BY
* @author guyadong
*
*/
public class ${className} extends #typeName($sourceinfo.baseClass){
private final $stubClassName stub;
public $stubClassName getStub(){
return stub;
}
#parse("${include}/webclient.ksoap.${sourceinfo.interfaceClass.simpleName}.body.vm")
#set( $method2PortMap=$sourceinfo.method2PortMap)
#foreach ($method in $TOOL.sortBySignature($methods))
#set( $port = $method2PortMap.get($method))
#set( $isVoid=$TOOL.isVoid($method.returnType))
@Override//$velocityCount
public #typeParametersDefine() #typeName($method.genericReturnType) $method.name (#join($method.parameters '#pamameterType($e) $e.name' ',')) #fillThrows($TOOL.sortBy($method.genericExceptionTypes,"simpleName")){
try{
#RETURN() stub.${port.name}(#join($method.parameters '#if($sourceinfo.isGenericTypeClass($method,$e.type))${e.name}.toString()#else$e.name#end' ','));
}catch (ServiceRuntime e) {
throw new RuntimeException(e);
}
}
#end###foreach ($method in $methods)
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy