Author |
Message
|
paulobugmann |
Posted: Fri Jul 27, 2018 12:36 pm Post subject: Help with XMLNSC message |
|
|
Newbie
Joined: 27 Jul 2018 Posts: 5
|
I have a system sending a message via httpinput. I need to retrieve the value of the OperationCode tag, however my system is including the xml with scape within the xmlMessage tag.
<?xml version="1.0" encoding="utf-8"?><soap:Envelope><soap:Body><ProcessMessage><xmlMessage><?xml version="1.0" encoding="utf-8"?>
<FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.WriteTransactionHistory>
<SessionContext>
<EmployeeID>1</EmployeeID>
<EmployeeNo>ADMIN</EmployeeNo>
<OperationCode>ProductionOrder.StatusChange.OUT</OperationCode>
</SessionContext>
<FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.TransactionName >
<TransactionName>POStatusChange</TransactionName>
</FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.TransactionName>
</FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.WriteTransactionHistory></xmlMessage><applicationName>WebMethodAdapter</applicationName></ProcessMessage></soap:Body></soap:Envelope>
I need some help, to recover the value of the OperationCode tag via ESQL. |
|
Back to top |
|
 |
timber |
Posted: Fri Jul 27, 2018 1:50 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
You are receiving two separate XML documents. The inner document is just a text value within the outer document. Your message flow needs to parse the inner document (convert it from a string to a message tree).
There are lots of examples in this forum showing how to do this. You will need a CREATE statement with a PARSE clause, and you should specify DOMAIN('XMLNSC').
Tip: You don't actually need to convert the CHARACTER string into a BLOB before you pass it into the CREATE...PARSE statement. I'm fairly sure that IIB will do that for you. |
|
Back to top |
|
 |
paulobugmann |
Posted: Tue Jul 31, 2018 5:48 am Post subject: |
|
|
Newbie
Joined: 27 Jul 2018 Posts: 5
|
Thanks for the support.
I tested it in many ways, but it still is not working.
Could someone help please?
I removed the Soap envelope. Here is the last test I did.
DECLARE l_iInCCSID INTEGER InputRoot.Properties.CodedCharSetId;
DECLARE l_iInEncoding INTEGER InputRoot.Properties.Encoding;
DECLARE r_In REFERENCE TO InputRoot;
-- Convert Character entities to the XML tree
DECLARE l_bSOAPReqCharEntitiesBlob BLOB CAST(InputRoot.XMLNSC.*:ProcessMessage.*:xmlMessage AS BLOB CCSID l_iInCCSID);
CREATE LASTCHILD OF Environment.Variables.SOAPInputData AS r_In DOMAIN 'XMLNSC' PARSE(l_bSOAPReqCharEntitiesBlob, l_iInEncoding, l_iInCCSID);
MOVE r_In TO r_In.*:"FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.WriteTransactionHistory";
SET OutputRoot = InputRoot; |
|
Back to top |
|
 |
Vitor |
Posted: Tue Jul 31, 2018 6:15 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
paulobugmann wrote: |
Could someone help please? |
@timber did help - he told you to parse the second doc. Parsing is not the same as just adding something to the tree. _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
paulobugmann |
Posted: Tue Jul 31, 2018 12:39 pm Post subject: |
|
|
Newbie
Joined: 27 Jul 2018 Posts: 5
|
Sorry for my ignorance, but I'm not able to access the second document. |
|
Back to top |
|
 |
fjb_saper |
Posted: Tue Jul 31, 2018 6:21 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
paulobugmann wrote: |
Sorry for my ignorance, but I'm not able to access the second document. |
That's because you cannot change the InputRoot tree.
You need to change the OutputRoot tree when copying your tree part...
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
timber |
Posted: Wed Aug 01, 2018 1:43 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Quote: |
I'm not able to access the second document |
How did you try to access it? What happened? |
|
Back to top |
|
 |
paulobugmann |
Posted: Wed Aug 01, 2018 5:07 am Post subject: |
|
|
Newbie
Joined: 27 Jul 2018 Posts: 5
|
I do not have much knowledge in ESQL.
But I've tried in many ways to get the contents of the doc and I can not.
DECLARE l_iInCCSID INTEGER InputRoot.Properties.CodedCharSetId;
DECLARE l_iInEncoding INTEGER InputRoot.Properties.Encoding;
DECLARE r_In REFERENCE TO InputRoot;
-- Convert Character entities to the XML tree
DECLARE l_bSOAPReqCharEntitiesBlob BLOB CAST(InputRoot.XMLNSC.*:ProcessMessage.*:xmlMessage AS BLOB CCSID l_iInCCSID);
CREATE LASTCHILD OF Environment.Variables.SOAPInputData AS r_In DOMAIN 'XMLNSC' PARSE(l_bSOAPReqCharEntitiesBlob, l_iInEncoding, l_iInCCSID);
MOVE r_In TO r_In.*:"FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.WriteTransactionHistory";
IF FIELDVALUE(r_In.XMLNSC.*:SessionContext.OperationCode) = 'ProductionOrder.StatusChange.OUT' THEN
PROPAGATE TO TERMINAL 'out';
RETURN TRUE;
ELSE
RETURN FALSE;
END IF; |
|
Back to top |
|
 |
Vitor |
Posted: Wed Aug 01, 2018 5:24 am Post subject: |
|
|
 Grand High Poobah
Joined: 11 Nov 2005 Posts: 26093 Location: Texas, USA
|
paulobugmann wrote: |
I've tried in many ways to get the contents of the doc and I can not. |
You've posted this code twice. What are the other ways you've tried?
Also, as my worthy associate asked, what happened in each of these ways? "I can not" is hardly descriptive or informative.
paulobugmann wrote: |
I do not have much knowledge in ESQL. |
Does the person who gave you this task know this? Can they get you ESQL assistance from people on site, who will be more able to relate to your situation than a much of anonymous strangers on the Internet? _________________ Honesty is the best policy.
Insanity is the best defence. |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Aug 02, 2018 1:31 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
paulobugmann wrote: |
I do not have much knowledge in ESQL.
But I've tried in many ways to get the contents of the doc and I can not.
Code: |
DECLARE r_In REFERENCE TO InputRoot;
.....
CREATE LASTCHILD OF Environment.Variables.SOAPInputData AS r_In DOMAIN 'XMLNSC' PARSE(l_bSOAPReqCharEntitiesBlob, l_iInEncoding, l_iInCCSID);
|
|
Again the INPUT Tree is NOT MUTABLE. This means you're not allowed to change it and if you try nothing happens... Try changing the OUTPUT tree instead!  _________________ MQ & Broker admin |
|
Back to top |
|
 |
timber |
Posted: Thu Aug 02, 2018 11:23 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
1. This comment is not accurate:
Code: |
-- Convert Character entities to the XML tree |
You are not 'converting character entities'. That would simply give you a string that looks like XML. You are parsing the value of the xmlMessage tag to create a message tree.
2. This line of code is probably not required.
Code: |
DECLARE l_bSOAPReqCharEntitiesBlob BLOB CAST(InputRoot.XMLNSC.*:ProcessMessage.*:xmlMessage AS BLOB CCSID l_iInCCSID); |
(I did mention that in my first response)
3. Looks OK:
Code: |
CREATE LASTCHILD OF Environment.Variables.SOAPInputData AS r_In DOMAIN 'XMLNSC' PARSE(l_bSOAPReqCharEntitiesBlob, l_iInEncoding, l_iInCCSID); |
...although you may want to experiment with removing the iinEncoding and iInCCSID parameters, because ESQL will set them for itself if you give it a CHARACTER instead of a BLOB.
4. This is where your problem is:
Code: |
MOVE r_In TO r_In.*:"FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.WriteTransactionHistory"; |
The reference r_In is already positioned on Environment.Variables.SOAPInputData."FlexNet.BusinessFacade.Utility.TransactionHistoryWriter.WriteTransactionHistory". You are now trying to move to a non-existent child of that node.
Tip: You would probably have found this defect within 15 minutes if you had taken a user trace. If you are going to write and debug a lot of ESQL then you should get comfortable with taking a reading a user trace. See other posts in this forum for how to use mqsichangetrace, mqsireadlog and mqsiformatlog. |
|
Back to top |
|
 |
|