NetTalk Central

Author Topic: how to emulate xml message request and response to customer  (Read 3969 times)

lanmicro

  • Full Member
  • ***
  • Posts: 112
    • View Profile
    • Email
I need to emulate the following XML message receipt from my customer. 
The part that has me stumped is the <UCAPOSMessage...> before the <CustomerQuery> tag.  How can I read that part of the message and include that information in my WebServer documentation?

I will also need to send similar information out in the response.  I hope once I know how to receive it the how to send it will be similar.

<?xml version="1.0" encoding="UTF-8"?>
<UCAPOSMessage version="1.0.0.0" Service="POSAccountInquiry" MessageStatus="Pending" MessageID="1" MessageSentDate="2015-05-26T15:05:23" SoftwareVersionNumber="1000" registerID="21">
   <CustomerQuery>
      <StoreID>1234</StoreID>
      <CashierID>1958094</CashierID>
      <TranDate>2015-04-25</TranDate>
      <TranTime>10:32</TranTime>
      <CustomerNumber>1234567890123</CustomerNumber>
   </CustomerQuery>
</UCAPOSMessage>
Gregory C. Bailey

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: how to emulate xml message request and response to customer
« Reply #1 on: June 05, 2015, 12:43:10 PM »
Sorry for the copy paste, hope this helps
From Capesoft XFiles Documents

Attributes
XML allows attributes to be assigned to a tag. For example;
<xml>
    <server protocol="http">www.capesoft.com</server>
    <port>80</port>
</xml>

This is equivalent to;
<xml>
    <server>www.capesoft.com</server>
    <protocol>http</protocol>
    <port>80</port>
</xml>

xFiles parses incoming attributes exactly as if they were tags. So the group for the above would be
Whatever    Group
Protocol      String(10)
Server        String(80),Name('web-server')
Port          Long,Name('web-port')
            End

TIP: The order of the fields in the group is not important, except in the case where multiple fields have the same external name.
TIP: For more on Creating XML that contains attributes, see here.

http://capesoft.com/docs/xFiles/xfiles.htm#SavingFieldsAsAttributes

lanmicro

  • Full Member
  • ***
  • Posts: 112
    • View Profile
    • Email
Re: how to emulate xml message request and response to customer
« Reply #2 on: June 09, 2015, 09:26:40 AM »
Hi Urayon,

Thanks for the response.  I got it to work except for the information in the "MessageSentDate" attribute.

When the data is "2015-05-26T15:05:23" the group starts with "23

When the data is changed to "2015-05-26T15.05.23"  the entire group is shown.  Is there something about : that causes this to fail?
Gregory C. Bailey

urayoan

  • Full Member
  • ***
  • Posts: 222
    • View Profile
    • AZ Rock Radio
Re: how to emulate xml message request and response to customer
« Reply #3 on: June 10, 2015, 10:21:47 AM »
My guess, maybe related with Replace colon in field name with a dot at XFiles template?

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11192
    • View Profile
Re: how to emulate xml message request and response to customer
« Reply #4 on: June 10, 2015, 10:22:59 PM »
Hi Greg,

>> When the data is "2015-05-26T15:05:23" the group starts with "23

My first instinct is to blame replace prefix, but prefixes are in _tags_ not _data_ so that doesn't seem right.

I think you need to post a small example showing the data structures and code you are using Greg so I can duplicate here.

cheers
Bruce


lanmicro

  • Full Member
  • ***
  • Posts: 112
    • View Profile
    • Email
Re: how to emulate xml message request and response to customer
« Reply #5 on: June 11, 2015, 07:00:40 AM »
Hi Bruce,

I updated Xfiles.  Last installed in Feb 2015.  Did not fix problem.

I updated StringTheory.  Last installed in Apr 2015.  Fixed problem.

So some combination of Xfiles and StringTheory update solves this.
Gregory C. Bailey

lanmicro

  • Full Member
  • ***
  • Posts: 112
    • View Profile
    • Email
Re: how to emulate xml message request and response to customer
« Reply #6 on: June 11, 2015, 09:27:49 AM »
Hi Bruce,

Spoke too soon.  Bad test. 

Here is the debug output when the : is used in the MessageSentDate attribute of <UCAPOSMessage>

[3648] <UCAPOSMessage version="1.0.0.0" Service="POSTranNotification" MessageStatus="Pending" MessageID="1" MessageSentDate="2015-05-26T15:05:23" SoftwareVersionNumber="1000" registerID="21">
[3648]  <ChargeTran>
[3648]   <StoreID>0160</StoreID>
[3648]   <CashierID>1958094</CashierID>
[3648]   <TranDate>2015-04-25</TranDate>
[3648]   <TranTime>10:32</TranTime>
[3648]   <TranNumber>1234</TranNumber>
[3648]   <CustomerNumber>016085490</CustomerNumber>
[3648]   <TranTotal>-14.30</TranTotal>
[3648]   <TranType>Sale</TranType>
[3648]   <TranDetail>
[3648]              <Items>
[3648]    <Item>
[3648]     <ItemCode>2</ItemCode>
[3648]                   <ItemDesc>WRITE OFF CHGS/WRONG PERSON</ItemDesc>
[3648]     <ItemAmount>-14.30</ItemAmount>
[3648]     <ItemQty>1</ItemQty>
[3648]    </Item>     
[3648]        </Items>
[3648]           </TranDetail>
[3648]          </ChargeTran>
[3648] </UCAPOSMessage>
[3648] 
[3648] ]
[3648] [NetDLL] [2] CallBackWindowClientCallBack() :  Count=1 p_wMsg = 6217 wParam = 488 (lParam = 2) = Loc:WSAGetSelect.Err = 0 & Loc:WSAGetSelect.Event = 2. p_hWnd = 459796
[3648] [NetDLL] [2] SimpleClient_Async() : FD_WRITE  Socket = 488 SockID = 38 Err = 0
[3648] [NetDLL] [2] SimpleClientWrite() : Nothing to do for this Socket. records (qSimpleOutList) = 0
[3648] [NetDLL] [2] SimpleClientWrite() : Number of writes = 0  records (qSimpleOutList) = 0
[3648] [NetDLL] [2] CallBackWindowClientCallBack() : End of Function - will Return (1)
[3648] [NetDLL] [4] SimpleClientSend() : Sending packet to Server = 127.0.0.1 Socket = 488 SockID = 38
[3648] [NetDLL] [4] lookupSimpleClientSocket() : IP = 127.0.0.1 Socket = 488 SockID = 38
[3648] [NetDLL] [4] SimpleClientWrite() : Whole packet sent  SimplePacketID = 38 Bytes sent now = 1067 Bytes sent total of this packet = 1067
[3648] [NetDLL] [4] SimpleClientWrite() : Nothing to do for this Socket. records (qSimpleOutList) = 0
[3648] [NetDLL] [4] SimpleClientWrite() : Number of writes = 1  records (qSimpleOutList) = 0
[1864] [st] [netTalk][thread=3] UCAPOSMessage Group=
[1864] [st] [netTalk][thread=3] StoreID =160
[1864] [st] [netTalk][thread=3] CashierID =1958094
[1864] [st] [netTalk][thread=3] TranDate =2015-04-25
[1864] [st] [netTalk][thread=3] TranTime =10:32
[1864] [st] [netTalk][thread=3] TranNumber =1234
[1864] [st] [netTalk][thread=3] CustomerNumber =016085490
[1864] [st] [netTalk][thread=3] TranTotal =-14.30
[1864] [st] [netTalk][thread=3] TranType =Sale
[1864] [st] [netTalk][thread=3] Item Records=1
[1864] [st] [netTalk][thread=3] Tax Records=0
[1864] [st] [netTalk][thread=3] Tender Records=0

Here is the debug output when the a . is used in the MessageSentDate attribute of <UCAPOSMessage>

[3648] <UCAPOSMessage version="1.0.0.0" Service="POSTranNotification" MessageStatus="Pending" MessageID="1" MessageSentDate="2015-05-26T15.05.23" SoftwareVersionNumber="1000" registerID="21">
[3648]  <ChargeTran>
[3648]   <StoreID>0160</StoreID>
[3648]   <CashierID>1958094</CashierID>
[3648]   <TranDate>2015-04-25</TranDate>
[3648]   <TranTime>10:32</TranTime>
[3648]   <TranNumber>1234</TranNumber>
[3648]   <CustomerNumber>016085490</CustomerNumber>
[3648]   <TranTotal>-14.30</TranTotal>
[3648]   <TranType>Sale</TranType>
[3648]   <TranDetail>
[3648]              <Items>
[3648]    <Item>
[3648]     <ItemCode>2</ItemCode>
[3648]                   <ItemDesc>WRITE OFF CHGS/WRONG PERSON</ItemDesc>
[3648]     <ItemAmount>-14.30</ItemAmount>
[3648]     <ItemQty>1</ItemQty>
[3648]    </Item>     
[3648]        </Items>
[3648]           </TranDetail>
[3648]          </ChargeTran>
[3648] </UCAPOSMessage>
[3648] 
[3648] ]
[3648] [NetDLL] [2] CallBackWindowClientCallBack() : loc:ret = 0
[3648] [NetDLL] [4] SimpleClientSend() : Sending packet to Server = 127.0.0.1 Socket = 468 SockID = 39
[3648] [NetDLL] [4] lookupSimpleClientSocket() : IP = 127.0.0.1 Socket = 468 SockID = 39
[3648] [NetDLL] [4] SimpleClientWrite() : Whole packet sent  SimplePacketID = 39 Bytes sent now = 1067 Bytes sent total of this packet = 1067
[3648] [NetDLL] [4] SimpleClientWrite() : Nothing to do for this Socket. records (qSimpleOutList) = 0
[3648] [NetDLL] [4] SimpleClientWrite() : Number of writes = 1  records (qSimpleOutList) = 0
[3648] [NetDLL] [2] CallBackWindowClientCallBack() :  Count=1 p_wMsg = 6218 wParam = 468 (lParam = 2) = Loc:WSAGetSelect.Err = 0 & Loc:WSAGetSelect.Event = 2. p_hWnd = 459796
[3648] [NetDLL] [2] SimpleClient_Async() : FD_WRITE  Socket = 468 SockID = 39 Err = 0
[3648] [NetDLL] [2] SimpleClientWrite() : Nothing to do for this Socket. records (qSimpleOutList) = 0
[3648] [NetDLL] [2] SimpleClientWrite() : Number of writes = 0  records (qSimpleOutList) = 0
[3648] [NetDLL] [2] CallBackWindowClientCallBack() : End of Function - will Return (1)
[1864] [st] [netTalk][thread=3] UCAPOSMessage Group=1.0.0.0                                                     POSTranNotification                                         Pending                                                     1                                                           2015-05-26T15.05.23                                         1000                                                        21
[1864] [st] [netTalk][thread=3] StoreID =160
[1864] [st] [netTalk][thread=3] CashierID =1958094
[1864] [st] [netTalk][thread=3] TranDate =2015-04-25
[1864] [st] [netTalk][thread=3] TranTime =10:32
[1864] [st] [netTalk][thread=3] TranNumber =1234
[1864] [st] [netTalk][thread=3] CustomerNumber =016085490
[1864] [st] [netTalk][thread=3] TranTotal =-14.30
[1864] [st] [netTalk][thread=3] TranType =Sale
[1864] [st] [netTalk][thread=3] Item Records=1
[1864] [st] [netTalk][thread=3] Tax Records=0
[1864] [st] [netTalk][thread=3] Tender Records=0

You can see that UCAPOSMessage Group is blank when the : is used and has parameters found when the . is used. 

The XML data structure is shown above.  If you need anything else holler.
Gregory C. Bailey

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11192
    • View Profile
Re: how to emulate xml message request and response to customer
« Reply #7 on: June 17, 2015, 02:11:53 AM »
I'm not seeing too much from the log Greg, I think if you can post a small example app that shows the effect then I can look a bit closer ...

Cheers
Bruce

lanmicro

  • Full Member
  • ***
  • Posts: 112
    • View Profile
    • Email
Re: how to emulate xml message request and response to customer
« Reply #8 on: June 17, 2015, 07:34:41 AM »
Hi Bruce,

Here is an example app and dictionary.  The example doesn't use any files to make it simple.

Here is the xml that is received.

<UCAPOSMessage version="1.0.0.0" Service="POSTranNotification" MessageStatus="Pending" MessageID="1" MessageSentDate="2015-05-26T15:05:23" SoftwareVersionNumber="1000" registerID="21">
   <ChargeTran>
      <StoreID>0160</StoreID>
      <CashierID>1958094</CashierID>
      <TranDate>2015-04-25</TranDate>
      <TranTime>10:32</TranTime>
      <TranNumber>1234</TranNumber>
      <CustomerNumber>016085490</CustomerNumber>
      <TranTotal>-14.30</TranTotal>
      <TranType>Sale</TranType>
      <TranDetail>
               <Items>
         <Item>
            <ItemCode>2</ItemCode>
                      <ItemDesc>WRITE OFF CHGS/WRONG PERSON</ItemDesc>
            <ItemAmount>-14.30</ItemAmount>
            <ItemQty>1</ItemQty>
         </Item>            
           </Items>
            </TranDetail>
         </ChargeTran>
</UCAPOSMessage>



[attachment deleted by admin]
Gregory C. Bailey

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11192
    • View Profile
Re: how to emulate xml message request and response to customer
« Reply #9 on: June 18, 2015, 11:05:10 PM »
Hi Greg,
 
The bug was in the StringTheory method, RemoveXMLPrefixes. I've fixed that and uploaded build 2.28.
Thanks for the example.

Your use of OMIT in the method is concerning. I suspect there are better ways to get what you need, and ultimately that will be much better for you from a forward-compatibility point of view. Rather then resort to manually constructing the reply, it might be better to describe what difference you need, and maybe there's a property of something you can set to get that.

Cheers
Bruce