How to access custom headers with camunda modeler java?

I have a serviceTask that has such extension element.
<bpmn:serviceTask id=“collect-money” name=“Collect Money”>
bpmn:extensionElements
<zeebe:taskDefinition type=“payment-service” retries=“5” />
zeebe:taskHeaders
<zeebe:header key=“method” value=“VISA” />
</zeebe:taskHeaders>
</bpmn:extensionElements>
</bpmn:serviceTask>
I want to retrieve the taskHeaders or sub elements such as “method” name in <zeebe:header key=“method” value=“VISA” /> or all keys and so on.
Thanks.

Hey @hamidreza_abroshan,
if you have access to the BPMN file you can fetch and read these properties. For instance before deploying it to the engine.

Below I have attached an example written in Java.
First of all you need to read the BPMN file:

BpmnModelInstance bpmnModelInstance = Bpmn.readModelFromStream(this.getClass().getResourceAsStream("/test.bpmn"));

Afterwards you can then access and BPMNModelInstance and get model elements by a certain type.

Hopefully this already helps you to get started!
Best,
Thomas

Thanks,
I want to access headers within the extension elements.
I know how to get extension elements and how to list or query them, but my problem is accessing headers in my examples.
<bpmn:extensionElements
<zeebe:taskDefinition type=“payment-service” retries=“5” />
zeebe:taskHeaders
<zeebe:header key=“method” value=“VISA” />
</zeebe:taskHeaders>
</bpmn:extensionElements>

For instance, <zeebe:header key=“method” value=“VISA” />
I want to access key and value of this header element and I can not found any header class I think it’s a custom element for zeebe.
Look at this example in camunda docs
It has some custom headers and I want to access them.
Thanks.

Hi again,
I also posted my question on stackoverflow with a full code example and you can check that here.
https://stackoverflow.com/questions/74598206/how-to-access-custom-bpmn-extension-elements-with-camunda-java-modeler-api
Best.