0 Replies Latest reply on Mar 2, 2016 1:12 PM by alexanderrs

    EsmApiGuide Java code error...

    alexanderrs

      In my attempts to use SOAP/XML with our local instance of the SIEM, I was using the guide, and its example below did not work for my Java Web Service Client code:


      EsmApi api = new McAfeeEsmApiService().getMcAfeeEsmApiPort();

      ((BindingProvider)api).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_ PROPERTY, true);

       

      My IDE (Eclipse Mars) intellisenses the new McAfeeEsmApiService() as cannot instantiate (it is an abstract class).  I changed this to:

       

      EsmApi api = new McAfeeEsmApiServiceLocator().getMcAfeeEsmApiPort();

         

      And the code compiled.  When I executed the code, I received the following error:


      java.lang.ClassCastException: com.mcafee.siem.api.v3.McAfeeEsmApiServiceSoapBindingStub cannot be cast to javax.xml.ws.BindingProvider


      After some digging into superclasses, I found that the interface javax.xml.rpc.Stub applies and a casted EsmApi object can have its property set to maintain the session.

       

      ((Stub)api)._setProperty(Stub.SESSION_MAINTAIN_PROPERTY, true);


      I was now able to log in and stay logged in.


      I hope this helps other developers.