Camunda无法在Inline脚本中读取HTTP-Connector响应的XML

发布于 2025-01-29 04:33:27 字数 2419 浏览 3 评论 0原文

我正在尝试从HTTP响应中解析XML主体。

这是我想要的和我在做什么。

  1. 我制作了简单的BPMN文件,该文件是请求API并从API服务器中获取响应。

输出

  1. 我想解析由xml组成的响应和响应。 将$(xml(wendment)}放入输出值时,我可以看到所有XML数据。
<?xml version="1.0" encoding="UTF-8"?><deployment xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <deployment_details>
    <host_uuid>1963aa56409abe71d8c449d6e2adf3eb816e8ccf75838bfa664ef803</host_uuid>
    <host_name>my_hostname</host_name>
    <vm_uuid>02c644ed-1a92-4efb-b80b-f1abbf5ea3b6</vm_uuid>
    <generated_vm_name>esc-vnf-info-csr_csr-te_0_bf4121de-cd55-4b14-ad7a-6d4a3f572e02</generated_vm_name>
    <interfaces>
      <interface>
        <binding_profile/>
        <network_uuid>b76e4cd7-0d88-4889-b6fe-2430641c26cc</network_uuid>
        <gateway>172.18.21.254</gateway>
        <ip_address>172.18.21.132</ip_address>
        <mac_address>fa:16:3e:17:86:67</mac_address>
        <netmask>255.255.255.0</netmask>
        <nic_id>0</nic_id>
        <port_forwarding/>
        <port_uuid>6c38a416-48b6-45d2-b192-2fe9971c1ed2</port_uuid>
        <port_security_enabled>false</port_security_enabled>
        <security_groups/>
        <subnet_uuid>41330856-a0c9-4a04-be5b-b513c761da0e</subnet_uuid>
        <type>virtual</type>
        <vim_interface_name>esc-vnf-info-csr_csr-te_0_bf4121de-cd55-4b14-ad7a-6d4a3f572e02</vim_interface_name>
      </interface>
    </interfaces>
  </deployment_details>
  <deployment_name>info-csr-test</deployment_name>
</deployment>
  1. 最终目标是获取主机名 /部署/deployment_details/host_name 至于此,我将值按以下值进行
${XML(response).xPath("/deployment/deployment_details/host_name").element()}

了实例化定义ESC_API_TEST:12:782EB51A-D4EC-111EC-AB99-5AF27468B181:错误在评估表达式时发生错误:$ {xml(wespmence).xpath(XPath).xpath(“/exployment/exployment/deployment_detail_details/osthost host_name_name”)) 。元素()}。原因:org.camunda.spin.xml.spinxpathexception:spin/dom-xml-01035无法找到xpath expression'/exployment/deployment_details/host_name'[start-instance-error]

有人会帮助我的问题吗?

I'm trying to parsing xml body from http response.

Here is what I want and what I'm doing.

  1. I made simple bpmn file which is request api and get the response from api server.

output

  1. I want to parsing the response and response consist of xml.
    I can see the all xml data when I put the $(XML(response)} in output value.
<?xml version="1.0" encoding="UTF-8"?><deployment xmlns="urn:ietf:params:xml:ns:netconf:base:1.0">
  <deployment_details>
    <host_uuid>1963aa56409abe71d8c449d6e2adf3eb816e8ccf75838bfa664ef803</host_uuid>
    <host_name>my_hostname</host_name>
    <vm_uuid>02c644ed-1a92-4efb-b80b-f1abbf5ea3b6</vm_uuid>
    <generated_vm_name>esc-vnf-info-csr_csr-te_0_bf4121de-cd55-4b14-ad7a-6d4a3f572e02</generated_vm_name>
    <interfaces>
      <interface>
        <binding_profile/>
        <network_uuid>b76e4cd7-0d88-4889-b6fe-2430641c26cc</network_uuid>
        <gateway>172.18.21.254</gateway>
        <ip_address>172.18.21.132</ip_address>
        <mac_address>fa:16:3e:17:86:67</mac_address>
        <netmask>255.255.255.0</netmask>
        <nic_id>0</nic_id>
        <port_forwarding/>
        <port_uuid>6c38a416-48b6-45d2-b192-2fe9971c1ed2</port_uuid>
        <port_security_enabled>false</port_security_enabled>
        <security_groups/>
        <subnet_uuid>41330856-a0c9-4a04-be5b-b513c761da0e</subnet_uuid>
        <type>virtual</type>
        <vim_interface_name>esc-vnf-info-csr_csr-te_0_bf4121de-cd55-4b14-ad7a-6d4a3f572e02</vim_interface_name>
      </interface>
    </interfaces>
  </deployment_details>
  <deployment_name>info-csr-test</deployment_name>
</deployment>
  1. final goal is to get the hostname
    /deployment/deployment_details/host_name
    As for this I put the value as below
${XML(response).xPath("/deployment/deployment_details/host_name").element()}

Cannot instantiate process definition esc_api_test:12:782eb51a-d4ec-11ec-ab99-5af27468b181: Error while evaluating expression: ${XML(response).xPath("/deployment/deployment_details/host_name").element()}. Cause: org.camunda.spin.xml.SpinXPathException: SPIN/DOM-XML-01035 Unable to find XPath expression '/deployment/deployment_details/host_name' [ start-instance-error ]

Does someone help my issue?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

你的背包 2025-02-05 04:33:27

我找到了以下代码获得值的其他方法。
XPath不起作用,但子元素运转良好。
美元

I found other way to get the value as below code.
xPath is not working but childElement is working well.
${XML(response).childElement("deployment_details").childElement("host_name").textContent()}

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文