I have a HTTPSOAP-SU and after XSLT transform and routing I arrive in a java
class to treat the SOAP demand (and to return a formatted response for the
client).
My question is : currently my java class is completely hard coded (with all
XML tags), is there a way do it more properly and easier into the ESB ? For
now, I must use the dom4j.jar and jaxen.jar to extract XML tags (and have it
into the SU.zip file).
Here is the java code :
public class LoginComponent extends TransformComponentSupport {
private static final Log log =
LogFactory.getLog("org.apache.servicemix");
public LoginComponent() {
log.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
log.debug("$$$$$$$$$$$$$$$$$$$$$ LoginComponent created
$$$$$$$$$$$$$$$$$$$$$$$$$");
log.debug("$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$$");
}
public boolean transform(MessageExchange exchange, NormalizedMessage
in, NormalizedMessage out) throws MessagingException {
log.debug("LoginComponent transform....");
try {
SourceTransformer sourceTransformer = new
SourceTransformer();
String fluxXMLInput =
sourceTransformer.contentToString(in);
Document doc = DocumentHelper.parseText(fluxXMLInput);
String deviceId = Utils.getXPathField(doc, "deviceId");
String groupId = Utils.getXPathField(doc, "groupId");
log.debug("LoginComponent deviceId = " + deviceId);
log.debug("LoginComponent groupId = " + groupId);
Source outMsg = null;
String result = null;
result =
"<SOAP><RESULT>"+deviceId+"/"+groupId+"</RESULT></SOAP>";
outMsg = new StringSource(result);
if (outMsg != null) {
// There is a valid response
log.debug("Response: " +
sourceTransformer.toString(outMsg));
out.setContent(outMsg);
return true;
} else {
log.debug("Response: No Response");
return false;
}
} catch (Exception e) {
log.error("LoginComponent Exception: ", e);
throw new MessagingException(e);
} finally {
}
}
}
--
View this message in context:
http://www.nabble.com/Hard-coded-XML-tags-into-a-java-component...-tp18866116p18866116.html
Sent from the ServiceMix - User mailing list archive at Nabble.com.