| 7905 |
manish.sha |
1 |
--------------------------------------------------------------------
|
|
|
2 |
Samples for calling FedEx Web Services (java)
|
|
|
3 |
--------------------------------------------------------------------
|
|
|
4 |
|
|
|
5 |
jdk 1.5 was used for testing.
|
|
|
6 |
|
|
|
7 |
When new wsdls are available, you will have to re-create the java files in the stub package for each sample project.
|
|
|
8 |
|
|
|
9 |
|
|
|
10 |
1. Download axis files (this is a one-time step)
|
|
|
11 |
----------------------------------------------------------------------
|
|
|
12 |
You will need to download Axis 1.4 components from www.apache.org at http://ws.apache.org/axis/
|
|
|
13 |
Download axis-bin-1_4.zip or axis-src-1_4.zip. Unzip it into any folder on your drive.
|
|
|
14 |
Add the following jar files from the "axis-1_4\lib" folder into your CLASSPATH
|
|
|
15 |
(for best results with your IDE, follow the one-time procedure shown right after the list of jar files below):
|
|
|
16 |
axis.jar,
|
|
|
17 |
axis-ant.jar,
|
|
|
18 |
commons-discovery-0.2.jar,
|
|
|
19 |
commons-logging-1.0.4.jar,
|
|
|
20 |
jaxrpc.jar,
|
|
|
21 |
log4j-1.2.8.jar,
|
|
|
22 |
saaj.jar,
|
|
|
23 |
wsdl4j-1.5.1.jar
|
|
|
24 |
The following files are not provided with axis but can be obtained from the web. Without these you may get some compilation warnings/errors.
|
|
|
25 |
It is more convenient if you also copy them into "axis-1_4\lib".
|
|
|
26 |
activation.jar,
|
|
|
27 |
mailapi.jar
|
|
|
28 |
|
|
|
29 |
|
|
|
30 |
2. Set CLASSPATH (this is a one-time step)
|
|
|
31 |
--------------------------------------------------------------------
|
|
|
32 |
On Eclipse-based IDEs, go to Window, Preferences, Java, Build Path,
|
|
|
33 |
Classpath variables, add "New" variable. Call this "AXIS_HOME",
|
|
|
34 |
and point it to where you unzipped axis components (the folder "axis-1_4", or similar if you use a different version).
|
|
|
35 |
|
|
|
36 |
(Doing this one-time procedure will automatically take care of classpath references for axis jars in each of the sample projects,
|
|
|
37 |
when you open each project as shown below).
|
|
|
38 |
|
|
|
39 |
|
|
|
40 |
3. How to make use of the sample projects
|
|
|
41 |
--------------------------------------------------------------------
|
|
|
42 |
|
|
|
43 |
For testing, you do not have to create a new project from scratch for any of the sample projects.
|
|
|
44 |
Each of the projects provided here has an associated ".project" file with it.
|
|
|
45 |
This can be used to directly import all existing project files into a new project on Eclipse-based IDEs.
|
|
|
46 |
In the IDE, click on File, Import, Existing projects into workspace. Select "Root Directory", then point to the folder containing a ".project" file.
|
|
|
47 |
The corresponding project name shows up. Select it and click OK. This will create the project in the IDE, with all required and referenced files.
|
|
|
48 |
|
|
|
49 |
|
|
|
50 |
4. How to re-create the java files in the "stub" package for each project
|
|
|
51 |
---------------------------------------------------------------------------------------------------------
|
|
|
52 |
WSDL2Java is contained in axis.jar. This is needed to (re)generate the files in the "stub" package - i.e. create java files from a wsdl.
|
|
|
53 |
This will be more convenient if you first add axis.jar to your system classpath.
|
|
|
54 |
|
|
|
55 |
*The following is a one-time step:*
|
|
|
56 |
On windows, go to control panel, system, advanced, environment variables, system variables, new -
|
|
|
57 |
create a variable called CLASSPATH and add "<full path>\axis.jar" to it.
|
|
|
58 |
If you had any command prompt open before doing this, you will have to close it and start a new one to be able to recognize the jar files mentioned above.
|
|
|
59 |
*End of one-time step*
|
|
|
60 |
|
|
|
61 |
Now, start a command prompt, and use the command:
|
|
|
62 |
java org.apache.axis.wsdl.WSDL2Java -w -p com.fedex.ship.stub <full_path>/myfile1.wsdl
|
|
|
63 |
|
|
|
64 |
example:
|
|
|
65 |
java org.apache.axis.wsdl.WSDL2Java -w -p com.fedex.ship.stub http://www.fedex.com/...../ShipService_v8.wsdl
|
|
|
66 |
depending on your environment, you may have to use a "?" instead of "." just before "wsdl"
|
|
|
67 |
see the command below:
|
|
|
68 |
java org.apache.axis.wsdl.WSDL2Java -w -p com.fedex.ship.stub http://www.fedex.com/...../ShipService?wsdl
|
|
|
69 |
or
|
|
|
70 |
java org.apache.axis.wsdl.WSDL2Java -w -p com.fedex.ship.stub C:\projects\wsdl\ShipService_v8.wsdl
|
|
|
71 |
or similar.
|
|
|
72 |
|
|
|
73 |
This will create all files in the stub package, and place them in the folder where you are running the command prompt.
|
|
|
74 |
You can then copy the newly created "com" folder and its contents into the appropriate sample project root directory.
|
|
|
75 |
----
|
|
|
76 |
Now, for each project, make sure there are no compile errors in the web service client main class, and run the project to get the desired output.
|
|
|
77 |
|
|
|
78 |
|
|
|
79 |
5. Date format
|
|
|
80 |
----------------
|
|
|
81 |
Axis 1.4 maps all xsd:dateTime WSDL/Schema types to Calendar class. The default serialized format of Calendar is:
|
|
|
82 |
|
|
|
83 |
"yyyy-MM-dd'T'HH:mm:ss.SSS'Z'"
|
|
|
84 |
|
|
|
85 |
Some web services may generate warning with the above format. To override this format each project has a client-config.wsdd file which defines custom type mapping for Calendar. Using this, the Axis client will serialize the Calendar objects in the following format:
|
|
|
86 |
|
|
|
87 |
"yyyy-MM-dd'T'HH:mm:ss.SSS(+|-)HH:mm"
|
|
|
88 |
|