Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Calling Java From TDI Script Component

257 views
Skip to first unread message

mcraghead

unread,
Nov 8, 2012, 5:33:57 PM11/8/12
to
A co-worker gave me some Java code that he used to make some account changes in ITIM from a web app that he created. He used the ITIM Web Service. I thought that since he already had existing code from the app that he created that I could basically use it for my purposes from TDI. However, I noticed that I have problems with certain calls (e.g. exception thrown, but account suspension takes place) and other calls (e.g. getAttributes()) throws an exception that I can't recover from.

First, I confirmed that the Java works. Then I copied the code to an empty Javascript component in TDI. I then I 'Javascript-ized' the code so that it would work from TDI. Maybe I didn't do it correctly(?). Are there limitations on what you can do with Java from a Javascript component?

This is basically what I have in the component that does the suspend:

var accountDN;
var config;
var user;
var ws;
var itimSession;
var req;
var e;

try {
accountDN = new java.lang.String("eruid=abc123, ou=systemUser, ou=itim, ou=myorg, dc=itim");
config = new Packages.gov.treas.fms.itim.data.util.Configuration.getInstance();
user = config.getProperty(Packages.gov.treas.fms.itim.data.util.Configuration.WS_USER_KEY);

ws = Packages.gov.treas.fms.itim.ws.util.ITIMWSUtil.getITIMWs();
itimSession = ws.login(user, user);
req = ws.suspendAccount(itimSession, accountDN, java.util.Calendar.getInstance());
task.logmsg("req: " + req);
if (req != null) {
java.lang.System.out.println("Request ID: " + req.getRequestId());
} else {
java.lang.System.out.println("Req = null");
}
} catch (e) {
e.printStackTrace();
}



It throws a java.net.ConnectException when executing the ws.suspendAccount() statement:

Thu Nov 08 17:12:44 EST 2012 AxisFault
Thu Nov 08 17:12:44 EST 2012 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
Thu Nov 08 17:12:44 EST 2012 faultSubcode:
Thu Nov 08 17:12:44 EST 2012 faultString: java.net.ConnectException: Connection refused: connect
Thu Nov 08 17:12:44 EST 2012 faultActor:
Thu Nov 08 17:12:44 EST 2012 faultNode:
Thu Nov 08 17:12:44 EST 2012 faultDetail:
Thu Nov 08 17:12:44 EST 2012 {http://xml.apache.org/axis/}stackTrace:java.net.ConnectException: Connection refused: connect
Thu Nov 08 17:12:44 EST 2012 at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:352)
...



However, if I go into ITIM I can see that the request was actually made and completes successfully.

I may end up trying to create a regular web service client in TDI, but this would be faster if I knew how to fix it in TDI.

Thanks in advance.

Michael

mcraghead

unread,
Nov 9, 2012, 10:33:09 AM11/9/12
to
I rebooted my desktop before I posted yesterday and forgot to re-create my tunnels to the server. I thought the error didn't quite look right. :-) Sorry about that.

The code is correct and where I said it's throwing an exception is also correct. The part that is incorrect it the error. It's not a connection error. This is a portion of the stack trace:

Fri Nov 09 10:14:59 EST 2012 AxisFault
Fri Nov 09 10:14:59 EST 2012 faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
Fri Nov 09 10:14:59 EST 2012 faultSubcode:
Fri Nov 09 10:14:59 EST 2012 faultString: org.xml.sax.SAXException: Invalid element in com.ibm.itim.ws.model.WSRequest - requesteeDN
Fri Nov 09 10:14:59 EST 2012 faultActor:
Fri Nov 09 10:14:59 EST 2012 faultNode:
Fri Nov 09 10:14:59 EST 2012 faultDetail:
Fri Nov 09 10:14:59 EST 2012 {http://xml.apache.org/axis/}stackTrace:org.xml.sax.SAXException: Invalid element in com.ibm.itim.ws.model.WSRequest - requesteeDN
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.encoding.ser.BeanDeserializer.onStartChild(BeanDeserializer.java:258)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.encoding.DeserializationContext.startElement(DeserializationContext.java:1035)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.message.SAX2EventRecorder.replay(SAX2EventRecorder.java:165)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.message.MessageElement.publishToHandler(MessageElement.java:1141)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.message.RPCElement.deserialize(RPCElement.java:236)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.message.RPCElement.getParams(RPCElement.java:384)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.client.Call.invoke(Call.java:2467)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.client.Call.invoke(Call.java:2366)
Fri Nov 09 10:14:59 EST 2012 at org.apache.axis.client.Call.invoke(Call.java:1812)
Fri Nov 09 10:14:59 EST 2012 at com.ibm.itim.ws.services.WSItimServiceSoapBindingStub.suspendAccount(WSItimServiceSoapBindingStub.java:5206)
...


Thanks again.

Michael
0 new messages