ASG
IBM
Zystems
Cressida
Icon
Netflexity
 
  MQSeries.net
Search  Search       Tech Exchange      Education      Certifications      Library      Info Center      SupportPacs      LinkedIn  Search  Search                                                                   FAQ  FAQ   Usergroups  Usergroups
 
Register  ::  Log in Log in to check your private messages
 
RSS Feed - WebSphere MQ Support RSS Feed - Message Broker Support

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MRM converting xml attributes to elements

Post new topic  Reply to topic
 MRM converting xml attributes to elements « View previous topic :: View next topic » 
Author Message
rk1891
PostPosted: Fri Jun 25, 2021 11:58 am    Post subject: MRM converting xml attributes to elements Reply with quote

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
View user's profile Send private message
timber
PostPosted: Tue Jun 29, 2021 12:02 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

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
View user's profile Send private message
rk1891
PostPosted: Tue Jun 29, 2021 4:40 am    Post subject: Reply with quote

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
View user's profile Send private message
timber
PostPosted: Tue Jun 29, 2021 10:05 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

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
View user's profile Send private message
rk1891
PostPosted: Tue Jun 29, 2021 10:10 am    Post subject: Reply with quote

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
View user's profile Send private message
mgk
PostPosted: Tue Jun 29, 2021 10:20 am    Post subject: Reply with quote

Padawan

Joined: 31 Jul 2003
Posts: 1638

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
View user's profile Send private message
timber
PostPosted: Wed Jun 30, 2021 1:54 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

I probably should have asked this before but...which version of IIB are you using?
Back to top
View user's profile Send private message
rk1891
PostPosted: Wed Jun 30, 2021 5:06 am    Post subject: Reply with quote

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
View user's profile Send private message
timber
PostPosted: Wed Jun 30, 2021 3:01 pm    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

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
View user's profile Send private message
rk1891
PostPosted: Thu Jul 01, 2021 5:04 am    Post subject: Reply with quote

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
View user's profile Send private message
timber
PostPosted: Fri Jul 02, 2021 5:15 am    Post subject: Reply with quote

Grand Master

Joined: 25 Aug 2015
Posts: 1280

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
View user's profile Send private message
rekarm01
PostPosted: Tue Jul 06, 2021 10:56 am    Post subject: Re: MRM converting xml attributes to elements Reply with quote

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
View user's profile Send private message
Display posts from previous:   
Post new topic  Reply to topic Page 1 of 1

MQSeries.net Forum Index » WebSphere Message Broker (ACE) Support » MRM converting xml attributes to elements
Jump to:  



You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Protected by Anti-Spam ACP
 
 


Theme by Dustin Baccetti
Powered by phpBB © 2001, 2002 phpBB Group

Copyright © MQSeries.net. All rights reserved.