BusinessObjects Board

Launch Batch Job using WS with Security enabled

Hi everybody,
i’ve a problem:i’ve to launch a BatchJob using DataServices WebService (with java). Eclipse has created a bunch of classes from WSDL. Whitout security, it’s all right. With security enabled, i do correctly login, i retrieve the sessionID, but then i don’t know where to put that string in subsequent calls (es ask for Job status, or launch a batch job).
Can anybody give me any examples?

thanks very much

Luca


luca.campodallorto (BOB member since 2013-05-29)

you will have to pass the sessionID as part of the header, some of the tools when converting the WSDL to Java will not generate the code for that, try the latest version of the tool to see if the issue is fixed or you can try by adding the following code

Modify Connection_OperationsStub.java to add header object.

    SOAPHeaderElement header = new SOAPHeaderElement("http://www.businessobjects.com/DataServices/ServerX.xsd", "session");
    MessageElement sessionIDElm = new MessageElement("", "SessionID");
    try
    {
        sessionIDElm.addTextNode(session.getSessionID());
        header.addChildElement(sessionIDElm);
  } catch (java.lang.Exception ex) {
          //throw axisFaultException(ex.getMessage());
  }
    _call.addHeader(header);

manoj_d (BOB member since 2009-01-02)

Hi manoj_d,
thanks very much for your answer. I think i’ve to add the header on Batch_Job_AdminStub (am i right?). On the stub class there is a addHeader() method, i’ve modified my code in this way:

LogonRequest logreq = new LogonRequest();
logreq.setCms_authentication("secEnterprise");
logreq.setPassword(j.getRepository().getPasswordDS());
logreq.setUsername(j.getRepository().getLoginDS());
logreq.setCms_system(j.getRepository().getServerCms());
Connection_OperationsProxy connOp = new Connection_OperationsProxy();
connOp.setEndpoint(j.getRepository().getUrl());
Session sess = connOp.logon(logreq);//this works
SOAPHeaderElement header = new SOAPHeaderElement("http://www.businessobjects.com/DataServices/ServerX.xsd", "session"); 
MessageElement sessionIDElm = new MessageElement("", "SessionID"); 
sessionIDElm.addTextNode(sess.getSessionID()); 
header.addChildElement(sessionIDElm);
Batch_Job_AdminStub bja = new Batch_Job_AdminStub(new URL(j.getRepository().getUrl()),null);
bja.setHeader(header);

but server response is always: Web Services security enabled and session validation failed. Error: No sessionID supplied in soap request

Where i’m wrong?

thanks


luca.campodallorto (BOB member since 2013-05-29)

This is my full code to get job status (works with security disabled):

LogonRequest logreq = new LogonRequest();
logreq.setCms_authentication("secEnterprise");
logreq.setPassword(j.getRepository().getPasswordDS());
logreq.setUsername(j.getRepository().getLoginDS());
logreq.setCms_system(j.getRepository().getServerCms());
Connection_OperationsProxy connOp = new Connection_OperationsProxy();
connOp.setEndpoint(j.getRepository().getUrl());
Session sess = connOp.logon(logreq);
SOAPHeaderElement header = new SOAPHeaderElement("http://www.businessobjects.com/DataServices/ServerX.xsd", "session"); 
MessageElement sessionIDElm = new MessageElement("", "sessionID"); 
sessionIDElm.addTextNode(sess.getSessionID()); 
header.addChildElement(sessionIDElm);
Batch_Job_AdminStub bja = new Batch_Job_AdminStub(new URL(j.getRepository().getUrl()),null);
bja.setHeader(header);
BatchJobStatusRequest request = new BatchJobStatusRequest();
request.setRepoName(j.getRepository().getName());
BatchJobRunIDsRequest x1 = new BatchJobRunIDsRequest();
x1.setJobName(j.getJobName());
x1.setRepoName(j.getRepository().getName());
BatchJobRunIDsResponse resp1 = bja.get_BatchJob_RunIDs(x1);
		try
		{
			BatchJobRunIDsResponseRun[] lista = resp1.getRun();
			int id = lista[0].getRunID();
			request.setRunID(id);
			BatchJobStatusResponse resp = bja.get_BatchJob_Status(request);
			return resp.getStatus();
			
		} 
			catch (Exception err)
		{
			return "Error:"+err.getMessage();
		}

luca.campodallorto (BOB member since 2013-05-29)

can you check the return of Logon ? are you getting a session ID ?
can you try to capture the input that is going to DS Webserver using TCPMon or WireShark

or you can also enable WS Trace for DS and check the input XML for this do the following
Stop tomcat
go to %LINK_DIR%\conf open Admin.xml in notepad and set the value of to TRUE
Start tomcat
run your client app, check the %LINK_DIR%\log\webservices.log.0 file for the input that is coming to DS WebServer and post that here


manoj_d (BOB member since 2009-01-02)

Yes, i got a SessionID after Logon.
this is the xml message logged (request for job run ID)

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<soapenv:Header>
<ns1:session xmlns:ns1="http://www.businessobjects.com/DataServices/ServerX.xsd" soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0">
<sessionID>D965B23F-43F8-C7E2-8AD5-FBEF3D2C1B57</sessionID>
</ns1:session>
</soapenv:Header>
<soapenv:Body>
<batchJobRunIDsRequest xmlns="http://www.businessobjects.com/DataServices/ServerX.xsd">
<jobName xmlns="">J_HYP_COMP_CEXCGU</jobName>
<repoName xmlns="">DSREPO_HYP</repoName>
</batchJobRunIDsRequest>
</soapenv:Body>
</soapenv:Envelope>

luca.campodallorto (BOB member since 2013-05-29)

What is your DS version ?
the input looks fine, can you try following from SoapUI
Import the DS WSDL in SoapUI Project
call logon operation to get a session ID
use the XML that you see in the log replace the session id and call run_batch_job see if that works


manoj_d (BOB member since 2009-01-02)

My DS version is 14.0.3.353

XML generated by SoapUI (great tool) for RunIDs request is the following (works):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ser="http://www.businessobjects.com/DataServices/ServerX.xsd">
   <soapenv:Header>
      <ser:session>
         <SessionID>B439EC21-67C8-A5BF-E2BF-EB5D85EC5121</SessionID>
      </ser:session>
   </soapenv:Header>
   <soapenv:Body>
      <ser:batchJobRunIDsRequest>
         <jobName>J_APPLICATION_MKT_MIGRAZIONE</jobName>
         <!--Optional:-->
         <status></status>
         <!--Optional:-->
         <repoName>DSREPOCEDFL</repoName>
      </ser:batchJobRunIDsRequest>
   </soapenv:Body>
</soapenv:Envelope>

that is different from mine:

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soapenv:Header>
      <ns1:session soapenv:actor="http://schemas.xmlsoap.org/soap/actor/next" soapenv:mustUnderstand="0" xmlns:ns1="http://www.businessobjects.com/DataServices/ServerX.xsd">
         <sessionID>D965B23F-43F8-C7E2-8AD5-FBEF3D2C1B57</sessionID>
      </ns1:session>
   </soapenv:Header>
   <soapenv:Body>
      <batchJobRunIDsRequest xmlns="http://www.businessobjects.com/DataServices/ServerX.xsd">
         <jobName xmlns="">J_HYP_COMP_CEXCGU</jobName>
         <repoName xmlns="">DSREPO_HYP</repoName>
      </batchJobRunIDsRequest>
   </soapenv:Body>
</soapenv:Envelope>

in namespace ser, i’ve namespace ns1.
What should i change in my code to obtain same xml?


luca.campodallorto (BOB member since 2013-05-29)

ser and ns1 are aliases and both resolve to same namespace, the problem is not with that

if you look at the element name sessionID in your input and SoapUI input the “S” in sessionID is capital S in case of SoapUI, I think this is causing the issue

Change your code the send this name as SessionID instead of sessionID and see if that works


manoj_d (BOB member since 2009-01-02)

Can you share the code you used to run the job?


olafecorcam (BOB member since 2013-01-29)