Hello all,
I'm completely new to the Cognos SDK and have only passing experience with Java in general. I need some help figuring out what is going on with my setup. I'm still trying to work with all of the delivered examples, both installed with the SDK and one from a getting started with SDK document. No matter which program I run I get the same error message so I'm assuming the problem is global.
I've tried it using JDK 1.6 and JDK 1.7.
Here is an example of the .java I'm running:
import java.net.URL;
import javax.xml.namespace.QName;
import org.apache.axis.client.Stub;
import org.apache.axis.message.SOAPHeaderElement;
import com.cognos.developer.schemas.bibus._3.BaseClass;
import com.cognos.developer.schemas.bibus._3.BiBusHeader;
import com.cognos.developer.schemas.bibus._3.ContentManagerService_PortType;
import com.cognos.developer.schemas.bibus._3.ContentManagerService_ServiceLocator;
import com.cognos.developer.schemas.bibus._3.PropEnum;
import com.cognos.developer.schemas.bibus._3.QueryOptions;
import com.cognos.developer.schemas.bibus._3.SearchPathMultipleObject;
import com.cognos.developer.schemas.bibus._3.SearchPathSingleObject;
import com.cognos.developer.schemas.bibus._3.Sort;
import com.cognos.developer.schemas.bibus._3.XmlEncodedXML;
public class SDKExample {
private static String dispatcherURL = "http://localhost:9900/p2pd/servlet/dispatch";
private static String nameSpaceID = "REDACTED";
private static String userName = "REDACTED";
private static String password = "REDACTED";
private ContentManagerService_PortType cmService = null;
private SearchPathSingleObject[] role = new SearchPathSingleObject[] {};
public static void main(String args[]) {
SDKExample mainClass = new SDKExample(); // instantiate the class
// Step 1: Connect to the Cognos services
mainClass.connectToCognos(dispatcherURL);
// Step 2: Logon to Cognos
mainClass.logonToCognos(nameSpaceID, userName, password);
//I've commented these out to make the troubleshooting easier
// Step 3: Execute tasks
// mainClass.executeTasks();
// Step 4: Logoff from Cognos
// mainClass.logoffFromCognos();
}
// Step 1: Connect to the Cognos services
private void connectToCognos(String dispatcherURL) {
ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator();
try {
URL url = new URL(dispatcherURL);
cmService = cmServiceLocator.getcontentManagerService(url);
} catch (Exception e) {
e.printStackTrace();
}
}
// Step 2: Logon to Cognos
private void logonToCognos(String nsID, String user, String pswd) {
StringBuffer credentialXML = new StringBuffer();
credentialXML.append("<credential>");
credentialXML.append("<namespace>").append(nsID).append("</namespace>");
credentialXML.append("<username>").append(user).append("</username>");
credentialXML.append("<password>").append(pswd).append("</password>");
credentialXML.append("</credential>");
String encodedCredentials = credentialXML.toString();
XmlEncodedXML xmlCredentials = new XmlEncodedXML();
xmlCredentials.set_value(encodedCredentials);
try {
//cmService.logon(xmlCredentials, null);
cmService.logon(xmlCredentials, role);
SOAPHeaderElement temp = ((Stub) cmService).getResponseHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader");
BiBusHeader CMbibus = (BiBusHeader) temp
.getValueAsType(new QName("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader"));
((Stub) cmService).setHeader("http://developer.cognos.com/schemas/bibus/3/", "biBusHeader", CMbibus);
} catch (Exception ex) {
ex.printStackTrace();
}
}
// Step 3: Execute tasks
private void executeTasks() {
PropEnum props[] = new PropEnum[] { PropEnum.searchPath, PropEnum.defaultName };
BaseClass bc[] = null;
String searchPath = "/content//package";
try {
SearchPathMultipleObject spMulti = new SearchPathMultipleObject(searchPath);
bc = cmService.query(spMulti, props, new Sort[] {}, new QueryOptions());
} catch (Exception e) {
e.printStackTrace();
return;
}
System.out.println("PACKAGES:\n");
if (bc != null) {
for (int i = 0; i < bc.length; i++) {
System.out.println(bc.getDefaultName().getValue() + " - " + bc.getSearchPath().getValue());
}
}
}
// Step 4: Logoff from Cognos
private void logoffFromCognos() {
try {
cmService.logoff();
} catch (Exception ex) {
ex.printStackTrace();
}
}
}
Here is the error message I get when executing:
AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.userException
faultSubcode:
faultString: java.lang.NumberFormatException: For input string: ""
faultActor:
faultNode:
faultDetail:
{http://xml.apache.org/axis/}stackTrace:java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at com.cognos.org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPSender.java:651)
at com.cognos.org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
at com.cognos.org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at com.cognos.org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:119)
at com.cognos.org.apache.axis.SimpleChain.invoke(SimpleChain.java:84)
at com.cognos.org.apache.axis.client.AxisClient.invoke(AxisClient.java:166)
at com.cognos.org.apache.axis.client.Call.invokeEngine(Call.java:2785)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2768)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2444)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2367)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:1813)
at com.cognos.developer.schemas.bibus._3.ContentManagerServiceStub.logon(ContentManagerServiceStub.java:7393)
at SDKExample.logonToCognos(SDKExample.java:71)
at SDKExample.main(SDKExample.java:34)
{http://xml.apache.org/axis/}hostname:scogapp1vsc
java.lang.NumberFormatException: For input string: ""
at com.cognos.org.apache.axis.AxisFault.makeFault(AxisFault.java:102)
at com.cognos.org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:155)
at com.cognos.org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
at com.cognos.org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:119)
at com.cognos.org.apache.axis.SimpleChain.invoke(SimpleChain.java:84)
at com.cognos.org.apache.axis.client.AxisClient.invoke(AxisClient.java:166)
at com.cognos.org.apache.axis.client.Call.invokeEngine(Call.java:2785)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2768)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2444)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:2367)
at com.cognos.org.apache.axis.client.Call.invoke(Call.java:1813)
at com.cognos.developer.schemas.bibus._3.ContentManagerServiceStub.logon(ContentManagerServiceStub.java:7393)
at SDKExample.logonToCognos(SDKExample.java:71)
at SDKExample.main(SDKExample.java:34)
Caused by: java.lang.NumberFormatException: For input string: ""
at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
at java.lang.Integer.parseInt(Integer.java:592)
at java.lang.Integer.parseInt(Integer.java:615)
at com.cognos.org.apache.axis.transport.http.HTTPSender.readHeadersFromSocket(HTTPSender.java:651)
at com.cognos.org.apache.axis.transport.http.HTTPSender.invoke(HTTPSender.java:144)
... 12 more
Any help in troubleshooting this would be most appreciated.
Jay Deckman
Jay,
The problem doesn't appear to be with your code, but rather with your server. The SDK (more specifically Axis) is trying to read the HTTP Response Code from the server, which is an Integer (e.g. 200=OK, 500=Server Error). However the server is returning blank for an error code. Is your dispatcher really at http://localhost:9300/p2pd/servlet/dispatch? Try this in a browser and make sure that you see a Cognos screen properly. If you want to try connecting another way download our product MetaManager (the trial, you don't to buy anything) and see if it can connect to the Dispatcher properly or if you get the same error. With MetaManager at least you'll get better logging on the connection.
http://www.bspsoftware.com/products/metamanager/download/
-Andy
Thanks for that help Andrew. It looks like I was using the wrong connection data.