beautypg.com

Modifying the class file of the client – HP Integrity NonStop H-Series User Manual

Page 212

background image

Figure 9-10 New Java Package Dialog Box

4.

Click

Finish

.

The class files under the Java package are created.

Modifying the Class File of the Client

To modify the newly created

TemperatureConverterClient.java class

file, complete

the following steps:

1.

Create an instance of the

ServiceClient

under the

main()

method.

ServiceClient client = new ServiceClient();

2.

Create the following two

OMElement

methods for payload (request SOAP body or the

message) under the

main()

method:

createPayLoad1()

: For converting Celsius to Fahrenheit

createPayLoad2()

: For converting Fahrenheit to Celsius

NOTE:

OMElement

is the Axis2/Java representation of XML.

The following code creates the above-mentioned

OMElement

methods.

public static OMElement createPayLoad1() {
OMFactory fac = OMAbstractFactory.getOMFactory();
OMNamespace omNs = fac.createOMNamespace("http://ws.apache.org/axis2",
"axis2");
OMElement method = fac.createOMElement("c2fConversion", omNs);
OMElement element = fac.createOMElement("value", omNs);
element.setText("4");
method.addChild(element);
return method;
}

public static OMElement createPayLoad2() {
OMFactory fac = OMAbstractFactory.getOMFactory();

212

Getting Started with Axis2/Java

This manual is related to the following products: