`
soboer
  • 浏览: 1307542 次
文章分类
社区版块
存档分类
最新评论

BPEL实例运行[3]——流程的调用

 
阅读更多

首先需要得到相应的WSDL,通过这些文件可以生成WSDL文件中定义的Type所对应的Java 类,这些类有些类似于Bean,用于存储数据(如果知道TypeWSDL中的定义的话也可以手工完成相应类的定义,实现相应的方法即可)。使用Apache的包org.apache.axis.wsdl中的WSDL2Java.java将本例中的3WSDL文件转化为java文件。

WSDL2Java.java

/**//*
*Copyright2001-2004TheApacheSoftwareFoundation.
*
*LicensedundertheApacheLicense,Version2.0(the"License");
*youmaynotusethisfileexceptincompliancewiththeLicense.
*YoumayobtainacopyoftheLicenseat
*
*
http://www.apache.org/licenses/LICENSE-2.0
*
*Unlessrequiredbyapplicablelaworagreedtoinwriting,software
*distributedundertheLicenseisdistributedonan"ASIS"BASIS,
*WITHOUTWARRANTIESORCONDITIONSOFANYKIND,eitherexpressorimplied.
*SeetheLicenseforthespecificlanguagegoverningpermissionsand
*limitationsundertheLicense.
*/

packageorg.apache.axis.wsdl;

importorg.apache.axis.constants.Scope;
importorg.apache.axis.utils.CLOption;
importorg.apache.axis.utils.CLOptionDescriptor;
importorg.apache.axis.utils.ClassUtils;
importorg.apache.axis.utils.JavaUtils;
importorg.apache.axis.utils.Messages;
importorg.apache.axis.wsdl.gen.Parser;
importorg.apache.axis.wsdl.gen.WSDL2;
importorg.apache.axis.wsdl.toJava.Emitter;
importorg.apache.axis.wsdl.toJava.NamespaceSelector;

/***//**
*CommandlineinterfacetotheWSDL2Javautility
*/

publicclassWSDL2JavaextendsWSDL2...{

//Defineourshortone-letteroptionidentifiers.

/***//**FieldSERVER_OPT*/
protectedstaticfinalintSERVER_OPT='s';

/***//**FieldSKELETON_DEPLOY_OPT*/
protectedstaticfinalintSKELETON_DEPLOY_OPT='S';

/***//**FieldNAMESPACE_OPT*/
protectedstaticfinalintNAMESPACE_OPT='N';

/***//**FieldNAMESPACE_FILE_OPT*/
protectedstaticfinalintNAMESPACE_FILE_OPT='f';

/***//**FieldOUTPUT_OPT*/
protectedstaticfinalintOUTPUT_OPT='o';

/***//**FieldSCOPE_OPT*/
protectedstaticfinalintSCOPE_OPT='d';

/***//**FieldTEST_OPT*/
protectedstaticfinalintTEST_OPT='t';
/***//**FieldBUILDFILE_OPT*/
protectedstaticfinalintBUILDFILE_OPT='B';
/***//**FieldPACKAGE_OPT*/
protectedstaticfinalintPACKAGE_OPT='p';

/***//**FieldALL_OPT*/
protectedstaticfinalintALL_OPT='a';

/***//**FieldTYPEMAPPING_OPT*/
protectedstaticfinalintTYPEMAPPING_OPT='T';

/***//**FieldFACTORY_CLASS_OPT*/
protectedstaticfinalintFACTORY_CLASS_OPT='F';

/***//**FieldHELPER_CLASS_OPT*/
protectedstaticfinalintHELPER_CLASS_OPT='H';

/***//**FieldUSERNAME_OPT*/
protectedstaticfinalintUSERNAME_OPT='U';

/***//**FieldPASSWORD_OPT*/
protectedstaticfinalintPASSWORD_OPT='P';

protectedstaticfinalintCLASSPATH_OPT='X';

/***//**FieldbPackageOpt*/
protectedbooleanbPackageOpt=false;

/***//**Fieldnamespaceinclude*/
protectedstaticfinalintNS_INCLUDE_OPT='i';

/***//**Filednamespaceexclude*/
protectedstaticfinalintNS_EXCLUDE_OPT='x';

/***//**FieldIMPL_CLASS_OPT*/
protectedstaticfinalintIMPL_CLASS_OPT='c';

/***//**FieldALLOW_INVALID_URL_OPT*/
protectedstaticfinalintALLOW_INVALID_URL_OPT='u';

/***//**Wraparraysoption*/
protectedstaticfinalintWRAP_ARRAYS_OPT='w';

/***//**Fieldemitter*/
privateEmitteremitter;

/***//**
*Definetheunderstoodoptions.EachCLOptionDescriptorcontains:
*-The"long"versionoftheoption.Eg,"help"meansthat"--help"will
*berecognised.
*-Theoptionflags,governingtheoption'sargument(s).
*-The"short"versionoftheoption.Eg,'h'meansthat"-h"willbe
*recognised.
*-Adescriptionoftheoptionfortheusagemessage
*/


protectedstaticfinalCLOptionDescriptor[]options=
newCLOptionDescriptor[]...{
newCLOptionDescriptor("server-side",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
SERVER_OPT,Messages.getMessage(
"optionSkel00")),
newCLOptionDescriptor("skeletonDeploy",
CLOptionDescriptor.ARGUMENT_REQUIRED,
SKELETON_DEPLOY_OPT,
Messages.getMessage(
"optionSkeletonDeploy00")),
newCLOptionDescriptor("NStoPkg",
CLOptionDescriptor.DUPLICATES_ALLOWED
+CLOptionDescriptor.ARGUMENTS_REQUIRED_2,
NAMESPACE_OPT,
Messages.getMessage(
"optionNStoPkg00")),
newCLOptionDescriptor("fileNStoPkg",
CLOptionDescriptor.ARGUMENT_REQUIRED,
NAMESPACE_FILE_OPT,
Messages.getMessage(
"optionFileNStoPkg00")),
newCLOptionDescriptor("package",CLOptionDescriptor.ARGUMENT_REQUIRED,
PACKAGE_OPT,
Messages.getMessage(
"optionPackage00")),
newCLOptionDescriptor("output",CLOptionDescriptor.ARGUMENT_REQUIRED,
OUTPUT_OPT,
Messages.getMessage(
"optionOutput00")),
newCLOptionDescriptor("deployScope",
CLOptionDescriptor.ARGUMENT_REQUIRED,SCOPE_OPT,
Messages.getMessage(
"optionScope00")),
newCLOptionDescriptor("testCase",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
TEST_OPT,Messages.getMessage(
"optionTest00")),
newCLOptionDescriptor("all",CLOptionDescriptor.ARGUMENT_DISALLOWED,
ALL_OPT,Messages.getMessage(
"optionAll00")),
newCLOptionDescriptor("typeMappingVersion",
CLOptionDescriptor.ARGUMENT_REQUIRED,
TYPEMAPPING_OPT,
Messages.getMessage(
"optionTypeMapping00")),
newCLOptionDescriptor("factory",CLOptionDescriptor.ARGUMENT_REQUIRED,
FACTORY_CLASS_OPT,
Messages.getMessage(
"optionFactory00")),
newCLOptionDescriptor("helperGen",
CLOptionDescriptor.ARGUMENT_DISALLOWED,
HELPER_CLASS_OPT,
Messages.getMessage(
"optionHelper00")),
newCLOptionDescriptor("buildFile",CLOptionDescriptor.ARGUMENT_DISALLOWED,
BUILDFILE_OPT,
Messages.getMessage(
"optionBuildFile00")),
newCLOptionDescriptor("user",CLOptionDescriptor.ARGUMENT_REQUIRED,
USERNAME_OPT,
Messages.getMessage(
"optionUsername")),
newCLOptionDescriptor("password",
CLOptionDescriptor.ARGUMENT_REQUIRED,
PASSWORD_OPT,
Messages.getMessage(
"optionPassword")),
newCLOptionDescriptor("classpath",
CLOptionDescriptor.ARGUMENT_OPTIONAL,
CLASSPATH_OPT,
Messages.getMessage(
"optionClasspath")),
newCLOptionDescriptor("nsInclude",
CLOptionDescriptor.DUPLICATES_ALLOWED
+CLOptionDescriptor.ARGUMENT_REQUIRED,
NS_INCLUDE_OPT,
Messages.getMessage(
"optionNSInclude")),
newCLOptionDescriptor("nsExclude",
CLOptionDescriptor.DUPLICATES_ALLOWED
+CLOptionDescriptor.ARGUMENT_REQUIRED,
NS_EXCLUDE_OPT,
Messages.getMessage(
"optionNSExclude")),
newCLOptionDescriptor("implementationClassName",
CLOptionDescriptor.ARGUMENT_REQUIRED,
IMPL_CLASS_OPT,
Messages.getMessage(
"implementationClassName")),
newCLOptionDescriptor("allowInvalidURL",CLOptionDescriptor.ARGUMENT_DISALLOWED,
ALLOW_INVALID_URL_OPT,Messages.getMessage(
"optionAllowInvalidURL")),
newCLOptionDescriptor("wrapArrays",
CLOptionDescriptor.ARGUMENT_OPTIONAL,
WRAP_ARRAYS_OPT,
Messages.getMessage(
"optionWrapArrays")),
}
;

/***//**
*InstantiateaWSDL2Javaemitter.
*/

protectedWSDL2Java()...{

//emitteristhesameastheparent'sparservariable.Justcastit
//hereoncesowedon'thavetocastiteverytimeweuseit.
emitter=(Emitter)parser;

addOptions(options);
}
//ctor

/***//**
*InstantiateanextensionoftheParser
*
*
@return
*/

protectedParsercreateParser()...{
returnnewEmitter();
}
//createParser

/***//**
*Parseanoption
*
*
@paramoptionistheoption
*/

protectedvoidparseOption(CLOptionoption)...{

switch(option.getId())...{

caseFACTORY_CLASS_OPT:
emitter.setFactory(option.getArgument());
break;

caseHELPER_CLASS_OPT:
emitter.setHelperWanted(
true);
break;

caseSKELETON_DEPLOY_OPT:
emitter.setSkeletonWanted(
JavaUtils.isTrueExplicitly(option.getArgument(
0)));

//--skeletonDeployassumes--server-side,sofallthru
caseSERVER_OPT:
emitter.setServerSide(
true);
break;

caseNAMESPACE_OPT:
Stringnamespace
=option.getArgument(0);
StringpackageName
=option.getArgument(1);

emitter.getNamespaceMap().put(namespace,packageName);
break;

caseNAMESPACE_FILE_OPT:
emitter.setNStoPkg(option.getArgument());
break;

casePACKAGE_OPT:
bPackageOpt
=true;

emitter.setPackageName(option.getArgument());
break;

caseOUTPUT_OPT:
emitter.setOutputDir(option.getArgument());
break;

caseSCOPE_OPT:
Stringarg
=option.getArgument();

//Provide'null'default,preventslogginginternalerror.
//wehavesomethingdifferenttoreporthere.
Scopescope=Scope.getScope(arg,null);

if(scope!=null)...{
emitter.setScope(scope);
}
else...{
System.err.println(Messages.getMessage(
"badScope00",arg));
}

break;

caseTEST_OPT:
emitter.setTestCaseWanted(
true);
break;
caseBUILDFILE_OPT:
emitter.setBuildFileWanted(
true);
break;
caseALL_OPT:
emitter.setAllWanted(
true);
break;

caseTYPEMAPPING_OPT:
StringtmValue
=option.getArgument();

if(tmValue.equals("1.0"))...{
emitter.setTypeMappingVersion(
"1.0");
}
elseif(tmValue.equals("1.1"))...{
emitter.setTypeMappingVersion(
"1.1");
}
elseif(tmValue.equals("1.2"))...{
emitter.setTypeMappingVersion(
"1.2");
}
elseif(tmValue.equals("1.3"))...{
emitter.setTypeMappingVersion(
"1.3");
}
else...{
System.out.println(
Messages.getMessage(
"badTypeMappingOption00"));
}

break;

caseUSERNAME_OPT:
emitter.setUsername(option.getArgument());
break;

casePASSWORD_OPT:
emitter.setPassword(option.getArgument());
break;

caseCLASSPATH_OPT:
ClassUtils.setDefaultClassLoader(ClassUtils.createClassLoader(
option.getArgument(),
this.getClass().getClassLoader()));
break;

caseNS_INCLUDE_OPT:
NamespaceSelectorinclude
=newNamespaceSelector();
include.setNamespace(option.getArgument());
emitter.getNamespaceIncludes().add(include);
break;
caseNS_EXCLUDE_OPT:
NamespaceSelectorexclude
=newNamespaceSelector();
exclude.setNamespace(option.getArgument());
emitter.getNamespaceExcludes().add(exclude);
break;

caseIMPL_CLASS_OPT:
emitter.setImplementationClassName(option.getArgument());
break;

caseALLOW_INVALID_URL_OPT:
emitter.setAllowInvalidURL(
true);
break;

caseWRAP_ARRAYS_OPT:
emitter.setWrapArrays(
true);
break;

default:
super.parseOption(option);
}

}
//parseOption

/***//**
*validateOptions
*Thismethodisinvokedaftertheoptionsaresettovalidate
*theoptionsettings.
*/

protectedvoidvalidateOptions()...{

super.validateOptions();

//validateargumentcombinations
if(emitter.isSkeletonWanted()&&!emitter.isServerSide())...{
System.out.println(Messages.getMessage(
"badSkeleton00"));
printUsage();
}


if(!emitter.getNamespaceMap().isEmpty()&&bPackageOpt)...{
System.out.println(Messages.getMessage(
"badpackage00"));
printUsage();
}

}
//validateOptions

/***//**
*Main
*RuntheWSDL2Javaemitterwiththespecifiedcommand-linearguments
*
*
@paramargscommand-linearguments
*/

publicstaticvoidmain(Stringargs[])...{

WSDL2Javawsdl2java
=newWSDL2Java();

//wsdl2java.run(args);

String[]v
=...{"E:/ProgramFiles/activeBPEL/Designer/workspace/airline/wsdl/Travel.wsdl"};

wsdl2java.run(v);
}

}

生成4个文件,分别如下:

airline包中

FlightConfirmationType.java

/***//**
*FlightConfirmationType.java
*
*Thisfilewasauto-generatedfromWSDL
*bytheApacheAxis#axisVersion##today#WSDL2Javaemitter.
*/


packagecom.packtpub.service.airline;

publicclassFlightConfirmationTypeimplementsjava.io.Serializable...{
privatejava.lang.StringflightNo;

privatecom.packtpub.service.airline.TravelClassTypetravelClass;

privatefloatprice;

privatejava.util.CalendardepartureDateTime;

privatejava.util.CalendarreturnDateTime;

privatebooleanapproved;

publicFlightConfirmationType()...{
}


publicFlightConfirmationType(
java.lang.StringflightNo,
com.packtpub.service.airline.TravelClassTypetravelClass,
floatprice,
java.util.CalendardepartureDateTime,
java.util.CalendarreturnDateTime,
booleanapproved)...{
this.flightNo=flightNo;
this.travelClass=travelClass;
this.price=price;
this.departureDateTime=departureDateTime;
this.returnDateTime=returnDateTime;
this.approved=approved;
}



/***//**
*GetstheflightNovalueforthisFlightConfirmationType.
*
*
@returnflightNo
*/

publicjava.lang.StringgetFlightNo()...{
returnflightNo;
}



/***//**
*SetstheflightNovalueforthisFlightConfirmationType.
*
*
@paramflightNo
*/

publicvoidsetFlightNo(java.lang.StringflightNo)...{
this.flightNo=flightNo;
}



/***//**
*GetsthetravelClassvalueforthisFlightConfirmationType.
*
*
@returntravelClass
*/

publiccom.packtpub.service.airline.TravelClassTypegetTravelClass()...{
returntravelClass;
}



/***//**
*SetsthetravelClassvalueforthisFlightConfirmationType.
*
*
@paramtravelClass
*/

publicvoidsetTravelClass(com.packtpub.service.airline.TravelClassTypetravelClass)...{
this.travelClass=travelClass;
}



/***//**
*GetsthepricevalueforthisFlightConfirmationType.
*
*
@returnprice
*/

publicfloatgetPrice()...{
returnprice;
}



/***//**
*SetsthepricevalueforthisFlightConfirmationType.
*
*
@paramprice
*/

publicvoidsetPrice(floatprice)...{
this.price=price;
}



/***//**
*GetsthedepartureDateTimevalueforthisFlightConfirmationType.
*
*
@returndepartureDateTime
*/

publicjava.util.CalendargetDepartureDateTime()...{
returndepartureDateTime;
}



/***//**
*SetsthedepartureDateTimevalueforthisFlightConfirmationType.
*
*
@paramdepartureDateTime
*/

publicvoidsetDepartureDateTime(java.util.CalendardepartureDateTime)...{
this.departureDateTime=departureDateTime;
}



/***//**
*GetsthereturnDateTimevalueforthisFlightConfirmationType.
*
*
@returnreturnDateTime
*/

publicjava.util.CalendargetReturnDateTime()...{
returnreturnDateTime;
}



/***//**
*SetsthereturnDateTimevalueforthisFlightConfirmationType.
*
*
@paramreturnDateTime
*/

publicvoidsetReturnDateTime(java.util.CalendarreturnDateTime)...{
this.returnDateTime=returnDateTime;
}



/***//**
*GetstheapprovedvalueforthisFlightConfirmationType.
*
*
@returnapproved
*/

publicbooleanisApproved()...{
returnapproved;
}



/***//**
*SetstheapprovedvalueforthisFlightConfirmationType.
*
*
@paramapproved
*/

publicvoidsetApproved(booleanapproved)...{
this.approved=approved;
}


privatejava.lang.Object__equalsCalc=null;
publicsynchronizedbooleanequals(java.lang.Objectobj)...{
if(!(objinstanceofFlightConfirmationType))returnfalse;
FlightConfirmationTypeother
=(FlightConfirmationType)obj;
if(obj==null)returnfalse;
if(this==obj)returntrue;
if(__equalsCalc!=null)...{
return(__equalsCalc==obj);
}

__equalsCalc
=obj;
boolean_equals;
_equals
=true&&
((
this.flightNo==null&&other.getFlightNo()==null)||
(
this.flightNo!=null&&
this.flightNo.equals(other.getFlightNo())))&&
((
this.travelClass==null&&other.getTravelClass()==null)||
(
this.travelClass!=null&&
this.travelClass.equals(other.getTravelClass())))&&
this.price==other.getPrice()&&
((
this.departureDateTime==null&&other.getDepartureDateTime()==null)||
(
this.departureDateTime!=null&&
this.departureDateTime.equals(other.getDepartureDateTime())))&&
((
this.returnDateTime==null&&other.getReturnDateTime()==null)||
(
this.returnDateTime!=null&&
this.returnDateTime.equals(other.getReturnDateTime())))&&
this.approved==other.isApproved();
__equalsCalc
=null;
return_equals;
}


privateboolean__hashCodeCalc=false;
publicsynchronizedinthashCode()...{
if(__hashCodeCalc)...{
return0;
}

__hashCodeCalc
=true;
int_hashCode=1;
if(getFlightNo()!=null)...{
_hashCode
+=getFlightNo().hashCode();
}

if(getTravelClass()!=null)...{
_hashCode
+=getTravelClass().hashCode();
}

_hashCode
+=newFloat(getPrice()).hashCode();
if(getDepartureDateTime()!=null)...{
_hashCode
+=getDepartureDateTime().hashCode();
}

if(getReturnDateTime()!=null)...{
_hashCode
+=getReturnDateTime().hashCode();
}

_hashCode
+=(isApproved()?Boolean.TRUE:Boolean.FALSE).hashCode();
__hashCodeCalc
=false;
return_hashCode;
}


//Typemetadata
privatestaticorg.apache.axis.description.TypeDesctypeDesc=
neworg.apache.axis.description.TypeDesc(FlightConfirmationType.class,true);

static...{
typeDesc.setXmlType(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","FlightConfirmationType"));
org.apache.axis.description.ElementDescelemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"flightNo");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","FlightNo"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"travelClass");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","TravelClass"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","TravelClassType"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"price");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","Price"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","float"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"departureDateTime");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","DepartureDateTime"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","dateTime"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"returnDateTime");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","ReturnDateTime"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","dateTime"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"approved");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","Approved"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","boolean"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
}


/***//**
*Returntypemetadataobject
*/

publicstaticorg.apache.axis.description.TypeDescgetTypeDesc()...{
returntypeDesc;
}


/***//**
*GetCustomSerializer
*/

publicstaticorg.apache.axis.encoding.SerializergetSerializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.BeanSerializer(
_javaType,_xmlType,typeDesc);
}


/***//**
*GetCustomDeserializer
*/

publicstaticorg.apache.axis.encoding.DeserializergetDeserializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.BeanDeserializer(
_javaType,_xmlType,typeDesc);
}


}

FlightRequestType.java

/***//**
*FlightRequestType.java
*
*Thisfilewasauto-generatedfromWSDL
*bytheApacheAxis#axisVersion##today#WSDL2Javaemitter.
*/


packagecom.packtpub.service.airline;

publicclassFlightRequestTypeimplementsjava.io.Serializable...{
privatejava.lang.StringoriginFrom;

privatejava.lang.StringdestinationTo;

privatejava.util.DatedesiredDepartureDate;

privatejava.util.DatedesiredReturnDate;

publicFlightRequestType()...{
}


publicFlightRequestType(
java.lang.StringoriginFrom,
java.lang.StringdestinationTo,
java.util.DatedesiredDepartureDate,
java.util.DatedesiredReturnDate)
...{
this.originFrom=originFrom;
this.destinationTo=destinationTo;
this.desiredDepartureDate=desiredDepartureDate;
this.desiredReturnDate=desiredReturnDate;
}



/***//**
*GetstheoriginFromvalueforthisFlightRequestType.
*
*
@returnoriginFrom
*/

publicjava.lang.StringgetOriginFrom()...{
returnoriginFrom;
}



/***//**
*SetstheoriginFromvalueforthisFlightRequestType.
*
*
@paramoriginFrom
*/

publicvoidsetOriginFrom(java.lang.StringoriginFrom)...{
this.originFrom=originFrom;
}



/***//**
*GetsthedestinationTovalueforthisFlightRequestType.
*
*
@returndestinationTo
*/

publicjava.lang.StringgetDestinationTo()...{
returndestinationTo;
}



/***//**
*SetsthedestinationTovalueforthisFlightRequestType.
*
*
@paramdestinationTo
*/

publicvoidsetDestinationTo(java.lang.StringdestinationTo)...{
this.destinationTo=destinationTo;
}



/***//**
*GetsthedesiredDepartureDatevalueforthisFlightRequestType.
*
*
@returndesiredDepartureDate
*/

publicjava.util.DategetDesiredDepartureDate()...{
returndesiredDepartureDate;
}



/***//**
*SetsthedesiredDepartureDatevalueforthisFlightRequestType.
*
*
@paramdesiredDepartureDate
*/

publicvoidsetDesiredDepartureDate(java.util.DatedesiredDepartureDate)...{
this.desiredDepartureDate=desiredDepartureDate;
}



/***//**
*GetsthedesiredReturnDatevalueforthisFlightRequestType.
*
*
@returndesiredReturnDate
*/

publicjava.util.DategetDesiredReturnDate()...{
returndesiredReturnDate;
}



/***//**
*SetsthedesiredReturnDatevalueforthisFlightRequestType.
*
*
@paramdesiredReturnDate
*/

publicvoidsetDesiredReturnDate(java.util.DatedesiredReturnDate)...{
this.desiredReturnDate=desiredReturnDate;
}


privatejava.lang.Object__equalsCalc=null;
publicsynchronizedbooleanequals(java.lang.Objectobj)...{
if(!(objinstanceofFlightRequestType))returnfalse;
FlightRequestTypeother
=(FlightRequestType)obj;
if(obj==null)returnfalse;
if(this==obj)returntrue;
if(__equalsCalc!=null)...{
return(__equalsCalc==obj);
}

__equalsCalc
=obj;
boolean_equals;
_equals
=true&&
((
this.originFrom==null&&other.getOriginFrom()==null)||
(
this.originFrom!=null&&
this.originFrom.equals(other.getOriginFrom())))&&
((
this.destinationTo==null&&other.getDestinationTo()==null)||
(
this.destinationTo!=null&&
this.destinationTo.equals(other.getDestinationTo())))&&
((
this.desiredDepartureDate==null&&other.getDesiredDepartureDate()==null)||
(
this.desiredDepartureDate!=null&&
this.desiredDepartureDate.equals(other.getDesiredDepartureDate())))&&
((
this.desiredReturnDate==null&&other.getDesiredReturnDate()==null)||
(
this.desiredReturnDate!=null&&
this.desiredReturnDate.equals(other.getDesiredReturnDate())));
__equalsCalc
=null;
return_equals;
}


privateboolean__hashCodeCalc=false;
publicsynchronizedinthashCode()...{
if(__hashCodeCalc)...{
return0;
}

__hashCodeCalc
=true;
int_hashCode=1;
if(getOriginFrom()!=null)...{
_hashCode
+=getOriginFrom().hashCode();
}

if(getDestinationTo()!=null)...{
_hashCode
+=getDestinationTo().hashCode();
}

if(getDesiredDepartureDate()!=null)...{
_hashCode
+=getDesiredDepartureDate().hashCode();
}

if(getDesiredReturnDate()!=null)...{
_hashCode
+=getDesiredReturnDate().hashCode();
}

__hashCodeCalc
=false;
return_hashCode;
}


//Typemetadata
privatestaticorg.apache.axis.description.TypeDesctypeDesc=
neworg.apache.axis.description.TypeDesc(FlightRequestType.class,true);

static...{
typeDesc.setXmlType(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","FlightRequestType"));
org.apache.axis.description.ElementDescelemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"originFrom");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","OriginFrom"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"destinationTo");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","DestinationTo"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"desiredDepartureDate");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","DesiredDepartureDate"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","date"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"desiredReturnDate");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","DesiredReturnDate"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","date"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
}


/***//**
*Returntypemetadataobject
*/

publicstaticorg.apache.axis.description.TypeDescgetTypeDesc()...{
returntypeDesc;
}


/***//**
*GetCustomSerializer
*/

publicstaticorg.apache.axis.encoding.SerializergetSerializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.BeanSerializer(
_javaType,_xmlType,typeDesc);
}


/***//**
*GetCustomDeserializer
*/

publicstaticorg.apache.axis.encoding.DeserializergetDeserializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.BeanDeserializer(
_javaType,_xmlType,typeDesc);
}


}

TravelClassType.java

employee包中

/***//**
*TravelClassType.java
*
*Thisfilewasauto-generatedfromWSDL
*bytheApacheAxis#axisVersion##today#WSDL2Javaemitter.
*/


packagecom.packtpub.service.airline;

publicclassTravelClassTypeimplementsjava.io.Serializable...{
privatejava.lang.String_value_;
privatestaticjava.util.HashMap_table_=newjava.util.HashMap();

//Constructor
protectedTravelClassType(java.lang.Stringvalue)...{
_value_
=value;
_table_.put(_value_,
this);
}


publicstaticfinaljava.lang.String_Economy="Economy";
publicstaticfinaljava.lang.String_Business="Business";
publicstaticfinaljava.lang.String_First="First";
publicstaticfinalTravelClassTypeEconomy=newTravelClassType(_Economy);
publicstaticfinalTravelClassTypeBusiness=newTravelClassType(_Business);
publicstaticfinalTravelClassTypeFirst=newTravelClassType(_First);
publicjava.lang.StringgetValue()...{return_value_;}
publicstaticTravelClassTypefromValue(java.lang.Stringvalue)
throwsjava.lang.IllegalArgumentException...{
TravelClassTypeenumeration
=(TravelClassType)
_table_.get(value);
if(enumeration==null)thrownewjava.lang.IllegalArgumentException();
returnenumeration;
}

publicstaticTravelClassTypefromString(java.lang.Stringvalue)
throwsjava.lang.IllegalArgumentException...{
returnfromValue(value);
}

publicbooleanequals(java.lang.Objectobj)...{return(obj==this);}
publicinthashCode()...{returntoString().hashCode();}
publicjava.lang.StringtoString()...{return_value_;}
publicjava.lang.ObjectreadResolve()throwsjava.io.ObjectStreamException...{returnfromValue(_value_);}
publicstaticorg.apache.axis.encoding.SerializergetSerializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.EnumSerializer(
_javaType,_xmlType);
}

publicstaticorg.apache.axis.encoding.DeserializergetDeserializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.EnumDeserializer(
_javaType,_xmlType);
}

//Typemetadata
privatestaticorg.apache.axis.description.TypeDesctypeDesc=
neworg.apache.axis.description.TypeDesc(TravelClassType.class);

static...{
typeDesc.setXmlType(
newjavax.xml.namespace.QName("http://packtpub.com/service/airline/","TravelClassType"));
}

/***//**
*Returntypemetadataobject
*/

publicstaticorg.apache.axis.description.TypeDescgetTypeDesc()...{
returntypeDesc;
}


}

EmployeeType.java

/***//**
*EmployeeType.java
*
*Thisfilewasauto-generatedfromWSDL
*bytheApacheAxis#axisVersion##today#WSDL2Javaemitter.
*/


packagecom.packtpub.service.employee;

publicclassEmployeeTypeimplementsjava.io.Serializable...{
privatejava.lang.StringfirstName;

privatejava.lang.StringlastName;

privatejava.lang.Stringdepartement;

publicEmployeeType()...{
}


publicEmployeeType(
java.lang.StringfirstName,
java.lang.StringlastName,
java.lang.Stringdepartement)
...{
this.firstName=firstName;
this.lastName=lastName;
this.departement=departement;
}



/***//**
*GetsthefirstNamevalueforthisEmployeeType.
*
*
@returnfirstName
*/

publicjava.lang.StringgetFirstName()...{
returnfirstName;
}



/***//**
*SetsthefirstNamevalueforthisEmployeeType.
*
*
@paramfirstName
*/

publicvoidsetFirstName(java.lang.StringfirstName)...{
this.firstName=firstName;
}



/***//**
*GetsthelastNamevalueforthisEmployeeType.
*
*
@returnlastName
*/

publicjava.lang.StringgetLastName()...{
returnlastName;
}



/***//**
*SetsthelastNamevalueforthisEmployeeType.
*
*
@paramlastName
*/

publicvoidsetLastName(java.lang.StringlastName)...{
this.lastName=lastName;
}



/***//**
*GetsthedepartementvalueforthisEmployeeType.
*
*
@returndepartement
*/

publicjava.lang.StringgetDepartement()...{
returndepartement;
}



/***//**
*SetsthedepartementvalueforthisEmployeeType.
*
*
@paramdepartement
*/

publicvoidsetDepartement(java.lang.Stringdepartement)...{
this.departement=departement;
}


privatejava.lang.Object__equalsCalc=null;
publicsynchronizedbooleanequals(java.lang.Objectobj)...{
if(!(objinstanceofEmployeeType))returnfalse;
EmployeeTypeother
=(EmployeeType)obj;
if(obj==null)returnfalse;
if(this==obj)returntrue;
if(__equalsCalc!=null)...{
return(__equalsCalc==obj);
}

__equalsCalc
=obj;
boolean_equals;
_equals
=true&&
((
this.firstName==null&&other.getFirstName()==null)||
(
this.firstName!=null&&
this.firstName.equals(other.getFirstName())))&&
((
this.lastName==null&&other.getLastName()==null)||
(
this.lastName!=null&&
this.lastName.equals(other.getLastName())))&&
((
this.departement==null&&other.getDepartement()==null)||
(
this.departement!=null&&
this.departement.equals(other.getDepartement())));
__equalsCalc
=null;
return_equals;
}


privateboolean__hashCodeCalc=false;
publicsynchronizedinthashCode()...{
if(__hashCodeCalc)...{
return0;
}

__hashCodeCalc
=true;
int_hashCode=1;
if(getFirstName()!=null)...{
_hashCode
+=getFirstName().hashCode();
}

if(getLastName()!=null)...{
_hashCode
+=getLastName().hashCode();
}

if(getDepartement()!=null)...{
_hashCode
+=getDepartement().hashCode();
}

__hashCodeCalc
=false;
return_hashCode;
}


//Typemetadata
privatestaticorg.apache.axis.description.TypeDesctypeDesc=
neworg.apache.axis.description.TypeDesc(EmployeeType.class,true);

static...{
typeDesc.setXmlType(
newjavax.xml.namespace.QName("http://packtpub.com/service/employee/","EmployeeType"));
org.apache.axis.description.ElementDescelemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"firstName");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/employee/","FirstName"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"lastName");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/employee/","LastName"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
elemField
=neworg.apache.axis.description.ElementDesc();
elemField.setFieldName(
"departement");
elemField.setXmlName(
newjavax.xml.namespace.QName("http://packtpub.com/service/employee/","Departement"));
elemField.setXmlType(
newjavax.xml.namespace.QName("http://www.w3.org/2001/XMLSchema","string"));
elemField.setNillable(
false);
typeDesc.addFieldDesc(elemField);
}


/***//**
*Returntypemetadataobject
*/

publicstaticorg.apache.axis.description.TypeDescgetTypeDesc()...{
returntypeDesc;
}


/***//**
*GetCustomSerializer
*/

publicstaticorg.apache.axis.encoding.SerializergetSerializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.BeanSerializer(
_javaType,_xmlType,typeDesc);
}


/***//**
*GetCustomDeserializer
*/

publicstaticorg.apache.axis.encoding.DeserializergetDeserializer(
java.lang.StringmechType,
java.lang.Class_javaType,
javax.xml.namespace.QName_xmlType)
...{
return
neworg.apache.axis.encoding.ser.BeanDeserializer(
_javaType,_xmlType,typeDesc);
}


}

调用相应的Web服务。以下是一个调用航空售票流程的例子。

importjava.net.URL;
importjavax.xml.rpc.ParameterMode;
importorg.apache.axis.client.Call;
importorg.apache.axis.client.Service;
importcom.packtpub.service.airline.*;
importcom.packtpub.service.employee.*;
importjavax.xml.namespace.QName;
importorg.apache.axis.encoding.ser.BeanDeserializerFactory;
importorg.apache.axis.encoding.ser.BeanSerializerFactory;

publicclassAirLineUse...{


publicstaticvoidmain(Stringargs[])
...{
try
...{
AriLineUseclient
=newAriLineUse();
client.run();
}

catch(Exceptione)
...{
e.printStackTrace();
}

}


publicvoidrun()
throwsException
...{
//创建一个Call的实例,并配置相应的参数
Callcall=createCall();
try
...{
/**//*创建输入参数的实例,在本例中,调用的Operation是TravelApprovalPT(PortType)中的TravelApproval,输入的Massage是trv:TravelRequestMessage,输出的Message是aln:TravelResponseMessage(消息的定义参考相应的wsdl)*/

EmployeeTypeet
=newEmployeeType("d","dd","spk");
FlightRequestTypefrt
=newFlightRequestType("bj","sh",newjava.util.Date(),newjava.util.Date());
//调用web服务,并接受返回的数值
FlightConfirmationTypefct=(FlightConfirmationType)call.invoke(newObject[]...{et,frt});

System.out.println(
"HereistheresponsefromtheAirLine:");
System.out.println(
"FlightNo:"+fct.getFlightNo());
System.out.println(
"TravelClass:"+fct.getTravelClass());
System.out.println(
"Price:"+fct.getPrice());
System.out.println(
"DepartureDateTime:"+fct.getDepartureDateTime().getTime().toString());
System.out.println(
"ReturnDateTime:"+fct.getReturnDateTime().getTime().toString());
System.out.println(
"Approved:"+(fct.isApproved()==true?"yes":"no"));
}

catch(Exceptione)
...{
System.out.println(
"unexpectedexceptionseen:"+e.toString());

}

}



//创建一个Call的实例用于调用相应的web服务
protectedCallcreateCall()
throwsException
...{
Serviceservice
=newService();
Callcall
=(Call)service.createCall();
//WebService的URL
StringurlString="http://localhost:8085/active-bpel/services/clientService";
call.setTargetEndpointAddress(
newURL(urlString));
//需要调用的PortType中的Operation
call.setOperationName("TravelApproval");
//为每个ComplexType定义相应的QualifiedName
QNameqq=newQName("http://packtpub.com/service/employee/","EmployeeType");
QNamefrt
=newQName("http://packtpub.com/service/airline/","FlightRequestType");
QNamefct
=newQName("http://packtpub.com/service/airline/","FlightConfirmationType");
//将定义的Type注册到call中,同时生成并注册构造器和反构造器。
call.registerTypeMapping(EmployeeType.class,qq,

newBeanSerializerFactory(EmployeeType.class,qq),

newBeanDeserializerFactory(EmployeeType.class,qq));

call.registerTypeMapping(FlightRequestType.
class,frt,

newBeanSerializerFactory(FlightRequestType.class,frt),

newBeanDeserializerFactory(FlightRequestType.class,frt));

call.registerTypeMapping(FlightConfirmationType.
class,fct,

newBeanSerializerFactory(FlightConfirmationType.class,fct),

newBeanDeserializerFactory(FlightConfirmationType.class,fct));

//设置参数类型和返回值类型
call.addParameter("employee",qq,ParameterMode.IN);
call.addParameter(
"flightData",frt,ParameterMode.IN);
call.setReturnType(fct);

returncall;
}


}

分享到:
评论

相关推荐

    BPEL实例教程代码

    BPEL实例教程代码

    在Eclipse下开发BPEL实例分享

    在Eclipse下开发BPEL实例分享

    Oracle SOA 套件——Oracle BPEL 流程管理器

    Oracle SOA 套件——Oracle BPEL 流程管理器Oracle SOA 套件——Oracle BPEL 流程管理器

    BPEL 实例教程

    BPEL 实例教程 BPEL 实例教程 BPEL 实例教程 BPEL 实例教程

    BPEL的一个运行实例

    3. 实例分析.......................................................................................................- 6- 3.1. 实例逻辑.......................................................................

    BPEL实例 eclipse apache ode

    BPEL实例,Apache-ODE,Eclipse 该教程详细讲述了开发一个BPEL业务...先手动写好两个服务,一个是加法服务,一个是减法服务,然后希望构建一个bpel流程,该流程能够根据用户的输入来决定是调用加法服务还是减法服务。

    BPEL实例开发详细教程-个人实践

    网上有不少BPEL的实例文档,其中最常用的就是加减法BPEL部署。但是有些细节可能未交待清楚,本人当时在实践的...包含WebService与BPEL开发的环境配置、实例开发与部署、实例运行与测试,对关键易错部分标红突出显示。

    bpel2.0实例(可以直接运行)

    这是bpel2.0实例,包含循环结构和判断结构,在tomcat5和axis2可以直接运行!

    BPEL实例教程

    BPEL 激发企业进一步定义它们的业务流程,从而导致业务流程的优化、重新设计以及选择最合适的流程,进而实现了组织的进一步优化。BPEL 中描述的业务流程定义并不影响现有系统,因此对升级产生了促进作用。在已经或...

    bpel完整实例(webservice+bpel)

    bpel完整实例(webservice+bpel) openesb bpel

    一起学BPEL实例教程

    资源包含一份关于BPEL开发实例的文档,以及开发中的代码。主要包含两个web服务的发布及使用。

    BPEL实例简明教程(20页)

    简单介绍了BPEL的基本构架。有一个实例。利用实例展开。很容易读懂。内容不多。

    BPEL整合WEBService服务的一个完整案例

    BPEL整合WEBService服务的一个完整案例

    BPEL流程编排发布实例

    初学BPEL的很好的代码指导教材,绝对值得下载学习。

    西工大服务计算实验四_BPEL服务组合

     客户端输入3个数字,BPEL流程接收请求,先调用加法Web服务,获得结果后,再将结果和第三个参数,作为减法Web的输入,调用减法Web服务,获得预期结果,并返回客户。  例如:输入:3,6.5,2 • 首先调用...

    一起学BPEL实例教程一(原创)

    在Eclipse环境下开发BPEL的详细教程,基本上是step by step。...3 BPEL的开发 详情见附件。希望大家一起学习,共同进步。 有分的就支持下,没分的就到http://zhongkem.javaeye.com/admin/blogs/691388下载吧~~

    bpel入门级实例

    去年写的一个小冬冬,把一个oracle的bpel实例改写后在activeBpel上运行,因为activeBpel是open的,可以研究引擎架构的实现。

Global site tag (gtag.js) - Google Analytics