AnsweredAssumed Answered

Web Services Question

Question asked by luisg on Jul 16, 2009
Latest reply on Sep 29, 2009 by openpj
Hi there. I've a big problem here, and don't know how to solve this.
Imagine the following scenario:
An application, A, need to access to a Web Service, B, (in a Tomcat 1) to invoke something. When A, make a request to B, B should make an operation in Alfresco (running in Tomcat 2). example: A make a request to B to create a folder in Alfresco. you know what I mean?

I did a Web Service in Eclipse and I wrote a simple function to login in Alfresco: the function receive a user (String) and a password (String) and return a message (String) that indicate if login succeeds or not. After that I generated a client with the wsdl.
If I make a request with that client to the service, giving the credentials ('admin', 'admin') I get this:

Request:

<soapenv:Envelope>
   <soapenv:Body>
      <q0:novaAccao>
      <q0:user>admin</q0:user>
      <q0:pass>admin</q0:pass>
     </q0:novaAccao>
   </soapenv:Body>
</soapenv:Envelope>

Response:

<soapenv:Envelope>
   <soapenv:Body>
      <soapenv:Fault>
         <faultcode>soapenv:Server.userException</faultcode>
         <faultstring>java.lang.reflect.InvocationTargetException</faultstring>
         <detail>
            <ns1:hostname>pt0103</ns1:hostname>
         </detail>
      </soapenv:Fault>
   </soapenv:Body>
</soapenv:Envelope>

pt0103 is the name of my machine.

The code is working, cause I did a test with a class with that code. the code is:

public String novaAccao(java.lang.String user, java.lang.String pass){
      final String URL = "http://localhost:8080/alfresco/api";
      String result;
      try
      {
         System.out.println("Logging to " + URL);
         WebServiceFactory.setEndpointAddress(URL);
         AuthenticationUtils.startSession(user, pass);
         result = "success";
      }
      catch(Exception e)
      {
            System.err.println("FAIL.");
            result = "fail";
            e.printStackTrace();
       }
      return result;
   }

Any of you have (or had) the same problem?
What am I doing wrong?

Please, Help

Luis

Outcomes