如题package cognos;
import javax.servlet.http.Cookie;
import http://www.doczj.com/doc/968719df3186bceb19e8bb49.htmlspace.QName;
import org.apache.axis.client.Stub;
import org.apache.axis.message.SOAPHeaderElement;
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.SearchPathSingleObject;
import com.cognos.developer.schemas.bibus._3.XmlEncodedXML;
public class CognosLogin {
public void loginCognos() throws Exception{
String dispatcherEndPoint = "http://172.16.4.150:9300/p2pd/servlet/dispatch";
// String gatewayPrefix = "http://localhost";
// String gatewaySuffix = "/ibmcognos/cgi-bin/cognos.cgi";
// String gatewayEndPoint = gatewayPrefix + gatewaySuffix;
String nameSpaceID = "NTLM";
String userName = "administrator";
String password = "administrator ";
ContentManagerService_ServiceLocator cmServiceLocator = new ContentManagerService_ServiceLocator();
ContentManagerService_PortType cmService = cmServiceLocator.getcontentManagerService(new http://www.doczj.com/doc/968719df3186bceb19e8bb49.html.URL(dispatcherEndPoint));
StringBuffer credentialXML = new StringBuffer();
credentialXML.append("");
credentialXML.append("").append(nameSpaceID).append("");
credentialXML.append("").append(userName).append("");
credentialXML.append("").append(password).append("");
credentialXML.append("");
String encodedCredentials = credentialXML.toString();
cmService.logon(new XmlEncodedXML(encodedCredentials), new SearchPathSingleObject[]{});
SOAPHeaderElement temp = ((Stub)cmService).getResponseHeader
("http://www.doczj.com/doc/968719df3186bceb19e8bb49.html/schemas/bibus/3/", "biBusHeader");
BiBusHeader cmBiBusHeader = (BiBusHeader)temp.getValueAsType
(new QName ("http://www.doczj.com/doc/968719df3186bceb19e8bb49.html/schemas/bibus/3/","biBusHeader"));
((Stub)cmService).setHeader("http://www.doczj.com/doc/968719df3186bceb19e8bb49.html/schemas/bibus/3/", "biBusHeader", cmBiBusHeader);
System.out.println("Setting all cookies...");
Cookie newCookie = null;
for (int i = 0; i < cmBiBusHeader.getHdrSession().getSetCookieVars().length; i++)
{
System.out.println(cmBiBusHeader.getHdrSession().getSetCookieVars().getName() + "=" + cmBiBusHeader.getHdrSession().getSetCookieVars().getValue());
newCookie = new Cookie(cmBiBusHeader.getHdrSession().getSetCookieVars().getName(), cmBiBusHeader.getHdrSession().getSetCookieVars().getValue());
// Make sure to set the domain and path as appropriate for your environment
//newCookie.setDomain(".xxx.yyy");;
newCookie.setMaxAge(-1);
newCooki