How do I Concatenate an XML String in Structured Text

theColonel26

Lifetime Supporting Member
Join Date
Feb 2014
Location
West Michigan
Posts
784
How do I Concatenate an XML String in Structured Text?
I am using codesys 2.3 with a Wago 750-852. I would expect the answer to be the same regardless of brand.

Here is what I need to concatenate

Code:
<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
  <s:Header>
    <Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IService/receiveHeartbeat</Action>
  </s:Header>
  <s:Body>
    <receiveHeartbeat xmlns="http://tempuri.org/">
      <reader>
Code:
*Word Variable*
Code:
</reader>
    </receiveHeartbeat>
  </s:Body>
</s:Envelope>
 
I think I have found a solution. I don't like it though. It's not very clean.

Code:
Reader_ID: STRING := '0';
	msg: STRING(500);
	Msg1: STRING(250) := '<s:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/"><s:Header>';
	Msg2: STRING(250) := '<Action s:mustUnderstand="1" xmlns="http://schemas.microsoft.com/ws/2005/05/addressing/none">http://tempuri.org/IService/receiveHeartbeat</Action>';
	Msg3: STRING := '</s:Header><s:Body><receiveHeartbeat xmlns="http://tempuri.org/"><reader>';
	MsgAfter: STRING := '</reader></receiveHeartbeat></s:Body></s:Envelope>';

Code:
msg := CONCAT(Msg1,Msg2);
msg := CONCAT(msg,Msg3);
msg := CONCAT(msg,Reader_ID);
msg := CONCAT(msg,MsgAfter);

It seems that string sizes are limited to 500 characters. Since the point of this is to create an XML message to send via HTTP. What happens when my messages inevitably get larger than 500 character. I am using the WagoLibHttp_02 library for http.
 
Hi
I would say your 500 character limit is a limitation that is going to stop you doing what you want to achieve within the PLC

Typically for more advance things the system would have an HMI/SCADA PC that would have more chance of doing what you want

Unless you can work out a method of sending strings and then rebuilding them at the other end
 
well colonel you are correct it is indeed 511, have you looked at oscat.de for other types of communication, you can put messages in an array for instance.
 
well colonel you are correct it is indeed 511, have you looked at oscat.de for other types of communication, you can put messages in an array for instance.

As far as I can tell the oscat network library (codesys_network_121_hf1.lib) only has functions for http_get not post.

I can't find a version of the basic library that is for codesys 2.3, only 3.
 
Last edited:

Similar Topics

Hello All, I have a little problem that I need some help with. I have got a 17 digit number coming from a supplier. It's basically a barcode...
Replies
11
Views
3,035
Hi, I have a list selector which I want to display the recipe found inside a plc-5. The recipe is store in an ascii table with each character...
Replies
4
Views
1,404
I am trying to concatenate two INTs into one DINT I have try following Knowledgebase Article 552006 but I am not having any luck. I have found...
Replies
6
Views
3,056
Hi all, I have trouble compiling the following simple Cicode function in Citect V7.0r1. Compiling gives the error "Operand expected". FUNCTION...
Replies
1
Views
3,910
I have an existing program for a machine which can run 50+ different parts. Each part has 10 parameters allocated and I have to modify the program...
Replies
1
Views
1,768
Back
Top Bottom