org.apache.muse.core
Class AbstractResourceClient

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

public abstract class AbstractResourceClient
extends java.lang.Object
implements 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()
           
 java.io.PrintWriter getTraceWriter()
           
 java.lang.Object invoke(ProxyHandler handler, java.lang.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).
 java.lang.Object invoke(ProxyHandler handler, java.lang.Object[] parameters, org.w3c.dom.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).
 org.w3c.dom.Element invoke(java.lang.String action, org.w3c.dom.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.
 org.w3c.dom.Element invoke(java.lang.String action, org.w3c.dom.Element soapBody, org.w3c.dom.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(java.io.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 java.io.PrintWriter getTraceWriter()

invoke

public java.lang.Object invoke(ProxyHandler handler,
                               java.lang.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 java.lang.Object invoke(ProxyHandler handler,
                               java.lang.Object[] parameters,
                               org.w3c.dom.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 org.w3c.dom.Element invoke(java.lang.String action,
                                  org.w3c.dom.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 org.w3c.dom.Element invoke(java.lang.String action,
                                  org.w3c.dom.Element soapBody,
                                  org.w3c.dom.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()

setTrace

public void setTrace(boolean trace)

setTraceWriter

public void setTraceWriter(java.io.PrintWriter writer)

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