net.ivoa.registry.search
Class DefaultServiceCaller

java.lang.Object
  extended by net.ivoa.registry.search.DefaultServiceCaller
All Implemented Interfaces:
ServiceCaller
Direct Known Subclasses:
MessagePrintingServiceCaller

public class DefaultServiceCaller
extends java.lang.Object
implements ServiceCaller

a default implementation of the ServiceCaller interface for calling a SOAP service. It simply calls sends the input SOAP message and returns the response. It checks the response for faults and throws the appropriate exception. This implementation can also be used as a base class for overriding or extending the call method. This interface is intended for the so-called wrapped document style of SOAP messaging in that the call() method is supposed to return the wrapping element from inside the SOAP body of the service response message.


Field Summary
protected  SOAPConnection conn
           
static java.lang.String GENERAL_FAULT
          the general registry interface fault element tag name
static java.lang.String NOT_FOUND_FAULT
          the tag name for the id-not-found registry interface fault element
static java.lang.String SOAP_NS
          the SOAP v1.1 namespace URI string
static java.lang.String UNSUPPORTED_OPERATION_FAULT
          the tag name for the unsupported operation registry interface fault element
 
Constructor Summary
DefaultServiceCaller()
          create a default ServiceCaller object
DefaultServiceCaller(SOAPConnection connection, java.net.URL endpoint)
          create a default ServiceCaller object
DefaultServiceCaller(java.net.URL endpoint)
          create a default ServiceCaller object
 
Method Summary
 org.w3c.dom.Element call(SOAPMessage msg, java.lang.String actionURI)
          call the SOAP service and return the content of the body the SOAP response.
static void checkForFaults(org.w3c.dom.Element bodyelement)
          check the given element representing the contents of the SOAP body to see if it is a SOAP Fault and throw the appropriate exception
protected  org.w3c.dom.Element extractContent(SOAPMessage resp)
          extract the content of the SOAP response.
 java.net.URL getEndpoint()
          get the service endpoint URL currently in use
static java.lang.String getMessage(org.w3c.dom.Element rifault)
          given the contents of registry interface fault element, return the enclosed error message.
protected  SOAPMessage getReplyFromCall(SOAPMessage msg, java.lang.String actionURI)
          call the service and return the SOAPMessage response
 void setEndpoint(java.net.URL endpoint)
          set the service endpoint URL
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

conn

protected SOAPConnection conn

SOAP_NS

public static final java.lang.String SOAP_NS
the SOAP v1.1 namespace URI string

See Also:
Constant Field Values

GENERAL_FAULT

public static final java.lang.String GENERAL_FAULT
the general registry interface fault element tag name

See Also:
Constant Field Values

NOT_FOUND_FAULT

public static final java.lang.String NOT_FOUND_FAULT
the tag name for the id-not-found registry interface fault element

See Also:
Constant Field Values

UNSUPPORTED_OPERATION_FAULT

public static final java.lang.String UNSUPPORTED_OPERATION_FAULT
the tag name for the unsupported operation registry interface fault element

See Also:
Constant Field Values
Constructor Detail

DefaultServiceCaller

public DefaultServiceCaller(SOAPConnection connection,
                            java.net.URL endpoint)
create a default ServiceCaller object

Parameters:
connection - the SOAPConnection object to use to connect to the service. If null, a default connection will be created.
endpoint - the service's endpoint URL.

DefaultServiceCaller

public DefaultServiceCaller(java.net.URL endpoint)
create a default ServiceCaller object

Parameters:
endpoint - the service's endpoint URL

DefaultServiceCaller

public DefaultServiceCaller()
create a default ServiceCaller object

Method Detail

setEndpoint

public void setEndpoint(java.net.URL endpoint)
set the service endpoint URL

Specified by:
setEndpoint in interface ServiceCaller

getEndpoint

public java.net.URL getEndpoint()
get the service endpoint URL currently in use

Specified by:
getEndpoint in interface ServiceCaller

call

public org.w3c.dom.Element call(SOAPMessage msg,
                                java.lang.String actionURI)
                         throws RegistryServiceException,
                                SOAPException
call the SOAP service and return the content of the body the SOAP response. This assumes a wrapped document message style in which the body contains a single child element.

Specified by:
call in interface ServiceCaller
Parameters:
msg - the input SOAP message to send
action - the SOAP action URI to use
Throws:
SOAPException - if an error occurs while handling the SOAP.
RegistryServiceException - if any errors occurs while communicating with the service.

getReplyFromCall

protected SOAPMessage getReplyFromCall(SOAPMessage msg,
                                       java.lang.String actionURI)
                                throws SOAPException
call the service and return the SOAPMessage response

Throws:
SOAPException

extractContent

protected org.w3c.dom.Element extractContent(SOAPMessage resp)
                                      throws RegistryServiceException,
                                             SOAPException
extract the content of the SOAP response. The response is checked for faults.

Throws:
RegistryServiceException
SOAPException

checkForFaults

public static void checkForFaults(org.w3c.dom.Element bodyelement)
                           throws RegistryServiceException
check the given element representing the contents of the SOAP body to see if it is a SOAP Fault and throw the appropriate exception

Throws:
RegistryServiceException

getMessage

public static java.lang.String getMessage(org.w3c.dom.Element rifault)
                                   throws org.w3c.dom.DOMException
given the contents of registry interface fault element, return the enclosed error message. The fault element is one defined in the registry interface search WSDL.

Throws:
org.w3c.dom.DOMException