I have created a REST API that receives a HTTP POST request(array of json requests) from UI. This would trigger a Xquery code which would spawn the requests to execute some functionalities and it may 10-30 mins to get completed. The max request count is 1000.
Please find the outline of the code below
declare function local:upload-record($req-xml, $chunk-size,$upload-uri){
if (exists($req-xml))
then (
let $log := xdmp:log("Upload started")
let $req-count := fn:count($req-xml)
let $response :=
(for $req in $req-xml[1 to $chunk-size]
let $user-name := $req/createdBy/text()
let $fetch-url := fn:concat("http://",$get-host:host,":{port}/fetchRecord)
let $auto-fetch := doc-lib:fetch-record($fetch-url)
let $doc-id := $auto-fetch[2]/envelope/doc-id/text()
let $auto-save := doc-lib:save-record($req,$doc-id)
let $publish-url := fn:concat("http://",$get-host:host,":{port}/publishRecord")
let $auto-publish := doc-lib:publish-record($publish-url,$doc-id,$user-name)
return $auto-publish
,
xdmp:spawn-function(function(){
local:upload-record(subsequence($req-xml, $chunk-size+1), $chunk-size,$upload-uri)
},
<options xmlns="xdmp:eval">
<result>true</result>
<update>true</update>
<commit>auto</commit>
</options>))
return $response)
else xdmp:log("Job completed successfully")
};
let $req := xdmp:get-request-body("json")/node()
let $config := json:config("custom")
let $req-xml := json:transform-from-json($req,$config)
let $chunk-size := 10
let $resp := xdmp:spawn-function(function() {local:upload-record($req-xml, $chunk-size,$bulk-upload-uri)}, <options xmlns="xdmp:eval"><result>true</result></options>)
return <response>Upload triggered successfully</response>
If there is an occurrence of error, say, timeout error, which stops the request processing at the mid of the task ,I need to report it to the UI that the processing is stopped due to error and provide the partial results to the UI.
So ,Is it possible to use try/catch when using spawn function? If so, how can we do it?
OK. I have given a sample below about one strategy that you could take:
Have a record in the system that helps track the work under the hood.
declare namespace my-lib = "http://www.example.com/my-lib";
(:Record a process step against the ID
Note - this function is "quick", but is a separate transaction and causes calling code (all 5 chunk processors) to queue in order to update.
If you log every step, it could slow the system down and create huge XML files. Tens of entries, OK. hundred, probably OK.
There are other strategies that could be used. However, I keep the lock for only the update/insert time (hence the eager evaluation of the entry in advance of the invoke-function)
:)
declare function my-lib:record-process-step($id, $status, $message, $data){
let $uri := "/my-logs/" || $id
let $entry := xdmp:eager(my-lib:generate-entry($id, $status, $message, $data))
let $_ := xdmp:invoke-function(function(){if(fn:exists(fn:doc($uri)))
then xdmp:node-insert-child(fn:doc($uri)/my-lib:log, $entry)
else xdmp:document-insert($uri, <my-lib:log>{$entry}</my-lib:log>)
})
return $uri
};
(: Generate a single record for a process step. Note the XML payload $data. I did this because different steps may have different information to pass:)
declare function my-lib:generate-entry($id as xs:string, $status as xs:string, $message as xs:string, $data as element()){
element my-lib:entry {
attribute id {$id},
attribute status {$status},
attribute message {$message},
attribute timstamp {fn:current-dateTime() + xdmp:elapsed-time()},
$data
}
};
(:For this sample, a unique ID:)
let $id := sem:uuid-string()
(:Mimic your chunking - I chose 5 as a sample :)
let $number-of-chunks := 5
(:First entry -initialization - lets us know how many chunks - payload details are the context of "Initialize Processing" :)
let $_ := my-lib:record-process-step($id, "intialize-processing", "starting processing of all chunks", <details><total-chunks>{$number-of-chunks}</total-chunks></details>)
(: Mimic the processing of chunks:)
let $_ := for $chunk-number in (1 to $number-of-chunks)
return xdmp:spawn-function(function(){
(:Messag about starting a chunk. - details reference this chunk:)
let $_ := my-lib:record-process-step($id, "chunk-start", "starting processing of chunk " || $chunk-number, <details><chunk-number>{$chunk-number}</chunk-number></details>)
(: Mimic doing some work - variable amount of stuff per chunk to get some interesting records back:)
let $_ := for $x in (1 to xdmp:random(5))
(: Mimic the work taking different amounts of time so that the log order is all random per chunk
- log the work update - for sample only - see notes at top about how much to log. I would have this log off unless I really needed intermediate information.:)
let $_ := xdmp:sleep((xdmp:random(5)+5)*1000)
let $_ := my-lib:record-process-step($id, "chunk-process-update", "I did something interesting in chunk " || $chunk-number, <details><chunk-number>{$chunk-number}</chunk-number><add-some-context-here/></details>)
return ()
(:Log when a chunk is done:)
let $_ := my-lib:record-process-step($id, "chunk-end", "end processing of chunk " || $chunk-number, <details><chunk-number>{$chunk-number}</chunk-number></details>)
return ()
})
return <response>{$id}</response>
Example Response:
<response>922116fa-2b0f-4f1e-ac5d-97a8b69dcec0</response>
enter code here
Log entry for /my-logs/922116fa-2b0f-4f1e-ac5d-97a8b69dcec0 is below.
You will not that the entries are in various orders per chunk and that the chunks do not finish in time. However, some critical datapoints:
one entry about total chunks for this ID
5 start entries - one for each chunk
-- Note: They are not guaranteed to start next to each other or right away - they may be queued on the task queue depending on other work competing for the task server
5 End entries out of order in terms of batch ID -by design in sample
You could add additional functions to the library to check on status like:
total chunks - count of started = queued
total chunks > count of chunks completed = not done
Processing time completed = if all chunks, then last timestamp of the chunk complete message
etc....
This simple functions, if exposed to your calling system could then be invoked externally to keep the other system (or browser) up to date on current process. This sample code only security is an important consideration that this sample does not cover. It also does not cover error situations, but strategically placed try/catch could log many of those as a different entry type.
`
<my-lib:log xmlns:my-lib="http://www.example.com/my-lib">
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="intialize-processing" message="starting processing of all chunks" timstamp="2022-08-08T14:15:13.7686171+02:00">
<details>
<total-chunks>5</total-chunks>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-start" message="starting processing of chunk 1" timstamp="2022-08-08T14:15:13.824793+02:00">
<details>
<chunk-number>1</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-start" message="starting processing of chunk 2" timstamp="2022-08-08T14:15:13.8360725+02:00">
<details>
<chunk-number>2</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-end" message="end processing of chunk 2" timstamp="2022-08-08T14:15:13.8370602+02:00">
<details>
<chunk-number>2</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-start" message="starting processing of chunk 3" timstamp="2022-08-08T14:15:13.8509333+02:00">
<details>
<chunk-number>3</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-start" message="starting processing of chunk 5" timstamp="2022-08-08T14:15:13.8666333+02:00">
<details>
<chunk-number>5</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-start" message="starting processing of chunk 4" timstamp="2022-08-08T14:15:13.8512207+02:00">
<details>
<chunk-number>4</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 5" timstamp="2022-08-08T14:15:19.8824323+02:00">
<details>
<chunk-number>5</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 4" timstamp="2022-08-08T14:15:19.9916399+02:00">
<details>
<chunk-number>4</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 1" timstamp="2022-08-08T14:15:20.8374943+02:00">
<details>
<chunk-number>1</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 3" timstamp="2022-08-08T14:15:22.8608729+02:00">
<details>
<chunk-number>3</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 3" timstamp="2022-08-08T14:15:28.8780495+02:00">
<details>
<chunk-number>3</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 5" timstamp="2022-08-08T14:15:28.8940915+02:00">
<details>
<chunk-number>5</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 4" timstamp="2022-08-08T14:15:29.9991982+02:00">
<details>
<chunk-number>4</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 1" timstamp="2022-08-08T14:15:30.8416467+02:00">
<details>
<chunk-number>1</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-end" message="end processing of chunk 1" timstamp="2022-08-08T14:15:30.844275+02:00">
<details>
<chunk-number>1</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 4" timstamp="2022-08-08T14:15:37.0065493+02:00">
<details>
<chunk-number>4</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 3" timstamp="2022-08-08T14:15:38.8920007+02:00">
<details>
<chunk-number>3</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 5" timstamp="2022-08-08T14:15:38.9078871+02:00">
<details>
<chunk-number>5</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 4" timstamp="2022-08-08T14:15:45.0274099+02:00">
<details>
<chunk-number>4</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 3" timstamp="2022-08-08T14:15:46.9046038+02:00">
<details>
<chunk-number>3</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 5" timstamp="2022-08-08T14:15:47.9183383+02:00">
<details>
<chunk-number>5</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-end" message="end processing of chunk 5" timstamp="2022-08-08T14:15:47.9213179+02:00">
<details>
<chunk-number>5</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 4" timstamp="2022-08-08T14:15:51.0422546+02:00">
<details>
<chunk-number>4</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-end" message="end processing of chunk 4" timstamp="2022-08-08T14:15:51.0440896+02:00">
<details>
<chunk-number>4</chunk-number>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-process-update" message="I did something interesting in chunk 3" timstamp="2022-08-08T14:15:51.9137371+02:00">
<details>
<chunk-number>3</chunk-number>
<add-some-context-here>
</add-some-context-here>
</details>
</my-lib:entry>
<my-lib:entry id="922116fa-2b0f-4f1e-ac5d-97a8b69dcec0" status="chunk-end" message="end processing of chunk 3" timstamp="2022-08-08T14:15:51.9168928+02:00">
<details>
<chunk-number>3</chunk-number>
</details>
</my-lib:entry>
</my-lib:log>
`
Related
I am trying to set the payload with a soap envelope, header, and body.
then substring payload by payload.indexOf("?>")+2
Based on the following expression:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://decisionresearch.com/RateMaker">
<soapenv:Header/>
<soapenv:Body>
#[payload.substring(payload.indexOf("?>")+2)]
</soapenv:Body>
</soapenv:Envelope>
Input Request: https://github.com/Manikandan99/Map_request/blob/main/Request_map.xml
Expected output: https://github.com/Manikandan99/Map_request/blob/main/Response_map.xml
Mule FLow:
<flow name="map_requestFlow" doc:id="21d0d652-3766-47ed-95aa-a451f62c5776" >
<http:listener doc:name="Listener" doc:id="7312114b-2857-40b3-98cd-f52b628b3a28" config-ref="HTTP_Listener_config" path="/map"/>
<ee:transform doc:name="Transform Message" doc:id="7f061325-473b-4f63-8e95-990827b03259" >
<ee:message >
<ee:set-payload ><![CDATA[%dw 2.0
output application/xml
---
payload]]></ee:set-payload>
</ee:message>
</ee:transform>
<logger level="INFO" doc:name="Logger" doc:id="21051f39-bb9f-412c-af73-f65051317757" message="#[payload]"/>
<set-payload value='#[<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns0="http://decisionresearch.com/RateMaker">
<soapenv:Header/>
<soapenv:Body>
#[payload.substring(payload.indexOf("?>")+2)]
</soapenv:Body>
</soapenv:Envelope>]' doc:name="Set Payload" doc:id="faf2bc3b-e7a3-4708-910b-daeb05bb5f6e" />
</flow>
Error message : https://github.com/Manikandan99/Map_request/blob/main/Error.txt
How to encapsulate soap with current payload?
That's wrong because of several reasons. First you can not use an expression inside an expression. Second you are trying to generate XML with strings, when DataWeave already does generates valid XML. Using strings directly is very very error prone. Whenever you see string manipulation to generate or parse XML, you should be questioning the reason.
Instead use DataWeave to generate the XML completely in a simple transform:
%dw 2.0
output application/xml
ns soapenv http://schemas.xmlsoap.org/soap/envelope/
---
{
soapenv#Envelop: {
soapenv#Header: null,
soapenv#Body: payload
}
}
Output (assuming the input has format application/xml):
<?xml version='1.0' encoding='UTF-8'?>
<soapenv:Envelop xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">
<soapenv:Header/>
<soapenv:Body>
<ns0:rate xmlns:ns0="http://decisionresearch.com/RateMaker">
<ns0:BrokerData>
<ns0:taxa>TOPA/CISG01/ALL</ns0:taxa>
<ns0:effectiveMode>effective</ns0:effectiveMode>
<ns0:requestDate>20190101</ns0:requestDate>
<ns0:function>rate</ns0:function>
</ns0:BrokerData>
<ns0:RateRequest>
<ns0:Policy>
<PolType>CNPK</PolType>
<ClassCode>CANDIS</ClassCode>
<Zip>80003</Zip>
<State>CO</State>
<EffDate>20211117</EffDate>
<ExpDate>20221117</ExpDate>
<Payroll>1200</Payroll>
<OHPayroll/>
<WAPayroll/>
<FTE>5</FTE>
<OccAgg>1000000/2000000</OccAgg>
<DmgPrem>500000</DmgPrem>
<MedPay>10000</MedPay>
<EmpBen>Yes</EmpBen>
<StopGap>None</StopGap>
<OHStopGap>None</OHStopGap>
<WAStopGap>None</WAStopGap>
<HNO>1000000</HNO>
<AssBat>100000/200000</AssBat>
<PerLocAgg>Yes</PerLocAgg>
<NumLoc>1</NumLoc>
<WSUB>0</WSUB>
<PICO>No</PICO>
<AIML>0</AIML>
<AIVS>0</AIVS>
<AIPA>0</AIPA>
<AIMA>0</AIMA>
<AILL>0</AILL>
<LLEA>0</LLEA>
<AIDP>0</AIDP>
<BAIV>No</BAIV>
<WACombo>No</WACombo>
<IRPMGL>2</IRPMGL>
<LPDPGL>1.00</LPDPGL>
</ns0:Policy>
<ns0:Location>
<LocationRef>Location-465697646-800339871</LocationRef>
<State>CO</State>
<Zip>80003</Zip>
</ns0:Location>
<ns0:Class>
<Id>Risk-1296379588-1802098261</Id>
<Number>1</Number>
<ClassCode>CANDIS</ClassCode>
<Exposure>2000000</Exposure>
<GLBR>25</GLBR>
<IsPrimary>Yes</IsPrimary>
</ns0:Class>
</ns0:RateRequest>
</ns0:rate>
</soapenv:Body>
</soapenv:Envelop>
I have the oracle database table CASH which contains below columns:
REGISTER DATE CASE BAG TYPE
1234 24-SEP-18 1123 112 A
1234 24-SEP-18 1124 113 S
1234 24-SEP-18 1123 116 S
1234 24-SEP-18 1124 117 A
7895 24-SEP-18 2568 119 A
7895 24-SEP-18 2568 118 S
Where the register number are the cash registers which can have multiple CASE linked to it and each CASE can have more than one BAG and Type attached to it. I want to transform it into below XML in Dataweave:
<ROOT>
<REGISTERS>
<REGISTER>1234</REGISTER>
<DATE>24-SEP-2018</DATE>
<DETAILS>
<BAG>1123</BAG>
<DETAIl>
<BAG>112</BAG>
<TYPE>A</TYPE>
</DETAIl>
<DETAIl>
<BAG>116</BAG>
<TYPE>S</TYPE>
</DETAIl>
</DETAILS>
<DETAILS>
<BAG>1124</BAG>
<DETAIl>
<BAG>113</BAG>
<TYPE>S</TYPE>
</DETAIl>
<DETAIl>
<BAG>117</BAG>
<TYPE>A</TYPE>
</DETAIl>
</DETAILS>
</REGISTERS>
<REGISTERS>
<REGISTER>7895</REGISTER>
<DATE>24-SEP-2018</DATE>
<DETAILS>
<BAG>2568</BAG>
<DETAIl>
<BAG>119</BAG>
<TYPE>A</TYPE>
</DETAIl>
<DETAIl>
<BAG>118</BAG>
<TYPE>S</TYPE>
</DETAIl>
</DETAILS>
</REGISTERS>
</ROOT>
Could you please give some pointers how can I achieve this in dataweave.
Thanks !!
Assuming you've already read the data from the database, you can use the following:
%dw 1.0
%output application/xml
---
ROOT: payload groupBy (($.REGISTER as :string) ++ ($.DATE as :string)) mapObject ((entries, number) -> {
REGISTERS: {
REGISTER: entries[0].REGISTER,
DATE: entries[0].DATE as :string {format: "yyyy-MM-dd"},
(entries groupBy $.CASE map DETAILS: {
CASE: $.CASE[0],
($ map DETAIL: {
BAG: $.BAG,
TYPE: $.TYPE
})
})
}
})
Can somebody help me with producing XML from two sql tables?
This is what I want:
<Sales>
<Sale>
<Journal_Prime>400000</Journal_Prime>
<DocNumber>100001</DocNumber>
<Details>
<Detail>
<Account>700300</Account>
<Amount>276,79</Amount>
<DebCre>-1</DebCre>
<Ventil>70</Ventil>
<Ref>WD2093E0V0</Ref>
<DocNumber>100001</DocNumber>
</Detail>
<Detail>
<Account>708000</Account>
<Amount>0,00</Amount>
<DebCre>1</DebCre>
<Ventil>70</Ventil>
<Ref>Korting</Ref>
<DocNumber>100001</DocNumber>
</Detail>
<Detail>
<Account>700530</Account>
<Amount>55,00</Amount>
<DebCre>-1</DebCre>
<Ventil>70</Ventil>
<Ref>Transport</Ref>
<DocNumber>100001</DocNumber>
</Detail>
<Detail>
<Account>451000</Account>
<Amount>0,00</Amount>
<DebCre>-1</DebCre>
<Ventil>11</Ventil>
<Ref>BTW</Ref>
<DocNumber>100001</DocNumber>
</Detail>
</Details>
</Sale>
</Sales>
This is my attempt
SELECT Sale.Journal_Prime, Sale.DocNumber, Detail.Account, Detail.Account, Detail.Amount, Detail.DebCre, Detail.Ventil, Detail.Ref, Detail.DocNumber
FROM XML_FAKAdres2017 as Sale
INNER JOIN XML_FAK2017 as Detail
ON Sale.DocNumber = Detail.DocNumber
FOR XML AUTO, ROOT('Sales'), ELEMENTS
giving me this result
<Sales>
<Sale>
<Journal_Prime>400000</Journal_Prime>
<DocNumber>100001</DocNumber>
<Detail>
<Account>700300</Account>
<Amount>276,79</Amount>
<DebCre>-1</DebCre>
<Ventil>70</Ventil>
<Ref>WD2093E0V0</Ref>
<DocNumber>100001</DocNumber>
</Detail>
<Detail>
<Account>708000</Account>
<Amount>0,00</Amount>
<DebCre>1</DebCre>
<Ventil>70</Ventil>
<Ref>Korting</Ref>
<DocNumber>100001</DocNumber>
</Detail>
<Detail>
<Account>700530</Account>
<Amount>55,00</Amount>
<DebCre>-1</DebCre>
<Ventil>70</Ventil>
<Ref>Transport</Ref>
<DocNumber>100001</DocNumber>
</Detail>
<Detail>
<Account>451000</Account>
<Amount>0,00</Amount>
<DebCre>-1</DebCre>
<Ventil>11</Ventil>
<Ref>BTW</Ref>
<DocNumber>100001</DocNumber>
</Detail>
</Sale>
</Sales>
So, I'm missing the <Details></Details> which is required by the bookkeeping program this code is meant for import. I'm not familiar with XML and to be honest I don't have a clue where this coming from.
Thanks.
Rik
Try this
SELECT Sale.Journal_Prime, Sale.DocNumber ,
(SELECT Detail.Account, Detail.Account, Detail.Amount,
Detail.DebCre, Detail.Ventil, Detail.Ref, Detail.DocNumber
FROM XML_FAK2017 as Detail where Sale.DocNumber = Detail.DocNumber
FOR XML AUTO,TYPE,ROOT('Details'),ELEMENTS)
FROM XML_FAKAdres2017 as Sale
FOR XML AUTO, ROOT('Sales'),ELEMENTS
Code to save the card number in the card number variable from request.
<set-variable variableName="cardNumber" value="#[xpath3('//#CardNumber', message.payload,'STRING')]" doc:name="Set cardNumber"/>
<logger level="INFO" message=" #[xpath3('//#CardNumber', message.payload, 'STRING')]" />
<logger message="#[flowVars['operationName']] cardNumber is = #[flowVars['cardNumberr']]" level="INFO" category="member" doc:name="Logger"/>
Below is the payload
mlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:typ="http://ws.loyalty.com/cpm/esb/amrp/2/1/member/types">
<soapenv:Header/>
<soapenv:Body>
<typ:GetMemberProfileRequest>
<typ:RequestContext Channel="WEB" Source="" Locale="" User="ONLINEUSER"/>
<typ:CardNumber>80000000021</typ:CardNumber>
</typ:GetMemberProfileRequest>
</soapenv:Body>
</soapenv:Envelope>
The card number is coming empty string in logs
#esha sherry, the xpath3 expression to get the card number should be
#[xpath3('/soapenv:Envelope/soapenv:Body/typ:GetMemberProfileRequest/typ:CardNumber', message.payload, 'STRING')]
I'm trying to send the request to IRS using WCF and file is attached as follows
TransmitterACAUIBusinessHeaderType manifestType = iRSSubmissionManifest;
ACASendService.BulkRequestTransmitterRequest request = new ACASendService.BulkRequestTransmitterRequest();
request.Security = GetSecurity();
request.ACATransmitterManifestReqDtl = GetACATransmitterManifestReqDtl(manifestType);
request.ACABusinessHeader = GetACATransmitterBusinessHeaderRequest(manifestType);
request.ACABulkRequestTransmitter = new ACABulkRequestTransmitterType();
byte[] uploadFile = StreamingHelper.Chunk(_submissionXmlFolderPath);
request.ACABulkRequestTransmitter.BulkExchangeFile = uploadFile;
ACASendService.BulkRequestTransmitterPortTypeClient _airClient = new ACASendService.BulkRequestTransmitterPortTypeClient();
ACASendService.ACABulkRequestTransmitterResponseType response = _airClient.BulkRequestTransmitter(request.ACASecurityHeader, request.Security, ref request.ACABusinessHeader, request.ACATransmitterManifestReqDtl, request.ACABulkRequestTransmitter);
When I look at the request I can see the binary data in Soap Body
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:us:gov:treasury:irs:ext:aca:air:7.0" xmlns:urn1="urn:us:gov:treasury:irs:common" xmlns:urn2="urn:us:gov:treasury:irs:msg:acabusinessheader" xmlns:urn3="urn:us:gov:treasury:irs:msg:irsacabulkrequesttransmitter">
<soapenv:Header xmlns:wsa="http://www.w3.org/2005/08/addressing">
<wsse:Security xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<Signature Id="SIG-57610A09584142FAA8ABFBD262776BF9" xmlns="http://www.w3.org/2000/09/xmldsig#">
<SignedInfo>
<CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#WithComments"/>
<SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1"/>
<Reference URI="#TS-C126221AACCA4F37BDBBC1AE27A45F44">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<InclusiveNamespaces PrefixList="wsse wsa soapenv urn urn1 urn2 urn3" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transform>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>DtSEqek9RuRdR/q8AlxobY/90+o=</DigestValue>
</Reference>
<Reference URI="#MF-D3C0AAF6624148A08627F799ECDDA387">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<InclusiveNamespaces PrefixList="wsa soapenv urn1 urn2 urn3" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transform>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>adRdmNY8Gwrebd9fMaiBRCgz/3o=</DigestValue>
</Reference>
<Reference URI="#BH-CD8C12D6D4984DD3901CFE1D9E65A86A">
<Transforms>
<Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
<InclusiveNamespaces PrefixList="wsa soapenv urn urn1 urn3" xmlns="http://www.w3.org/2001/10/xml-exc-c14n#"/>
</Transform>
</Transforms>
<DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1"/>
<DigestValue>dj4DhqNAJnNp40DT5dEdKGTOP48=</DigestValue>
</Reference>
</SignedInfo>
<SignatureValue>Signature==</SignatureValue>
<KeyInfo Id="KI-4174BEF920A14F639F7C4E9F825D53AE">
<wsse:SecurityTokenReference wsu:Id="STR-192B01936AC24010A0DF60BD21F3A6FA">
<KeyIdentifier EncodingType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary" ValueType="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3" xmlns="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">KeyData==</KeyIdentifier>
</wsse:SecurityTokenReference>
</KeyInfo>
</Signature>
<wsu:Timestamp wsu:Id="TS-C126221AACCA4F37BDBBC1AE27A45F44" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<wsu:Created>2016-04-18T12:03:46.570Z</wsu:Created>
<wsu:Expires>2016-04-18T12:13:46.572Z</wsu:Expires>
</wsu:Timestamp>
</wsse:Security>
<urn:ACATransmitterManifestReqDtl wsu:Id="MF-D3C0AAF6624148A08627F799ECDDA387" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<PaymentYr>2015</PaymentYr>
<PriorYearDataInd>0</PriorYearDataInd>
<EIN>EIN</EIN>
<TransmissionTypeCd>O</TransmissionTypeCd>
<TestFileCd>T</TestFileCd>
<TransmitterNameGrp>
<BusinessNameLine1Txt>Name</BusinessNameLine1Txt>
</TransmitterNameGrp>
<CompanyInformationGrp>
<CompanyNm>Company</CompanyNm>
<MailingAddressGrp>
<USAddressGrp>
<AddressLine1Txt>Address1</AddressLine1Txt>
<CityNm>City</CityNm>
<USStateCd>MD</USStateCd>
<USZIPCd>ZIP</USZIPCd>
</USAddressGrp>
</MailingAddressGrp>
<ContactNameGrp>
<PersonFirstNm>First</PersonFirstNm>
<PersonLastNm>Last</PersonLastNm>
</ContactNameGrp>
<ContactPhoneNum>Phone</ContactPhoneNum>
</CompanyInformationGrp>
<VendorInformationGrp>
<VendorCd>I</VendorCd>
<ContactNameGrp>
<PersonFirstNm>First</PersonFirstNm>
<PersonLastNm>Last</PersonLastNm>
</ContactNameGrp>
<ContactPhoneNum>Phone</ContactPhoneNum>
</VendorInformationGrp>
<TotalPayeeRecordCnt>1</TotalPayeeRecordCnt>
<TotalPayerRecordCnt>1</TotalPayerRecordCnt>
<SoftwareId></SoftwareId>
<FormTypeCd>1094/1095C</FormTypeCd>
<BinaryFormatCd>application/xml</BinaryFormatCd>
<ChecksumAugmentationNum>4BDAA151D8543B25D9A3DCDFDBFF0F44</ChecksumAugmentationNum>
<AttachmentByteSizeNum>3800</AttachmentByteSizeNum>
<DocumentSystemFileNm>1094C_Request_TCC_20160418T062909155Z.xml</DocumentSystemFileNm>
</urn:ACATransmitterManifestReqDtl>
<urn2:ACABusinessHeader wsu:Id="BH-CD8C12D6D4984DD3901CFE1D9E65A86A" xmlns:wsu="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd">
<urn:UniqueTransmissionId xmlns:urn="urn:us:gov:treasury:irs:ext:aca:air:7.0">d5631c37-de39-4569-914f-41d482b780e6:SYS12:TCC::T</urn:UniqueTransmissionId>
<urn1:Timestamp xmlns:urn1="urn:us:gov:treasury:irs:common">2016-04-18T17:33:53Z</urn1:Timestamp>
</urn2:ACABusinessHeader>
<wsa:Action>BulkRequestTransmitterService</wsa:Action>
</soapenv:Header>
<soapenv:Body>
<urn3:ACABulkRequestTransmitter version="1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<urn1:BulkExchangeFile>PEZvcm0xMDk0OTVDVHJhbnNtaXR0YWxVcHN0cm_File_Bytes=</urn1:BulkExchangeFile>
</urn3:ACABulkRequestTransmitter>
</soapenv:Body>
Am I missing anything? is there any specific bindings or encoding need to be added?
If I'm reading your generated XML correctly, it seems that you have embedded the file contents of your tax forms in the BulkExchangeFile element. Perhaps this is because when you looked at the wsdl file that the IRS distributes, the said element is described as xsd:base64Binary.
If you look at the page 84 of IRS' Composition Guide v4.3,https://www.irs.gov/PUP/for_taxpros/software_developers/information_returns/AIR%20Submission%20Composition%20and%20Reference%20Guide%20TY2015_v4.3_03_17_2016.pdf (or search for http://www.w3.org/2004/08/xop/include in the document), you will see that BulkExchangeFile should be populated like:
<inc:Include href="cid:yourAttachmentFile.xml" xmlns:inc="http://www.w3.org/2004/08/xop/include"/>
where yourAtachmentFile.xml is the file you want to send to the IRS-AIR-A2A system. As you'll see in the page, your tax data is expected to be received as an MTOM attachment.
In essence, your XML above has the tax data within the BulkExchangeElement and you aren't sending the data as an MTOM attachment.
I think you're a C# guy (I'm a java dude) so this thread might help you out: IRS-A2A BulkRequestTransmitter message not formmatted properly and/or cannot be interpreted
I had trouble sending our 1095 data to the IRS until I saw page 84 in the Composition Guide. One would think that complying to the WSDL should be enough to communicate with a web service ;)