# Trying to get data from ascii to a string

**URL:** <https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149>\
**Category:** General\
**Created:** [12 October 2020 21:06 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149 "2020-10-12T21:06:13Z")\
**Posts on this page:** 20\
**Page:** 2

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2020 14:21 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/24 "2020-10-13T14:21:42Z")

</div>

Unless you tell us which function is the "soap function", what the input to the function is and what output you are expecting then we don't know where to look.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2020 14:23 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/25 "2020-10-13T14:23:04Z")

</div>

Also you need to post the flow correctly so we can import it, as described by @UnborN and myself.

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 14:28 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/27 "2020-10-13T14:28:16Z")

</div>

I had to change from complete msg to normal debug and than you see the envelope data. All good. Deleted the pics and posts so people dont get confused.

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2020 14:29 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/28 "2020-10-13T14:29:16Z")

</div>

All you needed to do to see the contents of the payload object was to click on it in the debug. So is everything working now?

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 14:30 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/29 "2020-10-13T14:30:00Z")

</div>

This worked and than I had to change the debug output

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 October 2020 14:37 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/30 "2020-10-13T14:37:02Z")

</div>

Changing the debug output from complete msg to msg.payload doesnt change anything with the msg itself.  
but Im glad you found a solution cause i have no idea what SOAP is 😉

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 14:37 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/31 "2020-10-13T14:37:51Z")

</div>

Pain the ass web service to a database so IT can slow down development, create more overhead and just overall jam things up. Its just a sql query that is given to toddlers

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 14:44 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/32 "2020-10-13T14:44:28Z")

</div>

When i change it back to the function it doesnt work again. Here you can see the 1392 returned and just below that is the new debug info for the function. Do you know how I can get msg.\_msgid at the top before the payload?

Update: Nope, i used delete msg.payroll in a precursor function and it put it on top but still doesnt work. The string in the payload is exactly the same. Same node that works with inject string that matches.... HMMM???

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 October 2020 14:59 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/33 "2020-10-13T14:59:33Z")

</div>

> [@jeffreys](#):
>
> Do you know how I can get msg.\_msgid at the top before the payload?

the order of the msg object properties have nothing to do with it. Its an object .. the order doesnt matter.  
and also \_msgid is something internal for tracking Node-red messages.

So to understand better.  
If you inject a custom message to the SOAP node, you get a reply from it and  
when you use the Function node to send a msg to SOAP it doesnt work ?

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 15:00 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/34 "2020-10-13T15:00:44Z")

</div>

Correct. Here is my flow. The current way wired up is your function and you can see the inject that can be wired up instead. The inject works. the function doesnt

```auto
[{"id":"e6693df7.a3cfa","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"eb571ded.e53f3","type":"modbus-read","z":"e6693df7.a3cfa","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"21","rate":"1","rateUnit":"m","delayOnStart":false,"startDelayTime":"","server":"5410cb45.9afa3c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":110,"y":240,"wires":[[],["bf1abdfc.b1d4e","aafbdb90.305bd8"]]},{"id":"d74a4291.c4218","type":"switch","z":"e6693df7.a3cfa","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"neq","v":"1","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":350,"y":340,"wires":[["2c48206b.b7cbd"],[]]},{"id":"68d47360.93fddc","type":"function","z":"e6693df7.a3cfa","name":"","func":"\nmsg.site = 'AC'\n//msg.serial = msg.payload\nmsg.serial = global.get(\"SN\")\n\n////msg.serial = global.get(\"SN\")\n//msg.serial = 'BVGL01272'\n\n\nvar parse1 = '<?xml version=\"1.0\" encoding=\"utf-8\"?>';\nparse1 = parse1 + '\\n' + '<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">';\n//parse1 = parse1 + '\\n' + ' <soap:Header>';\n//parse1 = parse1 + '\\n' + ' <SoapSettings xmlns=\"http://tempuri.org/\">';\n//parse1 = parse1 + '\\n' + ' <IsTest>false</IsTest>';\n//parse1 = parse1 + '\\n' + ' <ApplicationID>105B9760-A4A0-4659-BE09-2B6F64980DBD</ApplicationID>';\n//parse1 = parse1 + '\\n' + ' <ApplicationKey>C565C1F9-A326-4754-B654-CFA059865820</ApplicationKey>';\n//parse1 = parse1 + '\\n' + ' </SoapSettings>';\n//parse1 = parse1 + '\\n' + ' </soap:Header>';\nparse1 = parse1 + '\\n' + ' <soap:Body>'\nparse1 = parse1 + '\\n' + ' <GetChargeRecipe xmlns=\"http://tempuri.org/\">';\nparse1 = parse1 + '\\n' + ' <serialNumber>' + global.get(\"SN\") + '</serialNumber>';\nparse1 = parse1 + '\\n' + ' <site>' + msg.site + '</site>';\n//parse1 = parse1 + '\\n' + ' <billNum>' + msg.billNum + '</billNum>';\nparse1 = parse1 + '\\n' + ' </GetChargeRecipe>';\nparse1 = parse1 + '\\n' + ' </soap:Body>';\nparse1 = parse1 + '\\n' + '</soap:Envelope>';\nmsg.payload = parse1;\n\ndelete msg.site\ndelete msg.serial\nmsg.topic = \"\";\nreturn msg;\n\n//var testval = global.get(\"test\")||0;\n//msg.payload = testval;\n//return msg;\n\n\n\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":260,"wires":[[]]},{"id":"bf1abdfc.b1d4e","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.data[20]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":340,"wires":[["d74a4291.c4218"]]},{"id":"7cad4f22.cfc79","type":"comment","z":"e6693df7.a3cfa","name":"Read from Wago","info":"","x":120,"y":200,"wires":[]},{"id":"37855d95.4f6b3a","type":"comment","z":"e6693df7.a3cfa","name":"Get 20th array position for serial wrote ","info":"","x":150,"y":380,"wires":[]},{"id":"eb4f9416.32b32","type":"comment","z":"e6693df7.a3cfa","name":"Check if equal 1, fire get web service","info":"","x":280,"y":420,"wires":[]},{"id":"77b13775.67d7ac","type":"comment","z":"e6693df7.a3cfa","name":"need SN put back into string global SN","info":"","x":250,"y":100,"wires":[]},{"id":"aafbdb90.305bd8","type":"function","z":"e6693df7.a3cfa","name":"","func":"//msg.value = String.fromCharCode(...msg.payload.data)\n\n//return msg;\nlet arr = msg.payload.data;\narr.pop();\nmsg.value = String.fromCharCode(...arr)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":140,"wires":[["3557e0ae.d936a"]]},{"id":"3557e0ae.d936a","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"SN","pt":"global","to":"value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":140,"wires":[[]]},{"id":"6aebd91.ca17728","type":"debug","z":"e6693df7.a3cfa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":100,"wires":[]},{"id":"1182f01a.64e21","type":"comment","z":"e6693df7.a3cfa","name":"Get global SN ","info":"","x":370,"y":220,"wires":[]},{"id":"79d279fa.08fe18","type":"debug","z":"e6693df7.a3cfa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":280,"wires":[]},{"id":"bcf8e8a3.96f408","type":"function","z":"e6693df7.a3cfa","name":"","func":"\n//global.set(\"CHARGEPERSYSTEM1\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM1)\n//global.set(\"CHARGEPERSYSTEM2\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM2)\n//global.set(\"CHARGEPERSYSTEM3\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM3)\n//global.set(\"CHARGEPERSYSTEM4\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM4)\n//global.set(\"CHARGEPERSYSTEM5\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM5)\n//global.set(\"CHARGEPERSYSTEM6\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM6)\n//global.set(\"CHARGEPERSYSTEM7\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM7)\n//global.set(\"CHARGEPERSYSTEM8\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM8)\n\nglobal.set(\"CHARGEPERSYSTEM1\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill1Quantity)\nglobal.set(\"CHARGEPERSYSTEM2\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill2Quantity)\nglobal.set(\"CHARGEPERSYSTEM3\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill3Quantity)\nglobal.set(\"CHARGEPERSYSTEM4\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill4Quantity)\nglobal.set(\"CHARGEPERSYSTEM5\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill5Quantity)\nglobal.set(\"CHARGEPERSYSTEM6\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill6Quantity)\nglobal.set(\"CHARGEPERSYSTEM7\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill7Quantity)\nglobal.set(\"CHARGEPERSYSTEM8\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill8Quantity)\n\n\n\n\nmsg.CHARGEPERSYSTEM1 = global.get(\"CHARGEPERSYSTEM1\");\nmsg.CHARGEPERSYSTEM2 = global.get(\"CHARGEPERSYSTEM2\");\nmsg.CHARGEPERSYSTEM3 = global.get(\"CHARGEPERSYSTEM3\");\nmsg.CHARGEPERSYSTEM4 = global.get(\"CHARGEPERSYSTEM4\");\nmsg.CHARGEPERSYSTEM5 = global.get(\"CHARGEPERSYSTEM5\");\nmsg.CHARGEPERSYSTEM6 = global.get(\"CHARGEPERSYSTEM6\");\nmsg.CHARGEPERSYSTEM7 = global.get(\"CHARGEPERSYSTEM7\");\nmsg.CHARGEPERSYSTEM8 = global.get(\"CHARGEPERSYSTEM8\");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":280,"wires":[["79d279fa.08fe18"]]},{"id":"35187516.658fca","type":"debug","z":"e6693df7.a3cfa","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":750,"y":180,"wires":[]},{"id":"dd225fc6.1380a","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetChargeRecipe xmlns=\"http://tempuri.org/\"> <serialNumber>' + global.get(\"SN\") + '</serialNumber> <site>AC</site> </GetChargeRecipe> </soap:Body> </soap:Envelope>","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":520,"wires":[[]]},{"id":"2c48206b.b7cbd","type":"function","z":"e6693df7.a3cfa","name":"","func":"delete msg.values\ndelete msg.input\ndelete msg.sendingNodeId\ndelete msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":580,"wires":[["ab242c2d.571b5"]]},{"id":"ab242c2d.571b5","type":"function","z":"e6693df7.a3cfa","name":"","func":"let SN = global.get(\"SN\");\nmsg.payload = `<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetChargeRecipe xmlns=\"http://tempuri.org/\"> <serialNumber>${SN}</serialNumber> <site>AC</site> </GetChargeRecipe> </soap:Body> </soap:Envelope>`\n//msg.topic = \"\";\ndelete msg.topic;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":680,"wires":[["5e9306a5.d58558","6aebd91.ca17728"]]},{"id":"5e9306a5.d58558","type":"simple-soap","z":"e6693df7.a3cfa","host":"http://172.16.17.6:8090/ChargeWs/ChargeService.asmx","hostType":"str","path":"","pathType":"str","action":"http://tempuri.org/GetChargeRecipe","actionType":"str","body":"payload","bodyType":"msg","mustache":false,"attrkey":"$","charkey":"_","stripPrefix":false,"simplify":false,"normalizeTags":false,"normalize":true,"topic":"","name":"GetChargeData","useAuth":false,"x":580,"y":240,"wires":[["bcf8e8a3.96f408","35187516.658fca"]]},{"id":"295f120e.cf468e","type":"inject","z":"e6693df7.a3cfa","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetChargeRecipe xmlns=\"http://tempuri.org/\"> <serialNumber>BVGJ01315</serialNumber> <site>AC</site> </GetChargeRecipe> </soap:Body> </soap:Envelope>","payloadType":"str","x":510,"y":160,"wires":[[]]},{"id":"5410cb45.9afa3c","type":"modbus-client","z":"","name":"WAGO","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"localhost","tcpPort":"503","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

```

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 October 2020 15:21 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/35 "2020-10-13T15:21:34Z")

</div>

They seem to be the same .. it doesnt make sense.  
Put a debug node after that function, with complete msg, to check if its identical with the msg from the inject node.  
The only difference is that with the function you dynamically send the SN with global.get("SN")  
maybe the global Context value is not set and its undefined ?  
Check the Context data as Colin mentioned  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/0/b08c11ebe2f965cf31795f7eebb2d8c7b4890dec.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2020 15:23 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/36 "2020-10-13T15:23:43Z")

</div>

Also add in the function node, after the global.get line

```auto
node.warn(`SN: ${SN}`)

```

and see what it shows in the debug pane.

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 15:24 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/37 "2020-10-13T15:24:04Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/8/6/861644fb0a9f55da729a0cfd2becfee2b4117c61.png)

And now wiring in Inject with same debug. This is way that works as you can see in debug

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/3/331e420364633d790199375710946bb3bcaaadb4.png)

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 15:25 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/38 "2020-10-13T15:25:32Z")

</div>

Gave me this. Soap still no go tho

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f5ea0f951f30a6f9033ee566a3d2f4fdd6605a0.png)

---

<div class="post-metadata">

**Author:** ![UnborN](https://avatars.discourse-cdn.com/v4/letter/u/4491bb/32.png) [@UnborN](https://discourse.nodered.org/u/UnborN)\
**Post date:** [13 October 2020 15:25 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/39 "2020-10-13T15:25:59Z")

</div>

Can you rename your debug nodes with names 1, 2, 3 because we dont know which is which

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 15:27 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/40 "2020-10-13T15:27:24Z")

</div>

![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/3/a/3a1a73c5cf60af33b8eaca917b7d6a57ea17d303.png)

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 15:29 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/41 "2020-10-13T15:29:07Z")

</div>

And here is the way it works again with the 1,2,3

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/b/b/bb2ff24bed395aef866b9bfd320754e213a66c06.png)

---

<div class="post-metadata">

**Author:** ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)\
**Post date:** [13 October 2020 15:37 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/42 "2020-10-13T15:37:51Z")

</div>

Does the soap node generate errors via a catch node? Add Status and Error nodes linked to the soap node and see if anything comes out. Connect them to (named) debug nodes showing the full message.  
Also repeat your test but this time instead of posting a screenshot click the little button by the payload line of debug 1 in each case and select Copy, then paste those here using the `</>` button as for flows.

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 15:44 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/43 "2020-10-13T15:44:41Z")

</div>

Ok here is the pic with the debug window shown and the exported flow.

Update: Last pic is the working inject and the debug. Doesnt look like the catch or status changes any from a none working one to a working one. See how the payload is null after the function being wired in. (debug 2 of first pic)

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/9/7/977edd969520a94cd70bd9d6d02b4b305c2cca36.png)

```auto
[{"id":"e6693df7.a3cfa","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"eb571ded.e53f3","type":"modbus-read","z":"e6693df7.a3cfa","name":"","topic":"","showStatusActivities":false,"logIOActivities":false,"showErrors":false,"unitid":"1","dataType":"HoldingRegister","adr":"0","quantity":"21","rate":"1","rateUnit":"m","delayOnStart":false,"startDelayTime":"","server":"5410cb45.9afa3c","useIOFile":false,"ioFile":"","useIOForPayload":false,"emptyMsgOnFail":false,"x":110,"y":240,"wires":[[],["bf1abdfc.b1d4e","aafbdb90.305bd8"]]},{"id":"d74a4291.c4218","type":"switch","z":"e6693df7.a3cfa","name":"","property":"payload","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"neq","v":"1","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":350,"y":340,"wires":[["2c48206b.b7cbd"],[]]},{"id":"68d47360.93fddc","type":"function","z":"e6693df7.a3cfa","name":"","func":"\nmsg.site = 'AC'\n//msg.serial = msg.payload\nmsg.serial = global.get(\"SN\")\n\n////msg.serial = global.get(\"SN\")\n//msg.serial = 'BVGL01272'\n\n\nvar parse1 = '<?xml version=\"1.0\" encoding=\"utf-8\"?>';\nparse1 = parse1 + '\\n' + '<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">';\n//parse1 = parse1 + '\\n' + ' <soap:Header>';\n//parse1 = parse1 + '\\n' + ' <SoapSettings xmlns=\"http://tempuri.org/\">';\n//parse1 = parse1 + '\\n' + ' <IsTest>false</IsTest>';\n//parse1 = parse1 + '\\n' + ' <ApplicationID>105B9760-A4A0-4659-BE09-2B6F64980DBD</ApplicationID>';\n//parse1 = parse1 + '\\n' + ' <ApplicationKey>C565C1F9-A326-4754-B654-CFA059865820</ApplicationKey>';\n//parse1 = parse1 + '\\n' + ' </SoapSettings>';\n//parse1 = parse1 + '\\n' + ' </soap:Header>';\nparse1 = parse1 + '\\n' + ' <soap:Body>'\nparse1 = parse1 + '\\n' + ' <GetChargeRecipe xmlns=\"http://tempuri.org/\">';\nparse1 = parse1 + '\\n' + ' <serialNumber>' + global.get(\"SN\") + '</serialNumber>';\nparse1 = parse1 + '\\n' + ' <site>' + msg.site + '</site>';\n//parse1 = parse1 + '\\n' + ' <billNum>' + msg.billNum + '</billNum>';\nparse1 = parse1 + '\\n' + ' </GetChargeRecipe>';\nparse1 = parse1 + '\\n' + ' </soap:Body>';\nparse1 = parse1 + '\\n' + '</soap:Envelope>';\nmsg.payload = parse1;\n\ndelete msg.site\ndelete msg.serial\nmsg.topic = \"\";\nreturn msg;\n\n//var testval = global.get(\"test\")||0;\n//msg.payload = testval;\n//return msg;\n\n\n\n\n\n\n\n\n\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":380,"y":260,"wires":[[]]},{"id":"bf1abdfc.b1d4e","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"payload.data[20]","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":200,"y":340,"wires":[["d74a4291.c4218"]]},{"id":"7cad4f22.cfc79","type":"comment","z":"e6693df7.a3cfa","name":"Read from Wago","info":"","x":120,"y":200,"wires":[]},{"id":"37855d95.4f6b3a","type":"comment","z":"e6693df7.a3cfa","name":"Get 20th array position for serial wrote ","info":"","x":150,"y":380,"wires":[]},{"id":"eb4f9416.32b32","type":"comment","z":"e6693df7.a3cfa","name":"Check if equal 1, fire get web service","info":"","x":280,"y":420,"wires":[]},{"id":"77b13775.67d7ac","type":"comment","z":"e6693df7.a3cfa","name":"need SN put back into string global SN","info":"","x":250,"y":100,"wires":[]},{"id":"aafbdb90.305bd8","type":"function","z":"e6693df7.a3cfa","name":"","func":"//msg.value = String.fromCharCode(...msg.payload.data)\n\n//return msg;\nlet arr = msg.payload.data;\narr.pop();\nmsg.value = String.fromCharCode(...arr)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":180,"y":140,"wires":[["3557e0ae.d936a"]]},{"id":"3557e0ae.d936a","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"SN","pt":"global","to":"value","tot":"msg"}],"action":"","property":"","from":"","to":"","reg":false,"x":330,"y":140,"wires":[[]]},{"id":"6aebd91.ca17728","type":"debug","z":"e6693df7.a3cfa","name":"1","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":630,"y":100,"wires":[]},{"id":"1182f01a.64e21","type":"comment","z":"e6693df7.a3cfa","name":"Get global SN ","info":"","x":370,"y":220,"wires":[]},{"id":"79d279fa.08fe18","type":"debug","z":"e6693df7.a3cfa","name":"3","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":950,"y":280,"wires":[]},{"id":"bcf8e8a3.96f408","type":"function","z":"e6693df7.a3cfa","name":"","func":"\n//global.set(\"CHARGEPERSYSTEM1\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM1)\n//global.set(\"CHARGEPERSYSTEM2\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM2)\n//global.set(\"CHARGEPERSYSTEM3\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM3)\n//global.set(\"CHARGEPERSYSTEM4\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM4)\n//global.set(\"CHARGEPERSYSTEM5\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM5)\n//global.set(\"CHARGEPERSYSTEM6\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM6)\n//global.set(\"CHARGEPERSYSTEM7\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM7)\n//global.set(\"CHARGEPERSYSTEM8\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetNamePlateInfoBySiteResponse.GetNamePlateInfoBySiteResult[\"diffgr:diffgram\"].DocumentElement.Data.CHARGEPERSYSTEM8)\n\n//global.set(\"CHARGEPERSYSTEM1\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill1Quantity)\n//global.set(\"CHARGEPERSYSTEM2\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill2Quantity)\n//global.set(\"CHARGEPERSYSTEM3\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill3Quantity)\n//global.set(\"CHARGEPERSYSTEM4\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill4Quantity)\n//global.set(\"CHARGEPERSYSTEM5\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill5Quantity)\n//global.set(\"CHARGEPERSYSTEM6\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill6Quantity)\n//global.set(\"CHARGEPERSYSTEM7\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill7Quantity)\n//global.set(\"CHARGEPERSYSTEM8\",msg.payload[\"soap:Envelope\"][\"soap:Body\"].GetChargeRecipeResponse.GetChargeRecipeResult.PresetFill8Quantity)\n\n\n\n\n//msg.CHARGEPERSYSTEM1 = global.get(\"CHARGEPERSYSTEM1\");\n//msg.CHARGEPERSYSTEM2 = global.get(\"CHARGEPERSYSTEM2\");\n//msg.CHARGEPERSYSTEM3 = global.get(\"CHARGEPERSYSTEM3\");\n//msg.CHARGEPERSYSTEM4 = global.get(\"CHARGEPERSYSTEM4\");\n//msg.CHARGEPERSYSTEM5 = global.get(\"CHARGEPERSYSTEM5\");\n//msg.CHARGEPERSYSTEM6 = global.get(\"CHARGEPERSYSTEM6\");\n//msg.CHARGEPERSYSTEM7 = global.get(\"CHARGEPERSYSTEM7\");\n//msg.CHARGEPERSYSTEM8 = global.get(\"CHARGEPERSYSTEM8\");\n\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":820,"y":280,"wires":[["79d279fa.08fe18"]]},{"id":"35187516.658fca","type":"debug","z":"e6693df7.a3cfa","name":"2","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":730,"y":180,"wires":[]},{"id":"dd225fc6.1380a","type":"change","z":"e6693df7.a3cfa","name":"","rules":[{"t":"set","p":"payload","pt":"msg","to":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetChargeRecipe xmlns=\"http://tempuri.org/\"> <serialNumber>' + global.get(\"SN\") + '</serialNumber> <site>AC</site> </GetChargeRecipe> </soap:Body> </soap:Envelope>","tot":"str"},{"t":"set","p":"topic","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":960,"y":520,"wires":[[]]},{"id":"2c48206b.b7cbd","type":"function","z":"e6693df7.a3cfa","name":"","func":"delete msg.values\ndelete msg.input\ndelete msg.sendingNodeId\ndelete msg.payload\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":460,"y":580,"wires":[["ab242c2d.571b5"]]},{"id":"ab242c2d.571b5","type":"function","z":"e6693df7.a3cfa","name":"","func":"let SN = global.get(\"SN\");\nnode.warn(`SN: ${SN}`)\nmsg.payload = `<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetChargeRecipe xmlns=\"http://tempuri.org/\"> <serialNumber>${SN}</serialNumber> <site>AC</site> </GetChargeRecipe> </soap:Body> </soap:Envelope>`\n//msg.topic = \"\";\ndelete msg.topic;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":590,"y":680,"wires":[["5e9306a5.d58558","6aebd91.ca17728"]]},{"id":"5e9306a5.d58558","type":"simple-soap","z":"e6693df7.a3cfa","host":"http://172.16.17.6:8090/ChargeWs/ChargeService.asmx","hostType":"str","path":"","pathType":"str","action":"http://tempuri.org/GetChargeRecipe","actionType":"str","body":"payload","bodyType":"msg","mustache":false,"attrkey":"$","charkey":"_","stripPrefix":false,"simplify":false,"normalizeTags":false,"normalize":true,"topic":"","name":"GetChargeData","useAuth":false,"x":580,"y":240,"wires":[["35187516.658fca"]]},{"id":"295f120e.cf468e","type":"inject","z":"e6693df7.a3cfa","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"<?xml version=\"1.0\" encoding=\"utf-8\"?> <soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"> <soap:Body> <GetChargeRecipe xmlns=\"http://tempuri.org/\"> <serialNumber>BVGJ01315</serialNumber> <site>AC</site> </GetChargeRecipe> </soap:Body> </soap:Envelope>","payloadType":"str","x":510,"y":160,"wires":[[]]},{"id":"d02d7ba5.e52e38","type":"status","z":"e6693df7.a3cfa","name":"","scope":["5e9306a5.d58558"],"x":880,"y":180,"wires":[["f17b359e.36d678"]]},{"id":"7664fec.47c89","type":"catch","z":"e6693df7.a3cfa","name":"","scope":["5e9306a5.d58558"],"uncaught":false,"x":870,"y":220,"wires":[["81df803a.5a017"]]},{"id":"f17b359e.36d678","type":"debug","z":"e6693df7.a3cfa","name":"StatusDebug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":180,"wires":[]},{"id":"81df803a.5a017","type":"debug","z":"e6693df7.a3cfa","name":"CatchDebug","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1030,"y":220,"wires":[]},{"id":"5410cb45.9afa3c","type":"modbus-client","z":"","name":"WAGO","clienttype":"tcp","bufferCommands":true,"stateLogEnabled":false,"queueLogEnabled":false,"tcpHost":"localhost","tcpPort":"503","tcpType":"DEFAULT","serialPort":"/dev/ttyUSB","serialType":"RTU-BUFFERD","serialBaudrate":"9600","serialDatabits":"8","serialStopbits":"1","serialParity":"none","serialConnectionDelay":"100","unit_id":"1","commandDelay":"1","clientTimeout":"1000","reconnectOnTimeout":true,"reconnectTimeout":"2000","parallelUnitIdsAllowed":true}]

```

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/c/6c5d7b656f0c562e8dea7b65faf2ef186630ad5f.png)

---

<div class="post-metadata">

**Author:** ![jeffreys](https://avatars.discourse-cdn.com/v4/letter/j/96bed5/32.png) [@jeffreys](https://discourse.nodered.org/u/jeffreys)\
**Post date:** [13 October 2020 16:07 UTC](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149/44 "2020-10-13T16:07:10Z")

</div>

When i replaced the ` with ' around the xml in the function, it worked

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/f/0/f05b1f8ddb67680704bde3622c30f75b209a5c22.png)

[Previous page](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149.md?page=1)

[Next page](https://discourse.nodered.org/t/trying-to-get-data-from-ascii-to-a-string/34149.md?page=3)
