Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Xml Talend-检查tEsbConsumer Soap响应和同名的计数字段_Xml_Soap_Talend - Fatal编程技术网

Xml Talend-检查tEsbConsumer Soap响应和同名的计数字段

Xml Talend-检查tEsbConsumer Soap响应和同名的计数字段,xml,soap,talend,Xml,Soap,Talend,我试图检查tEsbConsumer活动的响应是否包含多个具有特定名称的标记。假设响应如下所示: <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"> <soapenv:Body&

我试图检查tEsbConsumer活动的响应是否包含多个具有特定名称的标记。假设响应如下所示:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <ns1:CustomerSearchResponse xmlns="http://test.com/CustomerSearchResponse/" xmlns:ns1="http://test.com/CustomerSearchResponse/">
         <ns1:Success>
            <ns1:Customers>
               <ns1:Customer>
                  <ns1:CustomerId>12</ns1:CustomerId>
                  <ns1:Surname>Sur1</ns1:Surname>
               </ns1:Customer>
               <ns1:Customer>
                  <ns1:CustomerId>34</ns1:CustomerId>
                  <ns1:Surname>Sur2</ns1:Surname>
               </ns1:Customer>
            </ns1:Customers>
         </ns1:Success>
      </ns1:CustomerSearchResponse>
   </soapenv:Body>
</soapenv:Envelope>

12
Sur1
34
Sur2
TalendESB中的代码如下所示:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Body>
      <ns1:CustomerSearchResponse xmlns="http://test.com/CustomerSearchResponse/" xmlns:ns1="http://test.com/CustomerSearchResponse/">
         <ns1:Success>
            <ns1:Customers>
               <ns1:Customer>
                  <ns1:CustomerId>12</ns1:CustomerId>
                  <ns1:Surname>Sur1</ns1:Surname>
               </ns1:Customer>
               <ns1:Customer>
                  <ns1:CustomerId>34</ns1:CustomerId>
                  <ns1:Surname>Sur2</ns1:Surname>
               </ns1:Customer>
            </ns1:Customers>
         </ns1:Success>
      </ns1:CustomerSearchResponse>
   </soapenv:Body>
</soapenv:Envelope>

根据返回的客户数量,我想将消息重定向到不同的行。带有count()变量的附加变量对我来说也可以。txmlmap中的XPath不起作用,tXSLT transformer需要在输入时有一个文件,tExtractXMLField不起作用:


有人知道怎么做吗?

您可以使用DOM解析器计算标记上的数字。您可以在tJavaRow中执行此操作,并根据数字提前传递上下文。@Vish如果我想使用tJavaRow,我应该如何从输入行解析文档类型?类似的东西不起作用:
InputSource is=new InputSource();is.setCharacterStream(新的StringReader(input_row.payload));DocumentBuilderFactory dbFactory=DocumentBuilderFactory.newInstance();DocumentBuilder dBuilder=dbFactory.newDocumentBuilder();Document doc=dBuilder.parse(is);doc.getDocumentElement().normalize();字符串tt=doc.getElementsByTagName(“itemIdentifier”).item(0.getTextContent();System.out.println(“根元素:+tt”)