cognos java,cognos10用JAVA如何获取passPortID(即实现单点登录)

如题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

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值