我正在尝试使用计算节点创建一个 xml 文件。我的要求是生成以下xml文档
<soapenv:Envelope>
<soapenv:Body>
<man:request domain="My-Dom">
<man:b2b-query-metadata>
<man:query>
<man:query-condition evaluation="property-greater-than">
<man:property-name>InputTime</man:property-name>
<man:value>2018-08-10 00:00:00</man:value>
</man:query-condition>
</man:query>
<man:result-constraints>
<man:sort-order>
<man:property-name direction="asc">InputTime</man:property-name>
</man:sort-order>
</man:result-constraints>
</man:b2b-query-metadata>
</man:request>
</soapenv:Body>
</soapenv:Envelope>
以下是用于生成所需 xml 文档的片段。
CREATE COMPUTE MODULE FLOW_Compute
CREATE FUNCTION Main() RETURNS BOOLEAN
BEGIN
CALL CopyMessageHeaders();
CALL CreateSOAPReq();
RETURN TRUE;
END;
CREATE PROCEDURE CopyMessageHeaders() BEGIN
DECLARE I INTEGER 1;
DECLARE J INTEGER;
SET J = CARDINALITY(InputRoot.*[]);
WHILE I < J DO
SET OutputRoot.*[I] = InputRoot.*[I];
SET I = I + 1;
END WHILE;
END;
CREATE PROCEDURE CreateSOAPReq() BEGIN
DECLARE soapenv NAMESPACE 'http://schemas.xmlsoap.org/soap/envelope/';
DECLARE man NAMESPACE 'http://www.datapower.com/schemas/management';
SET OutputRoot.HTTPRequestHeader.POST = 'https://my.testbox.com:5550/service/mgmt/3.0';
SET OutputRoot.HTTPRequestHeader."Content-Type" = 'text/xml;charset=UTF-8';
SET OutputRoot.HTTPRequestHeader."Authorization" = 'Basic '||base64Encode(CAST('myuserid:mypassword' as BLOB CCSID InputRoot.Properties.CodedCharSetId));
SET OutputRoot.HTTPRequestHeader.Host = 'my.testbox.com:5550';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.(XMLNSC.Attribute)man:domain = 'My-Dom';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:query.man:"query-condition".evaluation = 'property-greater-than';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:query.man:"query-condition".man:"property-name" = 'InputTime';
SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:query.man:"query-condition".man:value = '2018-08-10 00:00:00';
--SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.man:"b2b-query-metadata".man:"result-constraints".man:"sort-order".man:"property-name".(XMLNSC.Attribute)man:direction = 'asc';
END;
END MODULE;
更新:在成功清除我能够获得以下 xml 元素的障碍后:<man:request domain="My-Dom">
使用以下语句SET OutputRoot.XMLNSC.soapenv:Envelope.soapenv:Body.man:request.(XMLNSC.Attribute)man:domain = 'B2B-Dev';
,我对这部分感到震惊:<man:property-name direction="asc">InputTime</man:property-name>
我试图扫描我们outputroot
从头开始创建的示例,但是大多数示例都处理通过入站内容进行解析:
https://www.ibm.com/support/knowledgecenter/en/SSKM8N_8.0.0/com.ibm.etools。 mft.doc/ac67241_.htm
我知道我们有属性,需要为其分配元素值。我不确定如何处理这一点。有人可以指出一个涉及SET
esql 中的命令的示例。
欢迎任何建议。