How Do I Consume a Web Service using Apache Axis2? (Magic xpa 4.x)
You can consume web services using Apache Axis2 by following these steps:
-
Select CRR from the Project menu.
-
Open a new line (F4).
-
From the Type column, select Apache Axis2.
-
Zoom (F5).
-
If a component was not selected, the Apache Axis2 Component box opens.
-
In this box, enter the service endpoint URL that the web services step calls. For example, http://www.dataaccess.com/webservicesserver/textcasing.wso?WSDL.
-
If a component was already loaded, its property sheet opens.
-
After you have defined the web service, you can use it in the same way you use any other Java component. For example,
o Define a Java alias in the CRR. TextCasingStub = com.dataaccess.www.webserviceserver.TextCasingStub
o Write a program as follows:
|
|
|
Object Type
|
Virtual
|
textCasingStub(A)
|
JAVA
|
TextCasingStub
|
Virtual
|
invertStringCaseRequest(B)
|
JAVA
|
TextCasingStub.InvertStringCase
|
Virtual
|
invertStringCaseResponse(C)
|
JAVA
|
TextCasingStub.InvertStringCaseResponse
|
Update
|
A
|
Java.TextCasingStub()
|
Update
|
B
|
Java.TextCasingStub.InvertStringCase()
|
Evaluate
|
|
B.setSAString('My String')
|
Update
|
C
|
A.invertStringCase(B)
|
Verify
|
Error
|
JavaException().toString() Cnd: JavaExceptionOccured()
|
Verify
|
|
C.getInvertStringCaseResult()
|
o After executing the program, you will see a message box with the result.
Note: The Magic xpa logic demonstrated above basically follows the logic of a native Java program.
import com.dataaccess.www.webservicesserver.TextCasingStub;
public class TestClient
{
public static void main(String[] args) throws Exception
{
try
{
TextCasingStub textCasingStub=new TextCasingStub();
TextCasingStub.InvertStringCase invertStringCaseRequest = new TextCasingStub.InvertStringCase();
invertStringCaseRequest.setSAString("My String");
TextCasingStub.InvertStringCaseResponse invertStringCaseResponse = textCasingStub.invertStringCase(invertStringCaseRequest);
System.out.println(String.format("Response: %s", invertStringCaseResponse.getInvertStringResult()));
}
catch (Exception ex)
{
system.out.println(ex);
}
}
}
|
How Do I Consume a WCF Web Service?