IBM Rational Business Developer (RBD) version 9.7 introduced a powerful new service library function—getRestResponseHeaders which enhances the capabilities of EGL (Enterprise Generation Language) Java clients when interacting with RESTful services.
The getRestResponseHeaders function allows developers to retrieve the HTTP response headers from a variable used to access a REST service. This function is particularly useful when you need to inspect metadata such as content type or custom headers returned by the service.
Syntax:
serviceLib.getRestResponseHeaders(variable Service | Interface in) returns (headers Dictionary)
variable: A variable based on a Service or Interface part that is used to access the REST service.
headers: A dictionary where each entry's key is the name of an HTTP header, and the corresponding value is the header's value
This blog explains how the EGL Java REST clients can see the HTTP response headers.
Java Client:
1. Create General project.
a. Go to File and Navigate to NewàEGL Project.

b. Provide the Project name (GeoName) and select General Project under the EGL project types.

c. Click Next.
d. Select Java under the Target runtime platform and Create a build descriptor under Build descriptor options.

e. Click Finish.
f. The General project under Project Explorer has been created successfully.

2. Create a Record:
a. Go to File and navigate to NewàRecord.

b. A New EGL Record window will appear.
c. Provide the Package name and EGL source file name.

d. Click Next.
e. Select Basic from the Templates and click Finish.

f. Record created and opened in EGL editor

Copy and paste the code below from here to the above file.
MyRecord.egl
package records;
Record MyRecord
name string;
age int;
count int;
end
3. Create an Interface:
a. Right-click the project GeoName and navigate to NewàInterface.

b. A New EGL Interface window will appear.
c. Provide the Package name and the EGL source file name.

d. Click Finish.
e. listname.egl interface created and opened in EGL editor.

Copy and paste the code below into the above file listname.egl file.
listname.egl
package interfaces;
import records.MyRecord;
interface listname
function searchJSON(query string in) returns(MyRecord){@GetRest{uriTemplate = "https://api.agify.io/?name={query}",
responseFormat = JSON}};
end
4. Creating a Program:
a. Go to File and navigate to NewàProgram.

b. A New EGL Program window will appear.
c. Provide the Package and EGL source file name.

d. Click Finish.
e. invokeservice.egl file created and opened in EGL editor.

Copy and paste the code below into the above invokeservice.egl file.
invokeservice.egl
package programs;
import interfaces.listname;
import records.MyRecord;
program invokeservice type BasicProgram{}
function main()
lname listname{@BindService{}};
query string = "meelad";
lname.searchJSON(query);
res dictionary = servicelib.getRestResponseHeaders(lname);
si int = res.size();
mykeys string[] = res.getKeys();
syslib.writeStdout("Number of Response header received"+" "+"="+" "+si);
for(i int from 1 to mykeys.getSize())
syslib.writestdout("entry " + mykeys[i] + " :: " +
res[mykeys[i]]);
end
end
end
5. Service Binding: Open deployment descriptor GeoName.egldd and open service binding tab
a. Go to the GeoName.egldd project under the EGL Source.

b. Go to the Service Bindings tab.
c. Click Add…
d. Add a Service Binding window will appear.
e. Select REST service binding option under Binding Types.

f. Click Next.
g. Click Browse and select listname.

h. Click Ok.
i. Click Finish.
6. Right-click on the general project (GeoName.egl).
7. Select Generate.

8. A Java program gets generated along with Interfaces and records.

9. Under the EGLGen/JavaSource right-click on invokeservice.java.
10. Select Run asàJava application.

11. Response headers will be displayed in the console.

Here, the Content-Type header tells the client the format of the returned data.
Content-Length indicates the size of the response body.
Response headers provide context, instructions, and additional information about the response itself, allowing clients to understand how to manage the returned data and resources.
Nandhini A
RBD QA Software Engineer.
Share the exciting news about the launch of IBM z17 with your network.
Step 1. Choose a sample message
⚡️IBM z17 is here! Powered by the new IBM Telum II processor, IBM z17 makes more possible, empowering organizations to drive innovation and do more with their data while processing sixty percent more transactions per day than IBM z16. See what sets IBM z17 apart here.
💻 Say hello to the new IBM z17. 👋 Bringing more AI to the core of business, IBM z17 helps organizations simplify compliance, improve productivity, and secure and use their most important data. Explore the z17 and its AI capabilities here.
🚀 Introducing IBM z17 - making more AI possible. With AI capabilities infused across hardware, software and systems, IBM z17 can drive business value by mitigating fraud risk, analyzing medical images, or even helping prevent retail crime – and that’s just the beginning. See how it can help your organization here.
📣I'm thrilled to introduce IBM z17! Here are three things that set the z17 apart ⤵️
1️⃣ IBM z17 is the modern mainframe engineered for the AI age, introducing multi-model AI capabilities along with new security features to protect data, and tools that leverage AI.
2️⃣ IBM z17 is fully designed for hybrid environments, enabling unmatched performance and reliability while changing how devs and systems operators engage with and manage IBM Z.
3️⃣ IBM z17 is built for the most important data, leveraging AI and the expanded Z Security and Compliance Center to simplify sensitive data tagging and access, crypto discovery and inventory and more.
Ready to do more? Get the details here.
Step 2. Add a hashtag
#IBMz #AI
Step 3. Use a social tile
