BLD0001 - Supporting SOAP over WMQ

BLD0001 - Supporting SOAP over WMQ

Creating integrated configurations in AEX (SAP NW PO 7.3 EHP1) having communication with a WMQ (either sender or receiver) requires some special trics. It seems like the JMS Adapter hasn't been really designed with SOAP in mind, meaning it cannot distinguish wether the message being read from the specific queue has a SOAP envelope or not.

Somehow, many people directly related SOAP with the HTTP transport protocol, but this isn't a limitation at all! SOAP is a message based protocol and not a transport protocol. Meaning; SOAP over HTTP or SOAP over WMQ (or JMS) is perfectly possible. Should be perfectly possible!

Then how to achieve it?

The solution does require some coding, due the fact that I foresee the realization of a custom build adapter module being placed in (pre) sequence of the existing default modules called:

  • ConvertJMSMessageToBinary
  • ConvertBinaryToXMBMessage

Sender side:

In the processing tab (section) of the Sender JMS Adapter configuration, there's a section called PI Settings. Within this section the 'Mapping of Message' parameter can be set with two pre selected values:

  • Message Payload = JMS Payload
  • Entire Message = JMS Payload

As said before, this does not distinguish between with or without SOAP envelope. So, leave the setting here to: Message Payload = JMS Payload. This results in having the full SOAP message (as retrieved from the queue, without the JMS or MQMD specific header) entering the adapter framework.

What we need is some kind of GetPayloadBean, able to remove the full SOAP envelope and treat the payload within the SOAP Body element as the actual payload to be further processed. Here's our candidate adapter module. The GetPayloadBean!

code snapshot

XMLPayload xmlpayload = msg.getDocument();
                DocumentBuilderFactory factory;
                factory = DocumentBuilderFactory.newInstance();                                                                                                                                                                                                      factory.setNamespaceAware(true);
               

                DocumentBuilder builder = factory.newDocumentBuilder();                                                                                                                                                                                        Document sourceDocument = builder.parse((InputStream) xmlpayload                                                                                                                                                                             .getInputStream());
                sourceDocument.getDocumentElement().normalize();
               

                NodeList nl = null;                                                                                                                                                                                                                                                      if (elementName != null) {
                            nl = sourceDocument.getElementsByTagNameNS("*", elementName);                                                                                                                                                                      Document rootDocument = builder.newDocument();
                            if (nl.item(0) != null) {
                                Node newRoot = rootDocument.importNode(nl.item(0), true);                                                                                                                                                                                     rootDocument.appendChild(newRoot);                                                                                                                                                                                                                     sourceDocument = rootDocument;
                        }
                  }
                 

                // return modified document                                                                                                                                                                                                                                      TransformerFactory tfactory = TransformerFactory.newInstance();                                                                                                                                                                              Transformer transformer = tfactory.newTransformer();                                                                                                                                                                                                  Source src = new DOMSource(sourceDocument);                                                                                                                                                                                                      ByteArrayOutputStream myBytes = new ByteArrayOutputStream();                                                                                                                                                                              Result dest = new StreamResult(myBytes);                                                                                                                                                                                                                  transformer.transform(src, dest);                                                                                                                                                                                                                                  byte[] docContent = myBytes.toByteArray();    
               

                if (docContent != null) {
                            xmlpayload.setContent(docContent);                                                                                                                                                                                                                           inputModuleData.setPrincipalData(msg);
                  }
            } catch (Exception e) {
                ModuleException me = new ModuleException(e);                                                                                                                                                                                                      throw me;
            }
            return inputModuleData;

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Tags:

| | | |

Contact

Adriaan Beukema

© 2014 All rights reserved.

Create a website for freeWebnode