Sunteți pe pagina 1din 21

Brighter, Bolder, Better

Amadeus Web Services


Implementation Guide
Java Axis1/2 Framework


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 2 of 21
Brighter, Bolder, Better


Index

1 Introduction .................................................................................................................. 4
2 SOAP Header versions ................................................................................................ 5
2.1 v1.0 and 1.1..................................................................................................... 5
2.2 v2.0.................................................................................................................. 5
3 Code Generation.......................................................................................................... 6
3.1 System Configuration....................................................................................... 6
3.2 Generation....................................................................................................... 7
4 Use of Session with header 1.0.................................................................................. 10
4.1 Axis 1............................................................................................................. 10
4.2 Axis 2............................................................................................................. 10
5 Use of Session with header 2.0.................................................................................. 11
5.1 Axis 1............................................................................................................. 11
5.2 Axis 2............................................................................................................. 11
6 Proxy use................................................................................................................... 13
6.1 Axis1 Generated Proxy Use (Eclipse Plug-in) ................................................ 13
6.2 Axis1 Generated Proxy Use (Command-Line)................................................ 16
6.3 Axis2 Generated Proxy Use (Command-Line)................................................ 16
6.4 Axis2 Generated Proxy Use (Eclipse Plug-in) ................................................ 18
7 Known Issues............................................................................................................. 19
7.1 Service Naming & Versioning Conventions .................................................... 19
7.2 Double Sequences (Axis1 only) ..................................................................... 19
7.3 Service calls never return (Axis1 only) ........................................................... 20
7.4 Eclipse Plugin - AxisFault at Generation Time................................................ 20
7.5 Time-Out Generating Java from WSDL.......................................................... 20
7.6 OutOfMemory Exception................................................................................ 21
7.7 Directory Structure Too Big............................................................................ 21


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 3 of 21
Brighter, Bolder, Better
Document control

Security level
Company Amadeus
Department API Consulting & Services
Author Cedric Counotte
Reviewed by Guillaume Cardon Date DD / MM / YYYY
Approved by Guillaume Cardon Date DD / MM / YYYY
Version Date Change Comment By
0.1 31 / 03 / 2009 Initial draft Cedric Counotte
0.2 11 / 06 / 2009 Updated Axis1 information Cedric Counotte
0.3 17 / 12 / 2009 New Axis1 known issues Cedric Counotte
0.4 15 / 04 / 2010 Updated SessionId know
issues
Olivier Bufalini
0.5 17 / 12 / 2010 Updated: use Session
element
Adrien Do Khac


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 4 of 21
Brighter, Bolder, Better

1 Introduction
This document describes implementation guidelines and known issues when using Java
Axis2 framework to access Amadeus Web Services.
Note that it is not recommended to use Axis 1 as it does not support every aspect of
Amadeus Web services out-of-the-box and code generation customization is very limited.


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 5 of 21
Brighter, Bolder, Better
2 SOAP Header versions
2.1 v1.0 and 1.1
- First version of header
- Management of session is done by a SessionID tag
- No WS-Addressing nor TFL
2.1.1 Representation:
This tag is described directly in the WSDL.
If not, please contact Implementation team to have it added (or migrate to header 2.0 or
superior)
2.2 v2.0
- Management of Session is done via a Session element
2.2.1 Representation
The Session element is described in the file WBS_Session-2.0.xsd that is part of the WSDL
.zip file.


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 6 of 21
Brighter, Bolder, Better
3 Code Generation
3.1 System Configuration
Axis1 or Axis2 must be installed (version 1.4 and 1.4.1 respectively tested). They can be
respectively downloaded here and here.
It is also recommended to install Java SDK (1.4 or above) as well as a Java IDE.
Java SDK can be download here and recommended free Java IDEs are:
Eclipse 3.4.2 (or superior)
o Axis2 plugin (optional).
NetBeans IDE 6.5 (best choice)
Once all software are installed it is important to add specific folders to the java class path and
to the system path, by getting Computer properties (right-click on Computer within Windows
Explorer), then click on Advanced tab and then Environment Variables:

Java class path:
JDK class folder (e.g. C:\Program Files\Java\jdk1.6.0_12\lib).
Axis1 class folder (e.g. C:\Program Files\java\axis1-1.4\lib).
Axis2 class folder (e.g. C:\Program Files\java\axis2-1.4.1\lib).
System path:
JDK bin folder (e.g. C:\Program Files\Java\jdk1.6.0_12\bin).
Axis2 bin folder (e.g. C:\Program Files\java\axis2-1.4.1\bin).
Special path:


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 7 of 21
Brighter, Bolder, Better
JAVA_HOME (e.g. C:\Program Files\Java\jdk1.6.0_12).
AXIS1_HOME (e.g. C:\Program Files\java\axis1-1.4).
AXIS2_HOME (e.g. C:\Program Files\java\axis2-1.4.1).
You may optionally install a web server if you want to create a web application project.
3.2 Generation
To generate an Axis2 proxy, one can either use the command-line or the integrated Eclipse
plugin. Note that NetBeans uses a different framework (Jax-WS or Jax-RPC).
3.2.1 Axis1 Command Line
The following command must be launched to generate a client proxy from a WSDL named
AmadeusWebService.wsdl. The WSDL file must be in the current directory along with all
XSD files.
axis_wsdl2java -o src-axis -a -W AmadeusWebServices.wsdl
The -a option tells the generator to generate all elements code (including the mandatory
Session element!).
The -W wraps the arguments of each service calls inside query/reply objects.
3.2.2 Axis2 Command Line
The following command must be launched to generate a client proxy from a WSDL named
AmadeusWebService.wsdl. The WSDL file must be in the current directory along with all
XSD files.
axis_wsdl2java -o src-axis -s -u --noBuildXML -ap -uri AmadeusWebServices.wsdl
The -s option tells the generator to generate synchroneous methods, you can also using -a to
generate asynchroneous methods if desired.
The -u option tells the generator to unpack the databinding classes, which is recommended
when many services are defined in the WSDL file, thus avoiding having one huge .java file.
The -noBuildXML avoids the generation of a build.xml file, but this actually depends on your
needs (whether you use ant to compile the project).
The -ap option allows generating code for all web service ports, but is optional.
3.2.3 Axis1/2 Eclipse Plugin
In eclipse, once you have created a Dynamic Web project, press Ctrl+N to get the New
Wizard dialog box.
Note that the plugin only supports Dynamic Web project and that the WSDL file and its
associated XSDs files must be located within the Eclipse workspace.
In this dialog box select the Web Service Client component and press Next as shown below:


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 8 of 21
Brighter, Bolder, Better

Browse to your downloaded and extracted WSDL package, then select Axis2 runtime (Axis1
is not recommended) and an installed web server if you want to deploy the client on the web.


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 9 of 21
Brighter, Bolder, Better

Press finish when done.


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 10 of 21
Brighter, Bolder, Better
4 Use of Session with header 1.0
4.1 Axis 1
As the SessionId is not sent via the methods parameters, it has to be manually added in the
header.
4.1.1 Creating or setting SessionId
SOAPHeaderElement header = new SOAPHeaderElement(
"http://xml.amadeus.com/WBS_Session_2.0", "SessionId");
header.setValue(sessionId);
proxy.setHeader(header);
4.1.2 Getting SessionId
SOAPHeaderElement sessionHeader = proxy.getResponseHeader(
http://webservices.amadeus.com/definitions, SessionId);
if(sessionHeader != null)
{
return sessionHeader.getValue();
}
4.2 Axis 2
4.2.1 Creating or setting SessionId
SessionId sessionId = new SessionId();
sessionId.setSessionId();
The sessionId is then sent as a parameter of the command.
4.2.2 Getting SessionId
String sessionId = proxy._getServiceClient().getLastOperationContext().
getMessageContext("In").getEnvelope().getHeader().
getFirstChildWithName(SessionId.MY_QNAME ).getText();


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 11 of 21
Brighter, Bolder, Better
5 Use of Session with header 2.0
5.1 Axis 1
As the SessionId is not sent via the methods parameters, it has to be manually added in the
header.
5.1.1 Creating Session element
SOAPHeaderElement header = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "Session");

SOAPHeaderElement sequenceNumberElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "SequenceNumber");
sequenceNumberElement.setValue(Integer.toString(
Integer.parseInt(sequenceNumber) + 1));
header.addChildElement(sequenceNumberElement);

SOAPHeaderElement securityTokenElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SecurityToken");
securityTokenElement.setValue(securityToken);
header.addChildElement(securityTokenElement);

SOAPHeaderElement sessionIdElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SessionId");
sessionIdElement.setValue(sessionId);
header.addChildElement(sessionIdElement);
5.1.2 Getting SessionId
SOAPHeaderElement she = proxy.getResponseHeader(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "Session");
String sessionId = ;
if (she != null)
{
SOAPHeaderElement sessionIdElement =
(SOAPHeaderElement)(she.getChildElements(new javax.xml.namespace.QName(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "SessionId"))
.next());
if(sessionIdElement != null)
{
sessionId = sessionIdElement.getValue();
}
}
Use similar code to set SequenceNumber and SecurityToken when needed
5.2 Axis 2
5.2.1 Creating Session
Session session = new Session();
SessionType sessionType = new SessionType();
sessionType.setSecurityToken("");
sessionType.setSequenceNumber("");
sessionType.setSessionID("");
session.setSession(sessionType);
The Session element is then sent as a parameter of the command.


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 12 of 21
Brighter, Bolder, Better
5.2.2 Getting and setting Session
The getting and setting are straight-forward as the session is a parameter of the command.


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 13 of 21
Brighter, Bolder, Better
6 Proxy use
6.1 Axis1 Generated Proxy Use (Eclipse Plug-in)
6.1.1 Security Authenticate
AmadeusWebServicesBindingStub proxy = GetProxy();

Security_AuthenticateUserIdentifier[] userIdentifier =
new Security_AuthenticateUserIdentifier[1];
userIdentifier[0] = new Security_AuthenticateUserIdentifier();

userIdentifier[0].setOriginator("WS1APOC");
userIdentifier[0].setOriginatorTypeCode("U");

Security_AuthenticateUserIdentifierOriginIdentification origin =
new Security_AuthenticateUserIdentifierOriginIdentification();
origin.setSourceOffice("NCEP02001");
userIdentifier[0].setOriginIdentification(origin);

Security_AuthenticateDutyCode dutyCode = new Security_AuthenticateDutyCode();
Security_AuthenticateDutyCodeDutyCodeDetails dutyCodeDetails =
new Security_AuthenticateDutyCodeDutyCodeDetails();
dutyCodeDetails.setReferenceQualifier("DUT");
dutyCodeDetails.setReferenceIdentifier("SU");
dutyCode.setDutyCodeDetails(dutyCodeDetails);

Security_AuthenticateSystemDetails systemDetails =
new Security_AuthenticateSystemDetails();
Security_AuthenticateSystemDetailsOrganizationDetails org_details =
new Security_AuthenticateSystemDetailsOrganizationDetails();
org_details.setOrganizationId("1A" );
systemDetails.setOrganizationDetails(org_details);

Security_AuthenticatePasswordInfo[] passwordInfo =
new Security_AuthenticatePasswordInfo[1];
passwordInfo[0] = new Security_AuthenticatePasswordInfo();
passwordInfo[0].setBinaryData("MnJPRWJyaSZXb1V0");
passwordInfo[0].setDataLength(new BigDecimal(12.0));
passwordInfo[0].setDataType("E");

try
{
Security_AuthenticateReplyProcessStatusHolder processStatus =
new Security_AuthenticateReplyProcessStatusHolder();
Security_AuthenticateReplyOrganizationInfoHolder organizationInfo =
new Security_AuthenticateReplyOrganizationInfoHolder();
Security_AuthenticateReplyErrorSectionHolder errorSection =
new Security_AuthenticateReplyErrorSectionHolder();
Security_AuthenticateReplyConversationGrpHolder conversationGrp =
new Security_AuthenticateReplyConversationGrpHolder();
proxy.security_Authenticate(null, userIdentifier, dutyCode, systemDetails,
passwordInfo, null, null, errorSection, processStatus,
organizationInfo, conversationGrp);

// Get session ID for SOAP header 1.0
SOAPHeaderElement she = proxy.getResponseHeader(
"http://webservices.amadeus.com/definitions", "SessionId");
String sessionId = ;
if(she != null)
{
sessionId = she.getValue();
}


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 14 of 21
Brighter, Bolder, Better
// ---------------------------------------

// Get session ID for SOAP header 2.0
SOAPHeaderElement she = proxy.getResponseHeader(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "Session");
String sessionId = "";
String sequenceNumber = "";
String securityToken = "";
if (she != null)
{
SOAPHeaderElement sessionIdElement =
(SOAPHeaderElement)(she.getChildElements(
new javax.xml.namespace.QName(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SessionId"))
.next());
if(sessionIdElement != null)
{
sessionId = sessionIdElement.getValue();
}

SOAPHeaderElement sequenceNumberElement =
(SOAPHeaderElement)(she.getChildElements(
new javax.xml.namespace.QName(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SequenceNumber"))
.next());
if(sequenceNumberElement != null)
{
sequenceNumber = sequenceNumberElement.getValue();
}

SOAPHeaderElement securityTokenElement =
(SOAPHeaderElement)(she.getChildElements(
new javax.xml.namespace.QName(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SecurityToken"))
.next());
if(securityTokenElement!= null)
{
securityToken = securityTokenElement.getValue();
}

}
// ---------------------------------------

}
catch(Exception e)
{
return "Cannot authenticate: " + e.getMessage();
}
6.1.2 Cryptic Command
AmadeusWebServicesBindingStub proxy = GetProxy();

Command_CrypticMessageAction messageAction = new Command_CrypticMessageAction();
Command_CrypticMessageActionMessageFunctionDetails messageFunctionDetails =
new Command_CrypticMessageActionMessageFunctionDetails();
messageFunctionDetails.setMessageFunction("M");
messageAction.setMessageFunctionDetails(messageFunctionDetails);

Command_CrypticLongTextString longTextString = new Command_CrypticLongTextString();
longTextString.setTextStringDetails("JD");

Command_CrypticReplyMessageActionDetailsHolder messageActionDetails =
new Command_CrypticReplyMessageActionDetailsHolder();
Command_CrypticReplyLongTextStringHolder longTextString2 =


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 15 of 21
Brighter, Bolder, Better
new Command_CrypticReplyLongTextStringHolder();

try
{
// Create session element for header 1.0
SOAPHeaderElement header = new SOAPHeaderElement(
"http://xml.amadeus.com/WBS_Session_2.0", "SessionId");
header.setValue(sessionId);
proxy.setHeader(header);
// ---------------------------------------

// Create session element for header 2.0
SOAPHeaderElement header = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "Session");

SOAPHeaderElement sequenceNumberElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "SequenceNumber");
sequenceNumberElement.setValue(Integer.toString(
Integer.parseInt(sequenceNumber) + 1));
header.addChildElement(sequenceNumberElement);

SOAPHeaderElement securityTokenElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SecurityToken");
securityTokenElement.setValue(securityToken);
header.addChildElement(securityTokenElement);

SOAPHeaderElement sessionIdElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SessionId");
sessionIdElement.setValue(sessionId);
header.addChildElement(sessionIdElement);
// ---------------------------------------


proxy.command_Cryptic(null, messageAction, null, null, longTextString,
messageActionDetails, longTextString2);
}
catch(Exception e)
{
return "Failed to issue cryptic command: " + e.getMessage();
}

// Retrieve response!
//

return longTextString2.value.getTextStringDetails();
6.1.3 Security SignOut
AmadeusWebServicesBindingStub proxy = GetProxy();

try
{
Security_SignOutReplyErrorSectionHolder errorSection =
new Security_SignOutReplyErrorSectionHolder();
Security_SignOutReplyProcessStatusHolder processStatus =
new Security_SignOutReplyProcessStatusHolder();

// Create session element for header 1.0
SOAPHeaderElement header = new SOAPHeaderElement(
"http://xml.amadeus.com/WBS_Session_2.0", "SessionId");
header.setValue(sessionId);
proxy.setHeader(header);
// ---------------------------------------

// Create session element for header 2.0
SOAPHeaderElement header = new SOAPHeaderElement(


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 16 of 21
Brighter, Bolder, Better
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "Session");

SOAPHeaderElement sequenceNumberElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd", "SequenceNumber");
sequenceNumberElement.setValue(Integer.toString(
Integer.parseInt(sequenceNumber) + 1));
header.addChildElement(sequenceNumberElement);

SOAPHeaderElement securityTokenElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SecurityToken");
securityTokenElement.setValue(securityToken);
header.addChildElement(securityTokenElement);

SOAPHeaderElement sessionIdElement = new SOAPHeaderElement(
"http://xml.amadeus.com/ws/2009/01/WBS_Session-2.0.xsd",
"SessionId");
sessionIdElement.setValue(sessionId);
header.addChildElement(sessionIdElement);
// ---------------------------------------


proxy.security_SignOut(null, errorSection, processStatus);
}
catch(Exception e)
{
return "Failed to sign-out: " + e.getMessage();
}

return "";


6.2 Axis1 Generated Proxy Use (Command-Line)
Code generated using the command-line and its options as described in previous chapter will
result in a slightly different code, in that the sessionID element will have a matching class
generated and all paremeters (for the query and reply contents) are encapsulated in
query/response classes.
6.3 Axis2 Generated Proxy Use (Command-Line)
6.3.1 Security Authenticate
UserIdentifier_type0[] userIdentifier = new UserIdentifier_type0[1];
userIdentifier[0] = new UserIdentifier_type0();

Originator_type1 originator = new Originator_type1();
originator.setOriginator_type0("WS1APOC");
userIdentifier[0].setOriginator(originator);

OriginatorTypeCode_type1 type_code = new OriginatorTypeCode_type1();
type_code.setOriginatorTypeCode_type0("U");
userIdentifier[0].setOriginatorTypeCode(type_code);

OriginIdentification_type0 origin = new OriginIdentification_type0();
SourceOffice_type1 office = new SourceOffice_type1();
office.setSourceOffice_type0("NCEP02001");
origin.setSourceOffice(office );
userIdentifier[0].setOriginIdentification(origin);

DutyCode_type0 dutyCode = new DutyCode_type0();
DutyCodeDetails_type0 dutyCodeDetails = new DutyCodeDetails_type0();


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 17 of 21
Brighter, Bolder, Better

ReferenceQualifier_type1 qualifier = new ReferenceQualifier_type1();
qualifier.setReferenceQualifier_type0("DUT");
dutyCodeDetails.setReferenceQualifier(qualifier);

ReferenceIdentifier_type1 identifier = new ReferenceIdentifier_type1();
identifier.setReferenceIdentifier_type0("SU");
dutyCodeDetails.setReferenceIdentifier(identifier);
dutyCode.setDutyCodeDetails(dutyCodeDetails);

SystemDetails_type0 systemDetails = new SystemDetails_type0();

OrganizationDetails_type0 org_details = new OrganizationDetails_type0();
OrganizationId_type1 orgId = new OrganizationId_type1();
orgId.setOrganizationId_type0("1A");
org_details.setOrganizationId(orgId );
systemDetails.setOrganizationDetails(org_details);

PasswordInfo_type0[] passwordInfo = new PasswordInfo_type0[1];
passwordInfo[0] = new PasswordInfo_type0();
BinaryData_type1 binaryData = new BinaryData_type1();
binaryData.setBinaryData_type0("MnJPRWJyaSZXb1V0");
passwordInfo[0].setBinaryData(binaryData);
DataLength_type1 dataLength = new DataLength_type1();
BigInteger bi = new BigInteger("12");
dataLength.setDataLength_type0(bi);
passwordInfo[0].setDataLength(dataLength);
DataType_type1 dataType = new DataType_type1();
dataType.setDataType_type0("E");
passwordInfo[0].setDataType(dataType);

Security_Authenticate authenticate_request = new Security_Authenticate();
authenticate_request.setDutyCode(dutyCode);
authenticate_request.setSystemDetails(systemDetails);
authenticate_request.setPasswordInfo(passwordInfo);
authenticate_request.setUserIdentifier(userIdentifier);

// Create Session element for header 2.0
Session session = new Session();
SessionType sessionType = new SessionType();
sessionType.setSecurityToken("");
sessionType.setSequenceNumber ("");
sessionType.setSessionId"");
session.setSession(sessionType);

Security_AuthenticateReply authReply =
proxy.Security_Authenticate(authenticate_request, session);
// Get Session values
String sessionId = session.getSession().getSessionId();
String sequenceNumber = session.getSession().getSequenceNumber();
String securityToken = session.getSession().getSecurityToken();

6.3.2 Cryptic Command
MessageAction_type0 messageAction = new MessageAction_type0();
MessageFunctionDetails_type0 messageFunctionDetails =
new MessageFunctionDetails_type0();
MessageFunction_type1 function = new MessageFunction_type1();
function.setMessageFunction_type0("M");
messageFunctionDetails.setMessageFunction(function);
messageAction.setMessageFunctionDetails(messageFunctionDetails);

LongTextString_type0 longTextString = new LongTextString_type0();
TextStringDetails_type1 details = new TextStringDetails_type1();
details.setTextStringDetails_type0("JD");
longTextString.setTextStringDetails(details );


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 18 of 21
Brighter, Bolder, Better
Command_Cryptic cryptic_query = new Command_Cryptic();
cryptic_query.setLongTextString(longTextString);
cryptic_query.setMessageAction(messageAction);

Command_CrypticReply cryptic_reply = null;

// Increment sequence number (header 2.0)
int sequenceNumber = Integer.parseInt(session.getSession().getSequenceNumber());
sequenceNumber++;
session.getSession().setSequenceNumber(Integer.toString(sequenceNumber));

cryptic_reply = proxy.Command_Cryptic(cryptic_query, session);

// Get cryptic response
//
String jdresult = cryptic_reply.getLongTextString().
getTextStringDetails().getTextStringDetails_type2();
6.3.3 Security SignOut
Security_SignOut security_SignOut1 = new Security_SignOut();

// Increment sequence number (header 2.0)
int sequenceNumber = Integer.parseInt(session.getSession().getSequenceNumber());
sequenceNumber++;
session.getSession().setSequenceNumber(Integer.toString(sequenceNumber));

proxy.Security_SignOut(security_SignOut1, session);
6.4 Axis2 Generated Proxy Use (Eclipse Plug-in)
The actual code to use a generated Axis2 proxy using Eclipse plug-in is the same as when
generating the Axis2 proxy from the command-line.
The only difference is the potential use of options. Noticeably the -u which unpacks the class
definitions to multiple files and packages.
Thus the command-line generation using -u is only different in the way proxy class definitions
are imported.


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 19 of 21
Brighter, Bolder, Better
7 Known Issues
7.1 Service Naming & Versioning Conventions
When using Axis2 code generator, an issue may occur when loading WSDL containing
duplicate service names, even though they refer to different versions of the service.
For that matter it is necessary to change the service names when duplicate entries are found
(e.g. PNR_AddMultiElements, PNR_Retrieve and PNR_Cancel).
For example, concerning PNR_AddMultiElements:
<wsdl:operation name="PNR_AddMultiElements62">
<wsdl:input message="aws:PNR_AddMultiElements_6_2"/>
<wsdl:output message="aws:PNR_Reply_6_2"/>
</wsdl:operation>
<wsdl:operation name="PNR_AddMultiElements">
<wsdl:input message="aws:PNR_AddMultiElements_7_3"/>
<wsdl:output message="aws:PNR_Reply_7_3"/>
</wsdl:operation>
...
<wsdl:operation name="PNR_AddMultiElements62">
<soap:operation soapAction=""/>

</wsdl:operation>
7.2 Double Sequences (Axis1 only)
You may get this error message at run-time:
- Could not convert [
It appears that the code generator for Axis1 performs auto-optimization on code generation
for the following types of WSDL fragment (a sequence containing a single sequence):
<xs:element name="name1" >
<xs:complexType>
<xs:sequence>

<xs:element name="name2" >
<xs:sequence>

</xs:sequence>
</xs:element>

</xs:sequence>
</xs:complexType>
</xs:element>
It results in a two dimensional table (definition [] []) instead of a one dimensional table
containing one single element. To solve this issue, an optional dummy element should be
added to the top sequence:
<xs:element name="name2" />
<xs:element name="Dummy.Axis1" minOccurs="0" maxOccurs="0"/>


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 20 of 21
Brighter, Bolder, Better
To ensure you have generated the code properly, make sure you cant find any [][] inside
your project directory.
7.3 Service calls never return (Axis1 only)
Whenever a service is called (Security_Authenticate for example), the response is received
on the TCP link but never managed properly, and the call ends-up with a time-out.
You must add the following configuration file (named client-config.wsdd) to the root of your
project:
<?xml version="1.0" encoding="UTF-8"?>
<deployment
name="commonsHTTPConfig"
xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">

<!-- use CommonsHTTPSender instead of the default HTTPSender -->
<transport name ="http"
pivot ="java:org.apache.axis.transport.http.CommonsHTTPSender" />
<transport name ="local"
pivot ="java:org.apache.axis.transport.local.LocalSender" />
<transport name ="java"
pivot ="java:org.apache.axis.transport.java.JavaSender"/>
</deployment>
As an alternative you can add the following piece of code:
EngineConfiguration engine =
EngineConfigurationFactoryFinder.newFactory().getClientEngineConfig();
SimpleProvider provider = new SimpleProvider(engine);
provider.deployTransport("http", new CommonsHTTPSender());

AmadeusWebServicesBindingStub stub = (AmadeusWebServicesBindingStub)
new AmadeusWebServicesLocator(provider).getAmadeusWebServicesPort();
7.4 Eclipse Plugin - AxisFault at Generation Time
You may get the below error message when trying to generate your proxy with Axis2. If this
is the case, you most certainly have already generated one, and the plugin does not accept
automatic overwritting Just remove previous proxy generation and retry.

7.5 Time-Out Generating Java from WSDL
When creating the Web Service Client java code from a WSDL, it may happen that Eclipse
fails with an emitter timed-out, even though the WSDL is a local file.
To solve this issue, developers should increase emitter time-out or disable it with a time-out
of -1, as follows in the Eclipse preferences:


2
0
1
1

A
m
a
d
e
u
s

I
T

G
r
o
u
p

S
A


Java Axis1/2 Framework





DEV/AIR/CMD/DSP/WBS
Last update: 05/04/2011
Page 21 of 21
Brighter, Bolder, Better

7.6 OutOfMemory Exception
When using Axis2 WSDL2Java from a command line, you might get a TargetInvocation and
an OutOfMemory exception. If so, you must change JVM settings to add specific option -
Xmx128M (using environment variable JAVA_OPTS).
Once java code has been generated using Axis2 plugin, Eclipse might show an out of
memory exception, because the generated .java file is too large (can be larger than 300Mb).
There is no solution has of today, except to either use a different framework or not use the
default data binding (ADB). Developers requiring this library should look to increase heap
space in Eclipse.
In this case, you should use the wsdl2java command line using the -u (unpack) option. This
will create multiple folders instead of having all generated code in one file.
Note that this type of exception only occurs when the WSDL file has too many services
defined. Another work-around can be to split the list of services into different WSDL files.
7.7 Directory Structure Too Big
If you use the xmlBeans data binding, you will not get out of memory issues, but the code
generator might create a directory structure far too deep causing issues, mostly when not
supported by OS.

S-ar putea să vă placă și