# Inject works to send to a SOAP web service but the same payload from a function doesnt?

**URL:** <https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194>\
**Category:** General\
**Created:** [13 October 2020 18:41 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194 "2020-10-13T18:41:50Z")\
**Posts on this page:** 20\
**Page:** 1

<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 18:41 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/1 "2020-10-13T18:41:50Z")

</div>

If I wire up the inject to the purple GetChargeData it works.

If I wire up the function to the GetChargeData it does NOT work even tho the strings are the same as seen in the debug window. The top one is the inject and the bottom is the function wired in. Same payload...??

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

```auto
[{"id":"e6693df7.a3cfa","type":"tab","label":"Flow 4","disabled":false,"info":""},{"id":"eb571ded.e53f3","type":"modbus-read","z":"e6693df7.a3cfa","d":true,"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":[["ab242c2d.571b5"],[]]},{"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 + ' <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 + ' <soap:Header>';\n//parse1 = parse1 + ' <SoapSettings xmlns=\"http://tempuri.org/\">';\n//parse1 = parse1 + ' <IsTest>false</IsTest>';\n//parse1 = parse1 + ' <ApplicationID>105B9760-A4A0-4659-BE09-2B6F64980DBD</ApplicationID>';\n//parse1 = parse1 + ' <ApplicationKey>C565C1F9-A326-4754-B654-CFA059865820</ApplicationKey>';\n//parse1 = parse1 + '\\n' + ' </SoapSettings>';\n//parse1 = parse1 + '\\n' + ' </soap:Header>';\nparse1 = parse1 + ' <soap:Body>'\nparse1 = parse1 + ' <GetChargeRecipe xmlns=\"http://tempuri.org/\">';\nparse1 = parse1 + ' <serialNumber>' + global.get(\"SN\") + '</serialNumber>';\nparse1 = parse1 + ' <site>' + msg.site + '</site>';\n//parse1 = parse1 + '\\n' + ' <billNum>' + msg.billNum + '</billNum>';\nparse1 = parse1 + ' </GetChargeRecipe>';\nparse1 = parse1 + ' </soap:Body>';\nparse1 = parse1 + ' </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":740,"y":820,"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":570,"y":420,"wires":[]},{"id":"1182f01a.64e21","type":"comment","z":"e6693df7.a3cfa","name":"Get global SN ","info":"","x":750,"y":780,"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":1110,"y":780,"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":980,"y":780,"wires":[["79d279fa.08fe18"]]},{"id":"35187516.658fca","type":"debug","z":"e6693df7.a3cfa","name":"2","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":770,"y":420,"wires":[]},{"id":"ab242c2d.571b5","type":"function","z":"e6693df7.a3cfa","name":"","func":"delete msg.values\ndelete msg.input\ndelete msg.sendingNodeId\ndelete msg.payload\n\nvar temp\n\nlet SN = global.get(\"SN\");\n//node.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\n///////////msg.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>'\n\n//msg.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\nmsg.topic = `${SN}`;\n//delete msg.topic;\nreturn msg;\n\n","outputs":1,"noerr":0,"initialize":"","finalize":"","x":540,"y":340,"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":760,"y":340,"wires":[["35187516.658fca"]]},{"id":"d02d7ba5.e52e38","type":"status","z":"e6693df7.a3cfa","name":"","scope":["5e9306a5.d58558"],"x":940,"y":320,"wires":[["f17b359e.36d678"]]},{"id":"7664fec.47c89","type":"catch","z":"e6693df7.a3cfa","name":"","scope":["5e9306a5.d58558"],"uncaught":false,"x":930,"y":360,"wires":[["81df803a.5a017"]]},{"id":"f17b359e.36d678","type":"debug","z":"e6693df7.a3cfa","name":"StatusDebug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":320,"wires":[]},{"id":"81df803a.5a017","type":"debug","z":"e6693df7.a3cfa","name":"CatchDebug","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","statusVal":"","statusType":"auto","x":1090,"y":360,"wires":[]},{"id":"e179e11d.f2402","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":550,"y":280,"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:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 October 2020 20:16 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/2 "2020-10-13T20:16:02Z")

</div>

Would you give this a go (I cant test it as I dont have access to your data)

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

```auto
[{"id":"eb571ded.e53f3","type":"modbus-read","z":"e6693df7.a3cfa","d":true,"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":[[],["d74a4291.c4218"]]},{"id":"d74a4291.c4218","type":"switch","z":"e6693df7.a3cfa","name":"check payload.data[20] == 1","property":"payload.data[20]","propertyType":"msg","rules":[{"t":"eq","v":"1","vt":"num"},{"t":"neq","v":"1","vt":"num"}],"checkall":"false","repair":false,"outputs":2,"x":360,"y":240,"wires":[["aafbdb90.305bd8"],[]]},{"id":"7cad4f22.cfc79","type":"comment","z":"e6693df7.a3cfa","name":"Read from Wago","info":"","x":120,"y":200,"wires":[]},{"id":"eb4f9416.32b32","type":"comment","z":"e6693df7.a3cfa","name":"Check [20] equal 1, fire get web service","info":"","x":390,"y":200,"wires":[]},{"id":"aafbdb90.305bd8","type":"function","z":"e6693df7.a3cfa","name":"set msg.sn","func":"//msg.value = String.fromCharCode(...msg.payload.data)\n\n//return msg;\nlet arr = msg.payload.data;\narr.pop();\nmsg.sn = String.fromCharCode(...arr)\nreturn msg;","outputs":1,"noerr":0,"initialize":"","finalize":"","x":410,"y":300,"wires":[["84045926.394098"]]},{"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":670,"y":240,"wires":[]},{"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":930,"y":240,"wires":[]},{"id":"d02d7ba5.e52e38","type":"status","z":"e6693df7.a3cfa","name":"","scope":["5e9306a5.d58558"],"x":100,"y":500,"wires":[["f17b359e.36d678"]]},{"id":"7664fec.47c89","type":"catch","z":"e6693df7.a3cfa","name":"","scope":null,"uncaught":false,"x":100,"y":540,"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":250,"y":500,"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":250,"y":540,"wires":[]},{"id":"e179e11d.f2402","type":"inject","z":"e6693df7.a3cfa","name":"test envelope","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":650,"y":360,"wires":[["5e9306a5.d58558"]]},{"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":900,"y":300,"wires":[["35187516.658fca"]]},{"id":"84045926.394098","type":"template","z":"e6693df7.a3cfa","name":"make envelope","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n <soap:Body>\n <GetChargeRecipe xmlns=\"http://tempuri.org/\">\n <serialNumber>{{sn}}</serialNumber>\n <site>AC</site>\n </GetChargeRecipe>\n </soap:Body>\n</soap:Envelope>","output":"str","x":640,"y":300,"wires":[["5e9306a5.d58558","6aebd91.ca17728"]]},{"id":"fe3956b0.b5b558","type":"inject","z":"e6693df7.a3cfa","name":"msg.sn = BVGJ01315","props":[{"p":"sn","v":"BVGJ01315","vt":"str"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","x":380,"y":360,"wires":[["84045926.394098"]]},{"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}]

```

check the output of debug `1` when it is fired by the modbus node VS the inject node.

(hopefully I havent completely ruined your flow 😃 )

---

<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 20:19 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/3 "2020-10-13T20:19:44Z")

</div>

Thanks you for trying! I am really stuck here. It looks like it is doing the same thing. The payload is still null in debug 2

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/7/57baff29953319564ea1a46a8a08fc1527627e05.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 October 2020 20:22 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/4 "2020-10-13T20:22:20Z")

</div>

> [@jeffreys](#):
>
> It looks like it is doing the same thing

What is that?

Does the inject route work but the modbus route not 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 20:25 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/5 "2020-10-13T20:25:57Z")

</div>

Debug 1 payload seems to have the proper string but when I send the exact same string in with anything other than a inject, I dont get anything but null back for debug 2 payload.

It should have all sorts of data in there. I have compared the inject string and the payload string in word with formatting on. Exact same except for some spaces, which I have tried removing also.

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/4/54e4a57a979725facea051c00ea98408a0b2668a.png)

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 October 2020 20:28 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/6 "2020-10-13T20:28:50Z")

</div>

So the only differnece I can see is that other properties are present in the `msg` going into the `soap` node. Lets rule that out.

Open the function named `set msg.sn` and replace all code with this...

```auto
let arr = msg.payload.data;
arr.pop();
let sn = String.fromCharCode(...arr)
return {sn:sn};

```

see how that performs

EDIT

Sorry your answer wasnt 100% clear please answer...

- Did it work when clicking the INJECT called "msg.sn = BVGJ01315"?
- Did it work when clicking the INJECT called "test envelope"?

---

<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 20:35 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/7 "2020-10-13T20:35:59Z")

</div>

> [@Steve-Mcl](#):
>
> ```auto
> let arr = msg.payload.data;
> arr.pop();
> let sn = String.fromCharCode(...arr)
> return {sn:sn};
> 
> ```

Same as shown in pic with this code. Still null. I used delete msg.x to remove the stuff before when i was playing around and it didnt help either.

Yes it works with the inject msg.sn = bvg...

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

and yes the second inject worked also

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/f/2f854271a2a36759328ecb7901c771d727ab3d3b.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 20:42 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/8 "2020-10-13T20:42:06Z")

</div>

Feed both strings into a function node containing  
`msg.payload = msg.payload.length`  
`return msg`  
and feed into another debug node. Check the two strings give the same number.

Do the status or catch nodes show anything if linked to the soap node?

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 October 2020 20:42 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/9 "2020-10-13T20:42:09Z")

</div>

> [@Steve-Mcl](#):
>
> `let sn = String.fromCharCode(...arr)`

can you capture debug `1` and debug `2` for all 3 operations (modbus, inject1 and inject2).

click the copy button that appears under your cursor when you hover in the debug window msg and paste them in a reply

modbus - debug 1...  
`````  
`paste debug copied data`  
`````  
modbus - debug 2...  
`````  
`paste debug copied data`  
`````

etc etc

---

<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 20:46 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/10 "2020-10-13T20:46:51Z")

</div>

Not quite sure what you want me to do. Both strings?

The catch and status never showed anything different between the two that I saw. About to call it for the day but I really appreciate the help. There is something different about the inject vs the function

---

<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 20:50 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/11 "2020-10-13T20:50:31Z")

</div>

Like this or am i messing up how to put the results on here

Modbus 1

```auto
{"sn":"BVGJ01315\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","_msgid":"890ac4d8.ee4b88","payload":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n <soap:Body>\n <GetChargeRecipe xmlns=\"http://tempuri.org/\">\n <serialNumber>BVGJ01315\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000</serialNumber>\n <site>AC</site>\n </GetChargeRecipe>\n </soap:Body>\n</soap:Envelope>"}

```

Modbus 2

```auto
{"sn":"BVGJ01315\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000\u0000","_msgid":"890ac4d8.ee4b88","payload":null,"topic":""}

```

msg.sn = 1

```auto
{"_msgid":"9750c0ed.21f2f","sn":"BVGJ01315","topic":"","payload":"<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<soap:Envelope xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\">\n <soap:Body>\n <GetChargeRecipe xmlns=\"http://tempuri.org/\">\n <serialNumber>BVGJ01315</serialNumber>\n <site>AC</site>\n </GetChargeRecipe>\n </soap:Body>\n</soap:Envelope>"}

```

msg.sn= 2

```auto
{"_msgid":"9750c0ed.21f2f","sn":"BVGJ01315","topic":"","payload":{"soap:Envelope":{"$":{"xmlns:soap":"http://schemas.xmlsoap.org/soap/envelope/","xmlns:xsi":"http://www.w3.org/2001/XMLSchema-instance","xmlns:xsd":"http://www.w3.org/2001/XMLSchema"},"soap:Body":{"GetChargeRecipeResponse":{"$":{"xmlns":"http://tempuri.org/"},"GetChargeRecipeResult":{"RevisionNumber":"0","PresetToolEvacuationTime":"0","PresetToolEvacuationLevel":"0","PresetVacuumCheckTime":"0","PresetVacuumCheckLevel":"0","PresetRejectEvacuationTime":"0","PresetRejectEvacuationLevel":"0","PresetLeakCheckLevel":"0","PresetLeakCheckTime":"0","PresetFill1Quantity":"1392","PresetFill2Quantity":"1392","PresetFill3Quantity":"0","PresetFill4Quantity":"0","PresetFill5Quantity":"0","PresetFill6Quantity":"0","PresetFill7Quantity":"0","PresetFill8Quantity":"0","PresetReclaimTime":"0","ErrorMessage":"Did not find a charge recipe for the given feature string.","ModelID":"0"}}}}}}

```

---

<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 20:50 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/12 "2020-10-13T20:50:55Z")

</div>

> [@jeffreys](#):
>
> Not quite sure what you want me to do. Both strings?

The failing one from the function node and the working one from the inject, that are supposed to be identical. Check the length to make sure there aren't any extra unprintable characters in there.

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 October 2020 20:51 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/13 "2020-10-13T20:51:02Z")

</div>

> [@jeffreys](#):
>
> `{"sn":"BVGJ01315\u0000\u0000\u0000\u0000\u0000\`

This is the problem.

---

<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 20:51 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/14 "2020-10-13T20:51:30Z")

</div>

k will pick up here tomorrow

---

<div class="post-metadata">

**Author:** ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)\
**Post date:** [13 October 2020 20:52 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/15 "2020-10-13T20:52:49Z")

</div>

In your other thread, I suggested you use buffer-parser - it takes care of all this kind of thing.

to clean up the `sn` you need to do soething like...

```auto
let arr = msg.payload.data;
arr.pop();
let sn = String.fromCharCode(...arr)
sn = sn.replace(/\0.*$/g,'');
return {sn:sn}

```

---

<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 20:52 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/16 "2020-10-13T20:52:59Z")

</div>

Note that, in the original thread, I did ask you to show us the strings in the way Steve has asked, but you ignored or did not notice that request.

---

<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 20:54 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/17 "2020-10-13T20:54:12Z")

</div>

BOOYAHHHHH nice work. I think that did it. I will verify more tomorrow!!!

---

<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 20:54 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/18 "2020-10-13T20:54:38Z")

</div>

Im sorry Colin. I really appreciate the help. I must have missed it. My bad

---

<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:** [14 October 2020 15:05 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/20 "2020-10-14T15:05:41Z")

</div>

``````auto
{"topic":"polling","payload":{"value":{"data":[66,86,71,74,48,49,51,49,53,0,0,0,0,0,0,0,0,0,0,0,1],"buffer":[0,66,0,86,0,71,0,74,0,48,0,49,0,51,0,49,0,53,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1]},"fc":16,"unitid":1,"address":100,"quantity":21},"values":[66,86,71,74,48,49,51,49,53,0,0,0,0,0,0,0,0,0,0,0,1],"input":{"topic":"polling","from":"","payload":{"unitid":"1","fc":3,"address":"0","quantity":"21","messageId":"5f871369467073c0b56f755c"},"queueLengthByUnitId":{"unitId":1,"queueLength":0},"queueUnitId":1,"unitId":1},"sendingNodeId":"bd3907b4.5700e8","_msgid":"2dd0f2dd.68064e"}`````
``````

---

<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:** [14 October 2020 15:07 UTC](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194/21 "2020-10-14T15:07:40Z")

</div>

This is good plc modbus write

```auto
{"value":[66,86,71,74,48,49,51,49,53,0,0,0,0,0,0,0,0,0,0,0,1],"fc":16,"unitid":1,"address":100,"quantity":21}

```

[Next page](https://discourse.nodered.org/t/inject-works-to-send-to-a-soap-web-service-but-the-same-payload-from-a-function-doesnt/34194.md?page=2)
