org.apache.muse.ws.addressing.soap
Class SimpleSoapClient

java.lang.Object
  extended by org.apache.muse.ws.addressing.soap.SimpleSoapClient
All Implemented Interfaces:
Traceable, SoapClient, SoapMonitor

public class SimpleSoapClient
extends Object
implements SoapClient

SimpleSoapClient is and implementation of SoapClient that relies on the java.net.HttpURLConnection API to send and receive SOAP messages. It provides complete WS-Addressing (WS-A) support, so that all requests are routed with WS-A EPRs and Actions. Messages are sent with valid reply and fault EPRs so that responses can be redirected if desired.

Author:
Dan Jemiolo (danj)

Constructor Summary
SimpleSoapClient()
           
 
Method Summary
protected  Element createMessage(EndpointReference source, EndpointReference destination, String action, Element[] bodyElements, Element[] extraHeaders)
          Creates a valid SOAP message, including WS-A headers that specify the destination and operation (action).
protected  URL getDestinationURL(EndpointReference destination)
           
 int getSoapMonitorPort()
           
 PrintWriter getTraceWriter()
           
 boolean isUsingSoapMonitor()
          

The default value is 'false'.
 boolean isUsingTrace()
          

The default value is 'false'.
 Element[] send(EndpointReference src, EndpointReference dest, String wsaAction, Element[] body)
          Sends a SOAP envelope with the given body to the given destination.
 Element[] send(EndpointReference src, EndpointReference dest, String wsaAction, Element[] body, Element[] extraHeaders)
          Sends a SOAP envelope with the given body to the given destination.
 void setTrace(boolean trace)
           
 void setTraceWriter(PrintWriter writer)
          

Note that there is a default PrintWriter set at instantiation - it wraps the System.out stream.
 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.
protected  void trace(Element xml, boolean incoming)
           
protected  void trace(String message)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleSoapClient

public SimpleSoapClient()
Method Detail

createMessage

protected Element createMessage(EndpointReference source,
                                EndpointReference destination,
                                String action,
                                Element[] bodyElements,
                                Element[] extraHeaders)
Creates a valid SOAP message, including WS-A headers that specify the destination and operation (action). The WS-A headers include proper return/fault information for the recipient to use in response. The 'extra headers' are SOAP header elements that do not belong to the WS-A namespace.

Parameters:
source -
destination -
action -
bodyElements -
extraHeaders -
Returns:
A valid SOAP message that can be sent to the destination.

getDestinationURL

protected URL getDestinationURL(EndpointReference destination)
Parameters:
destination -
Returns:
The URL of the EPR's wsa:Address. If SOAP monitoring is on, the URL's port is switched to the monitor port.

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.

getTraceWriter

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

isUsingSoapMonitor

public boolean isUsingSoapMonitor()


The default value is 'false'.

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

isUsingTrace

public boolean isUsingTrace()


The default value is 'false'.

Specified by:
isUsingTrace in interface Traceable
Returns:
True if tracing is turned on.

send

public Element[] send(EndpointReference src,
                      EndpointReference dest,
                      String wsaAction,
                      Element[] body)
Description copied from interface: SoapClient
Sends a SOAP envelope with the given body to the given destination. The SOAP header will include WS-A headers, one of which will be the WS-A Action specified in the third parameter. This method is not asynchronous - it will wait for a response and return the contents of the SOAP body.

Specified by:
send in interface SoapClient
Parameters:
src - The EPR of the service sending the message.
dest - The EPR of the service that will receive the message.
wsaAction - The WS-A Action that specifies the operation to be invoked on the destination service.
body - The contents of the SOAP body.
Returns:
The contents of the SOAP body in the response message. If the request resulted in a fault, the contents will include the fault XML. Note that such faults are not related to basic networking/SOAP faults.

send

public Element[] send(EndpointReference src,
                      EndpointReference dest,
                      String wsaAction,
                      Element[] body,
                      Element[] extraHeaders)
Description copied from interface: SoapClient
Sends a SOAP envelope with the given body to the given destination. The SOAP header will include WS-A headers, one of which will be the WS-A Action specified in the third parameter. This method is not asynchronous - it will wait for a response and return the contents of the SOAP body.

Specified by:
send in interface SoapClient
Parameters:
src - The EPR of the service sending the message.
dest - The EPR of the service that will receive the message.
wsaAction - The WS-A Action that specifies the operation to be invoked on the destination service.
body - The contents of the SOAP body.
extraHeaders - SOAP header elements that should be added to the outgoing message. These headers must not use the WS-Addressing namespace.
Returns:
The contents of the SOAP body in the response message. If the request resulted in a fault, the contents will include the fault XML. Note that such faults are not related to basic networking/SOAP faults.

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)


Note that there is a default PrintWriter set at instantiation - it wraps the System.out stream.

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

trace

protected void trace(Element xml,
                     boolean incoming)
Parameters:
xml - An XML fragment that will be sent to the trace log.
incoming - True if the message was part of an incoming SOAP message. This merely provides some context in the trace log.

trace

protected void trace(String message)
Parameters:
message - The message to print to the trace log.


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