axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Yakubovich, Alexey" <AYakubov...@roundarch.com>
Subject session in AddressBook sample
Date Tue, 15 Jun 2004 19:55:43 GMT
Hi, Axis users!
 
That's the third mail on the same topic... Sorry to repeat again about
the same... No only AddressBook sample seems not working, but the whole
Axis session implementation (class
org.apache.axis.session.SimpleSession) also seems to be a joke.  Please,
answer anybody who managed to use session in Axis web services, if not
with explanation how, but at least with positive statement that it could
work!  After failure with original example I tried with
SimpleSessionHandler and with SimpleSession ... and with <parameter
name="scope" value="Session"/> 
 
Just on case I attached the deploy.wsdd and
AddressBookSOAPBindingImpl.java files.
 
//----------------------------------------------------------------------
----------
<deployment xmlns="http://xml.apache.org/axis/wsdd/"
xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  <handler name="session"
type="java:org.apache.axis.handlers.SimpleSessionHandler"/>
  <service name="AddressBook" provider="java:RPC" style="rpc"
use="encoded">
      <requestFlow>
        <handler type="session"/>
      </requestFlow>
      <responseFlow>
        <handler type="session"/>
      </responseFlow>
      <parameter name="wsdlTargetNamespace"
value="urn:AddressFetcher2"/>
      <parameter name="wsdlServiceElement" value="AddressBookService"/>
      <parameter name="wsdlServicePort" value="AddressBook"/>
      <parameter name="className"
value="aly.learn.webSrvs.addr.AddressBookSOAPBindingSkeleton"/>
      <parameter name="wsdlPortType" value="AddressBook"/>
      <parameter name="allowedMethods" value="*"/>
      <parameter name="scope" value="Session"/>
      <typeMapping
        xmlns:ns="urn:AddressFetcher2"
        qname="ns:phone"
        type="java:aly.learn.webSrvs.addr.Phone"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
 
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      />
      <typeMapping
        xmlns:ns="urn:AddressFetcher2"
        qname="ns:address"
        type="java:aly.learn.webSrvs.addr.Address"
        serializer="org.apache.axis.encoding.ser.BeanSerializerFactory"
 
deserializer="org.apache.axis.encoding.ser.BeanDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      />
      <typeMapping
        xmlns:ns="urn:AddressFetcher2"
        qname="ns:stateType"
        type="java:aly.learn.webSrvs.addr.StateType"
        serializer="org.apache.axis.encoding.ser.EnumSerializerFactory"
 
deserializer="org.apache.axis.encoding.ser.EnumDeserializerFactory"
        encodingStyle="http://schemas.xmlsoap.org/soap/encoding/"
      />
  </service>
</deployment>
 
//-----------------------------------------------------------------
package aly.learn.webSrvs.addr;
 
import java.util.HashMap;
import java.util.Map;
import org.apache.axis.MessageContext;
import org.apache.axis.session.Session;
 
public class AddressBookSOAPBindingImpl implements AddressBook 
{
    private static String addressesName = "ADDR_MAP_NAME";
//    private Map addrMap = new HashMap();
 
    public void addEntry(String name, Address address) throws
java.rmi.RemoteException 
    {
        MessageContext mc = MessageContext.getCurrentContext();
        Session session = mc.getSession();
        Object value = session.get(addressesName);
        
        Map addrMap = (Map) session.get(addressesName);
        if(addrMap == null)
        {
            System.out.println("addEntry(): No addr map in session
yet!");
            addrMap = new HashMap(); 
            session.set(addressesName, addrMap);
        }
        
        addrMap.put(name, address);
    }
    
    public Address getAddressFromName(java.lang.String name) throws
java.rmi.RemoteException 
    {
        Address addr = null;
        
        MessageContext mc = MessageContext.getCurrentContext();
        Session session = mc.getSession();
        Object value = session.get(addressesName);
        
        if(value == null)
                  System.out.println("getAddressFromName(): No addr map
in session yet!");
        else
        {
            Map addrMap = (Map)value;
            addr = (Address)addrMap.get(name);
        }
                  
        return addr;
    }
}

Mime
View raw message