Web services example
JCICS supports all API commands that are available for working with web services in an application.
| Methods | JCICS class | EXEC CICS commands |
|---|---|---|
| invoke() | WebService | INVOKE WEBSERVICE |
| create() | SoapFault | SOAPFAULT CREATE |
| addFaultString() | SoapFault | SOAPFAULT ADD FAULTSTRING |
| addSubCode() | SoapFault | SOAPFAULT ADD SUBCODESTR |
| delete() | SoapFault | SOAPFAULT DELETE |
| create() | WSAEpr | WSAEPR CREATE |
| delete() | WSAContext | WSACONTEXT DELETE |
| set*() | WSAContext | WSACONTEXT BUILD |
| get*() | WSAContext | WSACONTEXT GET |
The following example shows how you might use JCICS to create a web service request:
Channel requesterChannel = Task.getTask().createChannel("TestRequester");
Container appData = requesterChannel.createContainer("DFHWS-DATA");
byte[] exampleData = "ExampleData".getBytes();
appData.put(exampleData);
WebService requester = new WebService();
requester.setName("MyWebservice");
requester.invoke(requesterChannel, "myOperationName");
byte[] response = appData.get();
To handle the application data that is sent and received in a web service request, if you are working with structured data, you can use a tool such as IBM® Record Generator for Java™ to generate classes. See Interacting with structured data from Java. You can also use Java to generate and consume XML directly.