org.iids.aos.webservices.axisstub
Class WSStubber

java.lang.Object
  extended by org.iids.aos.webservices.axisstub.WSStubber

public class WSStubber
extends java.lang.Object

Utility to connect to a service using the WSGatway service.

A partial rewrite of the original version. Initially, the WSGateway could be contacted using the SystemService proxy mechanism. The WSGateway is now changed so that is uses an agent to perform interaction with the outside world. This change was necessary because only AgentScape 0.8.x based agents could contact the service.

Seeing as 0.9 and further has no WSGateway stuff in the API anymore, we try to approach this in a little more generic way, ie by letting the service publish itself through the lookup service, and allowing other agents to contact the service using the AgentProxy (agent messaging).

Some legacy code may still be here, but cleanup is on its way.

TODO may need to migrate to Axis2. The new Axis2 version is already used for allowing incoming WSDL invocations to agents, might as well do this the other way round (though it is a bit complext - v1 and v2 differ quite a lot).

Author:
rjtimmer

Constructor Summary
WSStubber(java.lang.Object axisStubLocator, java.lang.String wsdl, AgentHandle local, AgentScapeID location)
          Creates and stores a lease for communication with a web service by an agent.
 
Method Summary
static WSGateway connectToWSGateway(AgentHandle handle)
           
static WSGateway connectToWSGateway(AgentScapeID location)
          Connect to the WSGateway for a certain location.
 java.lang.Object createStub(java.lang.String portName)
          Returns a stub with which the calling agent may access a specific port that is part of a web service.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

WSStubber

public WSStubber(java.lang.Object axisStubLocator,
                 java.lang.String wsdl,
                 AgentHandle local,
                 AgentScapeID location)
          throws java.lang.ClassCastException,
                 java.net.MalformedURLException,
                 CouldNotParseWSDL,
                 NoExclusiveTransport,
                 AgentScapeException
Creates and stores a lease for communication with a web service by an agent.

Parameters:
axisStubLocator - an Axis service locator object for the web service, as generated by WSDL2Java
wsdl - a URL pointing to a WSDL document
local - a local AgentHandle to contact the WSGatewayAgent
location - the location on where the WSGatewayAgent is running
Throws:
java.lang.ClassCastException - if axisStubLocator did not contain the correct methods
java.net.MalformedURLException - if wsdl was not a valid URL
CouldNotParseWSDL - if an error occurred while parsing the WSDL document
NoExclusiveTransport - the WS gateway did not grant 'exclTransport = true'
AgentScapeException - problem connecting to the gateway
See Also:
WSGateway.requestWSDLAccess(java.lang.String, java.lang.String, java.lang.String, java.lang.Boolean, org.iids.aos.systemservices.communicator.structs.AgentHandle)
Method Detail

createStub

public java.lang.Object createStub(java.lang.String portName)
                            throws java.lang.ClassCastException,
                                   javax.xml.rpc.ServiceException
Returns a stub with which the calling agent may access a specific port that is part of a web service. Uses the lease created in the constructor and uses the axisStubLocator and agentscape API that were passed to the constructor.

Parameters:
portName - the name of the port to access within the web service
Returns:
a stub that implements the operations of the port, by communicating with the web service through AgentScape's WSGateway. The Java type of this stub is the Java interface generated by WSDL2Java corresponding to the WSDL portType of the port. A quick way to find out the Java type is to look at the get() methods inside the generated ServiceLocator implementation.
Throws:
java.lang.ClassCastException - if axisStubLocator did not contain the correct methods
javax.xml.rpc.ServiceException - if an error occurred while Axis created the stub

connectToWSGateway

public static WSGateway connectToWSGateway(AgentScapeID location)
                                    throws AgentScapeException
Connect to the WSGateway for a certain location.

Actually, maybe an agent should only be allowed to contact the gateway on its own location? Because we use agent messages, these could be from anywhere basically. This may be solved eventuall with local handles, no?

Parameters:
location -
Returns:
WSGateway
Throws:
AgentScapeException

connectToWSGateway

public static WSGateway connectToWSGateway(AgentHandle handle)


Copyright © 2003, 2004 IIDS Group. All Rights Reserved.