cancel
Showing results for 
Search instead for 
Did you mean: 

Java : Request does not contain required Security header

mbooshtein
Champ in-the-making
Champ in-the-making
All,

I'm setting up the web services client to create users.  I've got the client starting the session but it wont add the security header.  Am I missing something?  I'm running alfresco 3.3.0 and the 3.4.b.  below is my code:

public class TestAlfresco  {

   /**
    * @param args
    */
   public static void main(String[] args) throws Exception  {
      
      

      
      // Get a reference to the
         AuthenticationServiceSoapBindingStub authenticationService =
            (AuthenticationServiceSoapBindingStub) new AuthenticationServiceLocator()
            .getAuthenticationService(new URL("http://host.domain.com:8080/alfresco/api/AuthenticationService"));
             
         // Start the session
         AuthenticationResult result = authenticationService
                                       .startSession("admin", "password");
         String ticket = result.getTicket();
         System.out.println(ticket);
        
         AdministrationServiceSoapBindingStub adminService = (AdministrationServiceSoapBindingStub) new AdministrationServiceLocator().getAdministrationService(new URL("http://host.domain.com:8080/alfresco/api/AdministrationService"));

         NewUserDetails nud = new NewUserDetails();
         nud.setUserName("testUserWS");
         nud.setPassword("start123");
         NamedValue[] nvs = new NamedValue[3];
         nvs[0] = new NamedValue(Constants.PROP_USER_FIRSTNAME,false,"testFirst",null);
         nvs[1] = new NamedValue(Constants.PROP_USER_LASTNAME,false,"testLast",null);
         nvs[2] = new NamedValue(Constants.PROP_USER_HOMEFOLDER,false,"testHome",null);
         nud.setProperties(nvs);
        
         adminService.createUsers(new NewUserDetails[] {nud});
        
        
        
        
        
      // End the session
         authenticationService.endSession(ticket);


   }

Here's the stack trace:
TICKET_dcc19afc37e94e10bcfe23170dc75be4cc2f63b0
Exception in thread "main" AxisFault
faultCode: {http://schemas.xmlsoap.org/soap/envelope/}Server.generalException
faultSubcode:
faultString: WSDoAllReceiver: Request does not contain required Security header
faultActor:
faultNode:
faultDetail:
   {http://xml.apache.org/axis/}stackTrace:WSDoAllReceiver: Request does not contain required Security header
   at org.apache.ws.axis.security.WSDoAllReceiver.invoke(WSDoAllReceiver.java:175)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.strategies.InvocationStrategy.visit(InvocationStrategy.java:32)
   at org.apache.axis.SimpleChain.doVisiting(SimpleChain.java:118)
   at org.apache.axis.SimpleChain.invoke(SimpleChain.java:83)
   at org.apache.axis.handlers.soap.SOAPService.invoke(SOAPService.java:454)
   at org.apache.axis.server.AxisServer.invoke(AxisServer.java:281)
   at org.apache.axis.transport.http.AxisServlet.doPost(AxisServlet.java:699)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:637)
   at org.apache.axis.transport.http.AxisServletBase.service(AxisServletBase.java:327)
   at javax.servlet.http.HttpServlet.service(HttpServlet.java:717)
   at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:290)
   at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:206)
   at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:233)
   at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:191)
   at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:127)
   at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:102)
   at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:109)
   at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:298)
   at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:852)
   at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:588)
   at org.apache.tomcat.util.net.JIoEndpoint$Worker.run(JIoEndpoint.java:489)
   at java.lang.Thread.run(Thread.java:619)

   {http://xml.apache.org/axis/}hostname:naboo.tremolo.lan

WSDoAllReceiver: Request does not contain required Security header
   at org.apache.axis.message.SOAPFaultBuilder.createFault(SOAPFaultBuilder.java:222)
   at org.apache.axis.message.SOAPFaultBuilder.endElement(SOAPFaultBuilder.java:129)
   at org.apache.axis.encoding.DeserializationContext.endElement(DeserializationContext.java:1087)
   at org.apache.xerces.parsers.AbstractSAXParser.endElement(Unknown Source)
   at org.apache.xerces.impl.XMLNSDocumentScannerImpl.scanEndElement(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl$FragmentContentDispatcher.dispatch(Unknown Source)
   at org.apache.xerces.impl.XMLDocumentFragmentScannerImpl.scanDocument(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)
   at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)
   at org.apache.xerces.parsers.AbstractSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl$JAXPSAXParser.parse(Unknown Source)
   at org.apache.xerces.jaxp.SAXParserImpl.parse(Unknown Source)
   at org.apache.axis.encoding.DeserializationContext.parse(DeserializationContext.java:227)
   at org.apache.axis.SOAPPart.getAsSOAPEnvelope(SOAPPart.java:696)
   at org.apache.axis.Message.getSOAPEnvelope(Message.java:435)
   at org.apache.axis.handlers.soap.MustUnderstandChecker.invoke(MustUnderstandChecker.java:62)
   at org.apache.axis.client.AxisClient.invoke(AxisClient.java:206)
   at org.apache.axis.client.Call.invokeEngine(Call.java:2784)
   at org.apache.axis.client.Call.invoke(Call.java:2767)
   at org.apache.axis.client.Call.invoke(Call.java:2443)
   at org.apache.axis.client.Call.invoke(Call.java:2366)
   at org.apache.axis.client.Call.invoke(Call.java:1812)
   at org.alfresco.webservice.administration.AdministrationServiceSoapBindingStub.createUsers(AdministrationServiceSoapBindingStub.java:619)
   at TestAlfresco.main(TestAlfresco.java:41)

Any help would be greatly appreciated.

Thanks
Marc
1 REPLY 1

jcustovic
Champ in-the-making
Champ in-the-making
Try using code below.

WebServiceFactory.setEndpointAddress(alfrescoUrl);
AuthenticationUtils.startSession(alfrescoUsername, alfrescoPassword);
try {
   AdministrationServiceSoapBindingStub adminService = WebServiceFactory.getAdministrationService();
   // Rest of your code
} finally {
   AuthenticationUtils.endSession();
}