org.apache.muse.core
Class AbstractResourceClient

java.lang.Object
  extended by org.apache.muse.core.AbstractResourceClient
All Implemented Interfaces:
Traceable, SoapMonitor
Direct Known Subclasses:
MetadataExchangeClient, WsResourceClient

public abstract class AbstractResourceClient
extends Object
implements Traceable, SoapMonitor

AbstractResourceClient is a base class for resource clients that are deployed as doc-literal services using WS-Addressing. It can be used to send raw SOAP messages to web services, but it mainly serves as the foundation for more concrete client classes.

Author:
Dan Jemiolo (danj)

Constructor Summary
AbstractResourceClient(EndpointReference destination)
          This is a convenience constructor that calls this(EndpointReference, EndpointReference) with the WS-A anonymous EPR as the second parameter (the source EPR).
AbstractResourceClient(EndpointReference destination, EndpointReference source)
          This is a convenience constructor that calls this(EndpointReference, EndpointReference, SoapClient) with an instance of SimpleSoapClient.
AbstractResourceClient(EndpointReference destination, EndpointReference source, Environment environment)
          This is a convenience constructor that calls this(EndpointReference, EndpointReference, SoapClient) with the SoapClient provided by the given Environment.
AbstractResourceClient(EndpointReference destination, EndpointReference source, SoapClient soapClient)
           
 
Method Summary
 EndpointReference getDestination()
           
 EndpointReference getEndpointReference()
           
 SoapClient getSoapClient()
           
 int getSoapMonitorPort()
           
 EndpointReference getSource()
           
 PrintWriter getTraceWriter()
           
 Object invoke(ProxyHandler handler, Object[] parameters)
          This is a convenience method that uses the given ProxyHandler to serialize the parameters (and deserialize the response) before calling invoke(String, Element).
 Object invoke(ProxyHandler handler, Object[] parameters, Element[] extraHeaders)
          This is a convenience method that uses the given ProxyHandler to serialize the parameters (and deserialize the response) before calling invoke(String, Element).
 Element invoke(String action, Element soapBody)
          A generic method invocation mechanism - this can be used by other proxy methods as well as users in order to send arbitrary requests to a resource.
 Element invoke(String action, Element soapBody, Element[] extraHeaders)
          A generic method invocation mechanism - this can be used by other proxy methods as well as users in order to send arbitrary requests to a resource.
 boolean isUsingSoapMonitor()
           
 boolean isUsingTrace()
           
 void setTrace(boolean trace)
           
 void setTraceWriter(PrintWriter writer)
           
 void startSoapMonitor(int monitorPort)
          Causes the SoapClient to send messages to the given port.
 void stopSoapMonitor()
          If SOAP monitoring was in use, the client will revert back to sending the messages to the port in the EPR's wsa:Address.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AbstractResourceClient

public AbstractResourceClient(EndpointReference destination)
This is a convenience constructor that calls this(EndpointReference, EndpointReference) with the WS-A anonymous EPR as the second parameter (the source EPR).

See Also:
WsaConstants.ANONYMOUS_EPR

AbstractResourceClient

public AbstractResourceClient(EndpointReference destination,
                              EndpointReference source)
This is a convenience constructor that calls this(EndpointReference, EndpointReference, SoapClient) with an instance of SimpleSoapClient.

See Also:
AbstractResourceClient(EndpointReference, EndpointReference, SoapClient)

AbstractResourceClient

public AbstractResourceClient(EndpointReference destination,
                              EndpointReference source,
                              Environment environment)
This is a convenience constructor that calls this(EndpointReference, EndpointReference, SoapClient) with the SoapClient provided by the given Environment.

See Also:
AbstractResourceClient(EndpointReference, EndpointReference, SoapClient), Environment.getSoapClient()

AbstractResourceClient

public AbstractResourceClient(EndpointReference destination,
                              EndpointReference source,
                              SoapClient soapClient)
Parameters:
destination - The EPR of the resource that will receive requests.
source - The EPR of the resource that is sending requests.
soapClient - The SOAP client that will be used to package and send requests.
Method Detail

getDestination

public EndpointReference getDestination()
Returns:
The EPR of the resource receiving requests.

getEndpointReference

public EndpointReference getEndpointReference()
Returns:
The EPR of the resource receiving requests. This is the same value returned by getDestination().

getSoapClient

public SoapClient getSoapClient()
Returns:
The SOAP client being used to send requests.

getSoapMonitorPort

public int getSoapMonitorPort()
Specified by:
getSoapMonitorPort in interface SoapMonitor
Returns:
The port to which messages are being sent when TCP/SOAP monitoring is being used. When no monitoring is used (normal mode), this returns -1.

getSource

public EndpointReference getSource()
Returns:
The EPR of the resource sending the requests.

getTraceWriter

public PrintWriter getTraceWriter()
Specified by:
getTraceWriter in interface Traceable
Returns:
The trace log.

invoke

public Object invoke(ProxyHandler handler,
                     Object[] parameters)
              throws SoapFault
This is a convenience method that uses the given ProxyHandler to serialize the parameters (and deserialize the response) before calling invoke(String, Element).

Throws:
SoapFault
See Also:
invoke(String, Element)

invoke

public Object invoke(ProxyHandler handler,
                     Object[] parameters,
                     Element[] extraHeaders)
              throws SoapFault
This is a convenience method that uses the given ProxyHandler to serialize the parameters (and deserialize the response) before calling invoke(String, Element).

Throws:
SoapFault
See Also:
invoke(String, Element)

invoke

public Element invoke(String action,
                      Element soapBody)
               throws SoapFault
A generic method invocation mechanism - this can be used by other proxy methods as well as users in order to send arbitrary requests to a resource.

The parameters are wrapped in a SOAP envelope and sent to the destination using the proxy's SoapClient. If a SOAP Fault is returned, it is parsed and thrown as a SoapFault object.

Returns:
The SOAP Body from the response message, or null if there was no response.
Throws:
SoapFault

invoke

public Element invoke(String action,
                      Element soapBody,
                      Element[] extraHeaders)
               throws SoapFault
A generic method invocation mechanism - this can be used by other proxy methods as well as users in order to send arbitrary requests to a resource.

The parameters are wrapped in a SOAP envelope and sent to the destination using the proxy's SoapClient. If a SOAP Fault is returned, it is parsed and thrown as a SoapFault object.

The 'extra headers' provided must be outside of the WS-Addressing namespace - all WS-A headers are provided by the endpoint references for the source and destination.

Returns:
The SOAP Body from the response message, or null if there was no response.
Throws:
SoapFault

isUsingSoapMonitor

public boolean isUsingSoapMonitor()
Specified by:
isUsingSoapMonitor in interface SoapMonitor
Returns:
True if messages are being redirected to a SOAP monitor port.

isUsingTrace

public boolean isUsingTrace()
Specified by:
isUsingTrace in interface Traceable
Returns:
True if tracing is turned on.

setTrace

public void setTrace(boolean trace)
Specified by:
setTrace in interface Traceable
Parameters:
trace - If 'true', tracing is turned on and messages sent to the trace log.

setTraceWriter

public void setTraceWriter(PrintWriter writer)
Specified by:
setTraceWriter in interface Traceable
Parameters:
writer - The trace log - note that you can make a PrintWriter from System.out and System.err by wrapping these fields in an instance of PrintWriter.

startSoapMonitor

public void startSoapMonitor(int monitorPort)
Description copied from interface: SoapMonitor
Causes the SoapClient to send messages to the given port. This does not change the port number in the WS-A EPR found in the SOAP headers. The receiver will have no idea it is taking part in SOAP monitoring. Only the original HTTP GET will have a different port.

Specified by:
startSoapMonitor in interface SoapMonitor
Parameters:
monitorPort - A positive integer - 0 to 65535.

stopSoapMonitor

public void stopSoapMonitor()
Description copied from interface: SoapMonitor
If SOAP monitoring was in use, the client will revert back to sending the messages to the port in the EPR's wsa:Address. If SOAP monitoring was not in use, the call is a no-op.

Specified by:
stopSoapMonitor in interface SoapMonitor


Copyright © 2005-2011 Apache Web Services - Muse. All Rights Reserved.