Author |
Message
|
rk1891 |
Posted: Fri Jun 25, 2021 11:58 am Post subject: MRM converting xml attributes to elements |
|
|
Apprentice
Joined: 12 Oct 2011 Posts: 42
|
Hello,
I've message flow where I'll be getting an XML in MQInput node and I'm constructing a SOAP message in a compute node before passing the message on to HTTPRequestNode to call the end webservice.
I created a message set with the provided wsdl in MRM domain and wire format as XML1. The wsdl has the request element of type 'xs:anyType' where a pre-constructed xml can go based on external xsds. They are not in-lined in the wsdl by the customer as they are very complex with a lot of definitions.
In the Java compute node I'm constructing the SOAP envelope message by adding the incoming xml to it but I believe since I'm adding the xml to the MRM domain , it's converting all attributes as elements in the generated soap message. Is there any way we can correct it ?
Any help is appreciated!
Below is my code:
Code: |
final MbElement outRoot = outMessage.getRootElement();
// set the MRM specific properties
outRoot.evaluateXPath("string(./?Properties/?MessageSet[set-value('E8EAGAO002001')])");
outRoot.evaluateXPath("string(./?Properties/?MessageType[set-value('Envelope')])");
outRoot.evaluateXPath("string(./?Properties/?MessageFormat[set-value('XML1')])");
outRoot.evaluateXPath("string(./?MQRFH2/?mcd/?Msd[set-value('MRM')])");
outRoot.evaluateXPath("string(./?MQRFH2/?mcd/?Fmt[set-value('XML1')])");
outRoot.evaluateXPath("string(./?MQRFH2/?mcd/?Set[set-value('E8EAGAO002001')])");
outRoot.evaluateXPath("string(./?MQRFH2/?mcd/?Type[set-value('Envelope')])");
outRoot.evaluateXPath("string(./?HTTPRequestHeader/?soapAction[set-value('urn:sendMessage')])");
final MbElement mrm = outRoot.createElementAsLastChild("MRM");
// Fetch the incoming BLOB payload
final MbElement inRoot = inMessage.getRootElement();
final MbElement inBody = inRoot.getLastChild().getFirstChild()
.getNextSibling();
final byte[] data = (byte[]) inBody.getValue();
// necessary to convert BLOB payload back to XML
final MbElement envRoot = inputAssembly.getGlobalEnvironment()
.getRootElement();
final MbElement variables = envRoot.createElementAsLastChild(
MbElement.TYPE_NAME, "Variables", null);
final MbElement inputBody = variables
.createElementAsLastChildFromBitstream(data,
MbXMLNSC.PARSER_NAME, null, null, null, 0, 0, 0);
// create the MRM elements
final MbElement body = mrm.createElementAsLastChild(
MbElement.TYPE_NAME, "Body", null);
body.setNamespace("http://www.w3.org/2003/05/soap-envelope");
final MbElement synchMessage = body.createElementAsLastChild(
MbElement.TYPE_NAME, "SynchMessage", null);
synchMessage.setNamespace("http://sample.test");
// Adding the input xml as element tree
final MbElement message = synchMessage
.createElementAsLastChild(MbElement.TYPE_NAME, "request",
null);
message.setNamespace("http://sample.test");
message.copyElementTree(inputBody);
|
|
|
Back to top |
|
 |
timber |
Posted: Tue Jun 29, 2021 12:02 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
Your diagnosis is probably correct. In the MRM domain, there is nothing in the message tree to indicate that an element should be a tag or an attribute -that information is all in the message set.
A couple of important questions:
- why are you creating a new MRM message set? The MRM domain is not the recommended way to model XML messages. This has been true since v7.
- Why are you using an HTTPRequest to call a web service? Why not a SOAPRequest node? |
|
Back to top |
|
 |
rk1891 |
Posted: Tue Jun 29, 2021 4:40 am Post subject: |
|
|
Apprentice
Joined: 12 Oct 2011 Posts: 42
|
#1 - I'm using the MRM domain so it can handle the SOAP envelope part of the message without me constructing it.
#2 - As there is no need since I don't have the requirement to handle other aspects of SOAP message like WS-Addressing etc |
|
Back to top |
|
 |
timber |
Posted: Tue Jun 29, 2021 10:05 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
You're free to use the MRM domain, if that's what you prefer. But be aware that almost nobody uses it these days because the alternatives are easier and faster. |
|
Back to top |
|
 |
rk1891 |
Posted: Tue Jun 29, 2021 10:10 am Post subject: |
|
|
Apprentice
Joined: 12 Oct 2011 Posts: 42
|
Hmm.. So you would suggest to use XMLNS domain in the message set that's generated based on the wsdl ? |
|
Back to top |
|
 |
mgk |
Posted: Tue Jun 29, 2021 10:20 am Post subject: |
|
|
 Padawan
Joined: 31 Jul 2003 Posts: 1642
|
Actually I would suggest using the SOAP domain along with the SOAP nodes as they manage all the "SOAPy" stuff for you... _________________ MGK
The postings I make on this site are my own and don't necessarily represent IBM's positions, strategies or opinions. |
|
Back to top |
|
 |
timber |
Posted: Wed Jun 30, 2021 1:54 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
I probably should have asked this before but...which version of IIB are you using? |
|
Back to top |
|
 |
rk1891 |
Posted: Wed Jun 30, 2021 5:06 am Post subject: |
|
|
Apprentice
Joined: 12 Oct 2011 Posts: 42
|
We are at IIB version 10 now.
I'll explore the SOAP node. So I should be creating the message set with SOAP domain from wsdl to work with it then?[/quote] |
|
Back to top |
|
 |
timber |
Posted: Wed Jun 30, 2021 3:01 pm Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
You should not be creating a message set at all. There is a better way to package up your schemas. You should
- create a library and import your WSDLs and XSDs
- add a reference to that library from your main application
Libraries and applications were introduced in v8, so they are stable and well-supported. |
|
Back to top |
|
 |
rk1891 |
Posted: Thu Jul 01, 2021 5:04 am Post subject: |
|
|
Apprentice
Joined: 12 Oct 2011 Posts: 42
|
I've seen libraries and applications when we upgraded to v8 but we never get on the task of updating all existing flows and sub-flows.
I'm using few sub-flows in this webservice client message flow. If I've to use an application that would require the sub-flows to be converted and all the existing flows that are using those sub-flows.
I've recently used a library in a Rest client message flow. May be that is something I can try here.
I don't plan on to adding the xsds to the library as they are not even imported in the wsdl. As I mentioned , the wsdl has the request and response defined as anyType. This is basically a model of using Document based SOA. So without that I'll have to see how much of it useful in creating the library in the first place. |
|
Back to top |
|
 |
timber |
Posted: Fri Jul 02, 2021 5:15 am Post subject: |
|
|
 Grand Master
Joined: 25 Aug 2015 Posts: 1292
|
You can use subflows with applications/libaries. You may need to fix up some of your code before you can move into the app/libraries world but you probably should be doing that anyway.
Regardless of any other considerations, you should not use the MRM domain in new message flows. The recommendation is SOAP/XMLNSC for XML, JSON for JSON messages and DFDL for CSV, COBOL and all custom formats. |
|
Back to top |
|
 |
rekarm01 |
Posted: Tue Jul 06, 2021 10:56 am Post subject: Re: MRM converting xml attributes to elements |
|
|
Grand Master
Joined: 25 Jun 2008 Posts: 1415
|
rk1891 wrote: |
I've seen libraries and applications when we upgraded to v8 but we never get on the task of updating all existing flows and sub-flows. |
Until then, message flows in Integration projects can also use message models from (static) libraries. |
|
Back to top |
|
 |
|