on 2018 Oct 23 10:22 AM
Hi,
my scenario description:
1. make a sql call to b1 and retrieve a table object with multiple rows.
2. make an http call for each row
3. each http call connects with 3rd party API and sends 1 sms for each row.
To achieve this I make xsl:for-each to the rows and set <call></call> with appropriate properties inside.
The xml result seems ok as xml shows calls to each rows, but the problem is that I am receiving SMS for only first row.
So this seems like I can't make multiple http calls within xsl:for-each. How can I solve this problem?
form for calling http:
<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:b1e="urn:com.sap.b1i.sim:b1event" xmlns:b1ie="urn:com.sap.b1i.sim:b1ievent" xmlns:b1im="urn:com.sap.b1i.sim:b1imessage" xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" xmlns:jdbc="urn:com.sap.b1i.adapter:jdbcadapter" xmlns:js="com.sap.b1i.bpc_tools.Javascript" xmlns:rfc="urn:sap-com:document:sap:rfc:functions" xmlns:sim="urn:com.sap.b1i.sim:entity" xmlns:uplt="urn:com.sap.b1i.xcellerator:upltdoc" xmlns:utils2="com.sap.b1i.bpc_tools.Utilities" xmlns:vpf="urn:com.sap.b1i.vplatform:entity" xmlns:xci="urn:com.sap.b1i.xcellerator:intdoc" xmlns:xsl="http://www.w3.org/1999/XSL/Transform" version="1.0" bfa:force="" vpf:force="" jdbc:force="" rfc:force="" b1ie:force="" b1e:force="" xci:force="" sim:force="" utils2:force="" b1im:force="" uplt:force="" js:force="">
<xsl:output method="xml" encoding="UTF-8" indent="yes"></xsl:output>
<xsl:param name="atom"></xsl:param>
<xsl:param name="sessionid"></xsl:param>
<xsl:variable name="msg" select="/vpf:Msg/vpf:Body/vpf:Payload[./@Role='C']"></xsl:variable>
<xsl:variable name="vpSender" select="/vpf:Msg/vpf:Header/vpf:Sender/@Id"></xsl:variable>
<xsl:variable name="vpObject" select="/vpf:Msg/vpf:Header/vpf:Sender/@ObjId"></xsl:variable>
<xsl:variable name="vpReceiver" select="/vpf:Msg/vpf:Header/vpf:ReceiverList/vpf:Receiver[./@handover='P']/@Id"></xsl:variable>
<xsl:template match="/">
<xsl:variable name="vptsDoc" select="document('/com.sap.b1i.internal/xml/timestamp')"></xsl:variable>
<xsl:variable name="vpts" select="concat($vptsDoc/*/@year,'/',$vptsDoc/*/@month,'/',$vptsDoc/*/@date,' ',$vptsDoc/*/@hour,':',$vptsDoc/*/@minute,':',$vptsDoc/*/@second)"></xsl:variable>
<vpf:Msg>
<xsl:copy-of select="/vpf:Msg/@*"></xsl:copy-of>
<xsl:copy-of select="/vpf:Msg/vpf:Header"></xsl:copy-of>
<vpf:Body>
<xsl:copy-of select="/vpf:Msg/vpf:Body/*"></xsl:copy-of>
<vpf:Payload Role="X" id="{$atom}" ts="{$vpts}">
<xsl:call-template name="transform"></xsl:call-template>
</vpf:Payload>
</vpf:Body>
</vpf:Msg>
</xsl:template>
<xsl:template name="transform">
<xsl:for-each select="$msg/jdbc:ResultSet/jdbc:Row">
<xsl:variable name="CS" select="'CS=abcd'"></xsl:variable>
<xsl:variable name="US" select="'US=abcd'"></xsl:variable>
<xsl:variable name="PA" select="'PA=pass'"></xsl:variable>
<xsl:variable name="PH" select="'PH='"></xsl:variable>
<xsl:variable name="MS" select="'MS='"></xsl:variable>
<xsl:variable name="space" select="'%20'"></xsl:variable>
<xsl:variable name="Pnumber">
<xsl:value-of select="jdbc:U_Phone"></xsl:value-of>
</xsl:variable>
<xsl:variable name="cont">
<xsl:value-of select="$msg/jdbc:ResultSet/jdbc:Row/jdbc:U_Content"></xsl:value-of>
</xsl:variable>
<xsl:variable name="contentResult">
<xsl:call-template name="b1ilib.strgReplace">
<xsl:with-param name="subs" select="'%20'"></xsl:with-param>
<xsl:with-param name="var" select="' '"></xsl:with-param>
<xsl:with-param name="wstrg" select="$msg/jdbc:ResultSet/jdbc:Row/jdbc:U_Content"></xsl:with-param>
</xsl:call-template>
</xsl:variable>
<!--<xsl:variable name="conte"><xsl:param name="wstrg"></xsl:param></xsl:variable>-->
<call>
<!--<query id="identifier" value="value"></query>-->
<!--optional - define your own query parameters - multiple elements allowed-->
<connect>
<!--the connect section is optional - you can also define a reference to the sld-->
<destProtocol>http</destProtocol>
<destHost>tideplatformgate.com</destHost>
<destPort></destPort>
<destPath>/smssender</destPath>
<query>
<xsl:value-of select="concat($CS,'&',$US,'&',$PA,'&',$PH,$Pnumber,'&',$MS,$contentResult)"></xsl:value-of>
</query>
<proxyHost></proxyHost>
<proxyPort></proxyPort>
<method>get</method>
<authentification></authentification>
<user></user>
<password></password>
<user2query></user2query>
<password2query></password2query>
<trustStoreURI></trustStoreURI>
<keyStoreURI></keyStoreURI>
<tlsVersion></tlsVersion>
</connect>
<dtd>
<!--optional - document type definition-->
</dtd>
<pltype>
<!--optional - default is xml-->
</pltype>
<payload>
<!--optional - in case of POST request you specify here your request document-->
</payload>
<htta>
<par id="httpheader.???" value="">
<!--optional - you can specify here your own http header definitions - multiple elements allowed-->
</par>
<par id="htta.returnpltypeforce" value="">
<!--optional-->
</par>
<par id="htta.returnpltypedefault" value="">
<!--optional-->
</par>
</htta>
</call>
</xsl:for-each>
</xsl:template>
<xsl:include href="../../com.sap.b1i.system.lib/xsl/string.xsl"></xsl:include>
</xsl:stylesheet>
result after testing:
This XML file does not appear to have any style information associated with it. The document tree is shown below.
<Msg xmlns="urn:com.sap.b1i.vplatform:entity" MessageId="18102311150232943969C0A8987E8FB9" BeginTimeStamp="20181023111502" logmsg="0000" SubMessageId="" status="success" owntst="true" test="true">
<Header>
<IPO Id="vPlatform_Test"/>
<Sender Id="" ObjId="sup.SingleSendUpd"/>
<Receiver Id=""/>
<ReceiverList>
<Receiver Id="" handover="P"/>
</ReceiverList>
<Identification Ident="Void" IdPar="n.a."/>
<nsList/>
<vBIU Id="sup.SingleSendUpd" ver="1.0.0" SId="sup.TideIntervalTest" filter="" phase=""/>
<Variables>
<var id="userid" value=""/>
<var id="username" value=""/>
</Variables>
<Properties/>
<SysTypeProperties type="B1if" offline="" snd="senderdummy" rcv="receiverdummy" ssystype="" rsystype=""/>
<LocalProperties type="B1if" biu="sup.SingleSendUpd" snd="senderdummy" rcv="receiverdummy" sid="sup.TideIntervalTest" offline=""/>
<VarProperties/>
</Header>
<Body>
<Payload Role="T" Type="Call"/>
<Payload Role="S">*** no test message specified ***</Payload>
<Payload Role="C" id="atom1" system="0010000101" mode="single" method="Automatic detection by key word(Automatic detection by key word)" plr="4" dbtype="SQL" blockExecution="false" compatibilityMode="true" delimiter=";" commitMode="2PC" sql="SELECT * FROM SUP_v_OSMS" disable-output-escaping="false">
<ResultSet xmlns="urn:com.sap.b1i.adapter:jdbcadapter" rowCount="3">
<Row>
<DocEntry>1</DocEntry>
<U_Phone>123123123</U_Phone>
<U_Content>Test</U_Content>
<U_SndDate/>
<U_SndTime/>
<U_Status>N</U_Status>
</Row>
<Row>
<DocEntry>2</DocEntry>
<U_Phone>+123123123</U_Phone>
<U_Content>test2</U_Content>
<U_SndDate/>
<U_SndTime/>
<U_Status>N</U_Status>
</Row>
<Row>
<DocEntry>3</DocEntry>
<U_Phone>123123123</U_Phone>
<U_Content>test3</U_Content>
<U_SndDate/>
<U_SndTime/>
<U_Status>N</U_Status>
</Row>
</ResultSet>
</Payload>
<vpf:Payload xmlns:vpf="urn:com.sap.b1i.vplatform:entity" Role="X" id="atom3" ts="2018/10/23 11:15:02">
<call xmlns="">
<connect>
<destProtocol>http</destProtocol>
<destHost>tideplatformgate.com</destHost>
<destPort/>
<destPath>/smssender</destPath>
<query>
CS=1234&US=4312&PA=pass&PH=123123123&MS=Test
</query>
<proxyHost/>
<proxyPort/>
<method>get</method>
<authentification/>
<user/>
<password/>
<user2query/>
<password2query/>
<trustStoreURI/>
<keyStoreURI/>
<tlsVersion/>
</connect>
<dtd/>
<pltype/>
<payload/>
<htta>
<par id="httpheader.???" value=""/>
<par id="htta.returnpltypeforce" value=""/>
<par id="htta.returnpltypedefault" value=""/>
</htta>
</call>
<call xmlns="">
<connect>
<destProtocol>http</destProtocol>
<destHost>tideplatformgate.com</destHost>
<destPort/>
<destPath>/smssender</destPath>
<query>
CS=1231&US=1231&PA=pass&PH=123123123&MS=test2
</query>
<proxyHost/>
<proxyPort/>
<method>get</method>
<authentification/>
<user/>
<password/>
<user2query/>
<password2query/>
<trustStoreURI/>
<keyStoreURI/>
<tlsVersion/>
</connect>
<dtd/>
<pltype/>
<payload/>
<htta>
<par id="httpheader.???" value=""/>
<par id="htta.returnpltypeforce" value=""/>
<par id="htta.returnpltypedefault" value=""/>
</htta>
</call>
<call xmlns="">
<connect>
<destProtocol>http</destProtocol>
<destHost>tideplatformgate.com</destHost>
<destPort/>
<destPath>/smssender</destPath>
<query>
CS=1231&US=1231&PA=pass&PH=123123123&MS=test3
</query>
<proxyHost/>
<proxyPort/>
<method>get</method>
<authentification/>
<user/>
<password/>
<user2query/>
<password2query/>
<trustStoreURI/>
<keyStoreURI/>
<tlsVersion/>
</connect>
<dtd/>
<pltype/>
<payload/>
<htta>
<par id="httpheader.???" value=""/>
<par id="htta.returnpltypeforce" value=""/>
<par id="htta.returnpltypedefault" value=""/>
</htta>
</call>
</vpf:Payload>
<Payload Role="C" id="atom2" statusNo="0" statusMsg="success" reference="atom3" sysid="" payload="atom3" throwException="false">
<http.header>
<http.header.info id="Server" value="Microsoft-IIS/7.5"/>
<http.header.info id="Cache-Control" value="private"/>
<http.header.info id="X-AspNet-Version" value="4.0.30319"/>
<http.header.info id="Set-Cookie" value="ASP.NET_SessionId=ymibcg5k12iechlqbgdpaum4; path=/; HttpOnly"/>
<http.header.info id="Content-Length" value="43"/>
<http.header.info id="Date" value="Tue, 23 Oct 2018 09:15:03 GMT"/>
<http.header.info id="X-Powered-By" value="ASP.NET"/>
<http.header.info id="Content-Type" value="text/html; charset=utf-8"/>
</http.header>
<bfa:io xmlns:bfa="urn:com.sap.b1i.bizprocessor:bizatoms" pltype="htm">Error: 0<BR>Suspension: 1<BR>ID: 1572751667</bfa:io>
</Payload>
</Body>
</Msg>
as you can see the http calls are set for each row correctly. But In reality only first http call is made. How do I solve this?
Request clarification before answering.
Hi there,
I don't think that you can pass multiple call objects to one HTTP Call atom. You can use graphical for-each atom instead to achieve your goal. Just split the result by your for-each statement and place the HTTP Call inside the for-each block.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks! That worked.
Now I have another problem. I need polish characters in side the <query></query> of http call. The result XML shows correctly, but when I receive SMS all the polish characters are broken. I have already set in SMS service providers api to use UTF-8, so maybe there's something I could do in integration framework to correct this?
User | Count |
---|---|
53 | |
8 | |
8 | |
5 | |
5 | |
4 | |
3 | |
2 | |
2 | |
2 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.