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 Process Server (WID/WPS/WAS+) » Service Gateway route on payload data?

Post new topic  Reply to topic
 Service Gateway route on payload data? « View previous topic :: View next topic » 
Author Message
eskil
PostPosted: Mon Nov 23, 2009 1:11 am    Post subject: Service Gateway route on payload data? Reply with quote

Novice

Joined: 25 Nov 2008
Posts: 14

Anyone have experience on how to get the ServiceGateWay to route on the payload data? Binding is SOAP/HTTP 1.1 and I want to route on the operation and namespace of the request (i.e "getData" + "http://namespace.to.route.on" in the example below)

Code:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:isn="http://namespace.to.route.on">
   <soapenv:Header>
      ...
   </soapenv:Header>
   <soapenv:Body>
      <isn:getData>
         ...
      </isn:getData>
   </soapenv:Body>
</soapenv:Envelope>


When the message reaches the mediation flow in the SGW module the data in the body of the SMO is named "message" (type: anyType) and the namespace is set to the one defined in the interface of the SGW which in a way make sense.

Not sure how to solve this, but is there any way to not "type" the incoming message, or to read the source XML instead?
Back to top
View user's profile Send private message
eskil
PostPosted: Wed Nov 25, 2009 1:52 am    Post subject: Reply with quote

Novice

Joined: 25 Nov 2008
Posts: 14

After hours of testing and pulling my hair I solved it. Perhaps someone else will stumble upon this problem later on so here is how I solved it.

The ServiceGateway is generated from the wizard (binding: HTTP/SOAP 1.1)

Created a business object (i.e "CommonData") that had a string called "compositeKey". Added the CommonData BO as the correlation context on the input primitive in the mediation flow.

After LogMessage I added a Custom Mediation primitive with the following code:

Java Imports:
Code:
import com.ibm.ws.webservices.engine.utils.XMLUtils;
import org.w3c.dom.Document;
import java.io.StringReader;
import org.xml.sax.InputSource;


Java Code:
Code:
/**
 * GENERATED COMMENT - DO NOT MODIFY
 * Variables:  for output terminals - out (com.ibm.wsspi.sibx.mediation.OutputTerminal)
 *             for user properties - <No user properties defined>
 * Inputs:     inputTerminal (com.ibm.wsspi.sibx.mediation.InputTerminal), smo (com.ibm.websphere.sibx.smobo.ServiceMessageObject)
 * Exceptions: com.ibm.wsspi.sibx.mediation.MediationConfigurationException, com.ibm.wsspi.sibx.mediation.MediationBusinessException
 */
 
Document bodyDoc;
String operation;
String namespace;

try {
   bodyDoc = XMLUtils.newDocument(new InputSource(new StringReader(smo.getString("/body/message/value"))));
   operation = bodyDoc.getDocumentElement().getNodeName();
   namespace = bodyDoc.getDocumentElement().getNamespaceURI();
} catch(Exception e) {
   operation = "";
   namespace = "";
}

// Remove namespace prefix
if(operation.indexOf(":") > -1) {
   operation = operation.substring(operation.indexOf(":")+1);
}

// Set composite key string (used by Database Lookup)
smo.setString("/context/correlation/compositeKey", namespace + "|" + operation);

out.fire(smo); // propagate the service message object to the primitive that is wired to the 'out' terminal


Then configure the Database Lookup to use "/context/correlation/compositeKey" when querying the database table.

You might want to remove or change the try/catch so you get a proper exception that you can return to the consumer.

Hope this might help someone.. GL!
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 Process Server (WID/WPS/WAS+) » Service Gateway route on payload data?
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.