You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by "Reinhold Bentele (uulm)" <re...@uni-ulm.de> on 2008/09/22 14:07:25 UTC

Problem with session in POJO

Hi all,

I have a problem with sessions in POJOs and couldn't find an answer in
the forums or in the list archive. I hope someone here can help me.
Therefore I created a minimal example for my problem.

I publish the following POJO as Web Service:

---MyService.java-----------------------------------------------------
public class MyService {
  public String echo(String s) {
    return "You said: " + s;
  }
}
----------------------------------------------------------------------


My main application that creates the configuration context and starts
the server:

---------App.java-----------------------------------------------------
package my.wsimpl;

import java.net.InetAddress;
import java.net.UnknownHostException;

import org.apache.axis2.AxisFault;
import org.apache.axis2.Constants;
import org.apache.axis2.context.ConfigurationContext;
import org.apache.axis2.context.ConfigurationContextFactory;
import org.apache.axis2.description.AxisService;
import org.apache.axis2.transport.http.SimpleHTTPServer;

public class App {

  public static void main(String[] args) throws AxisFault,
UnknownHostException {
    String pathToRepository = "D:/WS/Axis2WS/MinAddPrj/lib/axis2";
    ConfigurationContext context = ConfigurationContextFactory.
      createConfigurationContextFromFileSystem(pathToRepository, null);
    context.getAxisConfiguration().
      engageModule(Constants.MODULE_ADDRESSING);

    // get the host name
    String hostname = InetAddress.getLocalHost().getCanonicalHostName();
    context.getAxisConfiguration().addParameter("hostname", hostname);

    // create the service, set the scope and engage module
    AxisService myService = AxisService.createService(
      MyService.class.getName(),
      context.getAxisConfiguration());
    myService.setScope(Constants.SCOPE_SOAP_SESSION);
    myService.engageModule(context.getAxisConfiguration().
      getModule(Constants.MODULE_ADDRESSING));
		
    context.getAxisConfiguration().addService(myService);
		
    // start the server
    new SimpleHTTPServer(context, 8080).start();
    }
}
----------------------------------------------------------------------


If I make a request on the service I receive a correct response, so the
service is running and working. My problem now is that no session id was
included in the response. This is all I get:

---------Response-----------------------------------------------------
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
   <soapenv:Body>
      <ns:echoResponse xmlns:ns="http://wsimpl.my">
         <return>You said: Hello world</return>
      </ns:echoResponse>
   </soapenv:Body>
</soapenv:Envelope>
----------------------------------------------------------------------


Because I want to have stateful services (with login) I thought that
Axis would create a session id and send it in the response if I engage
the addressing module and configure the scope of the service.

What's wrong with my approach?

Reinhold

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problem with session in POJO

Posted by Deepal jayasinghe <de...@gmail.com>.
Reinhold Bentele (uulm) wrote:
> Deepal jayasinghe wrote:
>   
>> Did you engage addressing at the client side as well ?
>>     
> [...]
>
> Hi Deepal,
>
> thank you for your answer. No I did not engage addressing at client
> side. I thought that after the first request of a client (without
> addressing header at all or with an invalid session), Axis would
> automatically start a session and add a session id (addressing header)
> to the response.
>
> Am I wrong with this speculation? Does a session has to be initiated by
> the client (requester)?
>   
No if you deploy the service in the soap session , then client has to
send the addressing headers in order to be in the session. If the client
does not send the addressing header , then the server will not send any
of the addressing headers.

Thank you!
Deepal
> Reinhold
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>   


-- 
Thank you!


http://blogs.deepal.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problem with session in POJO

Posted by "Reinhold Bentele (uulm)" <re...@uni-ulm.de>.
Deepal jayasinghe wrote:
> Did you engage addressing at the client side as well ?
[...]

Hi Deepal,

thank you for your answer. No I did not engage addressing at client
side. I thought that after the first request of a client (without
addressing header at all or with an invalid session), Axis would
automatically start a session and add a session id (addressing header)
to the response.

Am I wrong with this speculation? Does a session has to be initiated by
the client (requester)?

Reinhold

---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org


Re: Problem with session in POJO

Posted by Deepal jayasinghe <de...@gmail.com>.
Did you engage addressing at the client side as well ?

-Deepal
> Hi all,
>
> I have a problem with sessions in POJOs and couldn't find an answer in
> the forums or in the list archive. I hope someone here can help me.
> Therefore I created a minimal example for my problem.
>
> I publish the following POJO as Web Service:
>
> ---MyService.java-----------------------------------------------------
> public class MyService {
>   public String echo(String s) {
>     return "You said: " + s;
>   }
> }
> ----------------------------------------------------------------------
>
>
> My main application that creates the configuration context and starts
> the server:
>
> ---------App.java-----------------------------------------------------
> package my.wsimpl;
>
> import java.net.InetAddress;
> import java.net.UnknownHostException;
>
> import org.apache.axis2.AxisFault;
> import org.apache.axis2.Constants;
> import org.apache.axis2.context.ConfigurationContext;
> import org.apache.axis2.context.ConfigurationContextFactory;
> import org.apache.axis2.description.AxisService;
> import org.apache.axis2.transport.http.SimpleHTTPServer;
>
> public class App {
>
>   public static void main(String[] args) throws AxisFault,
> UnknownHostException {
>     String pathToRepository = "D:/WS/Axis2WS/MinAddPrj/lib/axis2";
>     ConfigurationContext context = ConfigurationContextFactory.
>       createConfigurationContextFromFileSystem(pathToRepository, null);
>     context.getAxisConfiguration().
>       engageModule(Constants.MODULE_ADDRESSING);
>
>     // get the host name
>     String hostname = InetAddress.getLocalHost().getCanonicalHostName();
>     context.getAxisConfiguration().addParameter("hostname", hostname);
>
>     // create the service, set the scope and engage module
>     AxisService myService = AxisService.createService(
>       MyService.class.getName(),
>       context.getAxisConfiguration());
>     myService.setScope(Constants.SCOPE_SOAP_SESSION);
>     myService.engageModule(context.getAxisConfiguration().
>       getModule(Constants.MODULE_ADDRESSING));
> 		
>     context.getAxisConfiguration().addService(myService);
> 		
>     // start the server
>     new SimpleHTTPServer(context, 8080).start();
>     }
> }
> ----------------------------------------------------------------------
>
>
> If I make a request on the service I receive a correct response, so the
> service is running and working. My problem now is that no session id was
> included in the response. This is all I get:
>
> ---------Response-----------------------------------------------------
> <soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
>    <soapenv:Body>
>       <ns:echoResponse xmlns:ns="http://wsimpl.my">
>          <return>You said: Hello world</return>
>       </ns:echoResponse>
>    </soapenv:Body>
> </soapenv:Envelope>
> ----------------------------------------------------------------------
>
>
> Because I want to have stateful services (with login) I thought that
> Axis would create a session id and send it in the response if I engage
> the addressing module and configure the scope of the service.
>
> What's wrong with my approach?
>
> Reinhold
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>
>   


-- 
Thank you!


http://blogs.deepal.org


---------------------------------------------------------------------
To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
For additional commands, e-mail: axis-user-help@ws.apache.org