|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.jibx.ws.client.Client org.jibx.ws.soap.client.SoapClient
public final class SoapClient
A client for accessing SOAP web services.
Typically, this class will be configured to use JiBX bindings for marshalling the request payload and unmarshalling the response payload for example using:
SoapClient soapClient = new SoapClient("http://mystockws.com", BindingDirectory.getFactory(Ticker.class)); response = soapClient.call(request);
To configure a client with different bindings for Request and Response classes:
SoapClient soapClient = new SoapClient(path); soapClient.setOutBodyBindingFactory(BindingDirectory.getFactory(Request.class)); soapClient.setInBodyBindingFactory(BindingDirectory.getFactory(Response.class)); response = soapClient.call(request);
If a SOAP Fault occurs, the call
method will throw a SoapFaultException
. Any detail elements
of the SOAP fault are skipped unless handlers are configured to read the SOAP fault detail elements, see
addInFaultDetailsHandler(InHandler)
or addInFaultDetailsBindingFactory(IBindingFactory)
.
By default an encoding of UTF-8 is used, the outbound XML is unformatted and contains an XML declaration of
<?xml version="1.0" encoding="UTF-8"?>
. The encoding, XML declaration and formatting of the
outbound message can be overridden by calling Client.setMessageOptions(MessageOptions)
.
Constructor Summary | |
---|---|
SoapClient(String location)
Create a SOAP 1.1 client to connect to a service at the specified location. |
|
SoapClient(String location,
IBindingFactory factory)
Create a SOAP 1.1 client to connect to a service at the specified location. |
|
SoapClient(String location,
IBindingFactory factory,
MessageOptions options)
Create a SOAP 1.1 client to connect to a service at the specified location. |
|
SoapClient(String location,
IBindingFactory factory,
MessageOptions options,
SoapProtocol protocol)
Create a SOAP client to connect to a service at the specified location. |
Method Summary | |
---|---|
void |
addInFaultDetailsBindingFactory(IBindingFactory factory)
Adds a JiBX binding factory for the inbound SOAP fault details. |
void |
addInFaultDetailsHandler(InHandler inFaultDetailsHandler)
Adds a handler to use for reading the SOAP fault details. |
void |
addInHeaderHandler(InHandler headerHandler)
Adds the specified header handler to the inbound processing. |
void |
addOutHeader(Object obj)
Adds the specified object as a header to the outbound message. |
void |
addOutHeaderHandler(OutHandler headerHandler)
Adds the specified header handler to the outbound processing. |
Object |
call(Object request)
Call the service with specified operation name. |
void |
removeAllHandlers()
Removes all header handlers and inbound fault details handlers. |
void |
removeInFaultDetailsHandlers()
Removes all inbound fault details handlers. |
void |
removeInHeaderHandlers()
Removes all inbound header handlers. |
void |
removeOutHeaderHandlers()
Removes all outbound header handlers. |
void |
setBindingFactory(IBindingFactory factory)
Sets a single JiBX binding factory to be used for for marshalling and unmarshalling the SOAP body and unmarshalling any SOAP fault details. |
void |
setInHeaderHandlers(List inHeaderHandlers)
Sets the inbound header handlers. |
void |
setOperationName(String operationName)
Sets the name of the operation to be called. |
void |
setOutHeaderHandlers(List outHeaderHandlers)
Sets the outbound header handlers. |
void |
setProtocol(SoapProtocol protocol)
Set SOAP protocol version. |
void |
setSoapEncodingStyle(String encodingStyle)
Sets the optional SOAP encodingStyle attribute on the SOAP envelope. |
void |
setSoapFaultResolver(SoapFaultResolver soapFaultResolver)
Sets the SOAP fault resolver. |
Methods inherited from class org.jibx.ws.client.Client |
---|
close, setInBodyBindingFactory, setMessageOptions, setOutBodyBindingFactory, setTransportOptions |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public SoapClient(String location) throws WsConfigurationException
location
- the location of the service
WsConfigurationException
- on configuration exception, for instance the location is invalid.public SoapClient(String location, IBindingFactory factory) throws WsBindingException, WsConfigurationException
location
- the location of the servicefactory
- the factory containing bindings for the outbound SOAP body, inbound SOAP body and inbound SOAP
fault details. Bindings are only required for non-empty outbound or inbound SOAP bodies. If SOAP fault details
are received that do not match any of the bindings, the SOAP fault details will be skipped.
WsBindingException
- if client cannot be created due to an error with the JiBX bindings
WsConfigurationException
- on configuration exception, for instance the location is invalid.public SoapClient(String location, IBindingFactory factory, MessageOptions options) throws WsBindingException, WsConfigurationException
location
- the location of the servicefactory
- the factory containing bindings for the outbound SOAP body, inbound SOAP body and inbound SOAP
fault details. Bindings are only required for non-empty outbound or inbound SOAP bodies. If SOAP fault details
are received that do not match any of the bindings, the SOAP fault details will be skipped.options
- output options
WsBindingException
- if client cannot be created due to an error with the JiBX bindings
WsConfigurationException
- on configuration exception, for instance the location is invalid.public SoapClient(String location, IBindingFactory factory, MessageOptions options, SoapProtocol protocol) throws WsBindingException, WsConfigurationException
location
- the location of the servicefactory
- the factory containing bindings for the outbound SOAP body, inbound SOAP body and inbound SOAP
fault details. Bindings are only required for non-empty outbound or inbound SOAP bodies. If SOAP fault details
are received that do not match any of the bindings, the SOAP fault details will be skipped.options
- output optionsprotocol
- the version of the SOAP protocol for the client to use
WsBindingException
- if client cannot be created due to an error with the JiBX bindings
WsConfigurationException
- on configuration exception, for instance the location is invalid.Method Detail |
---|
public void setProtocol(SoapProtocol protocol)
SoapProtocol
for supported protocols.
protocol
- the version of SOAP protocolpublic void setBindingFactory(IBindingFactory factory) throws WsBindingException
For finer grain control of the different elements use Client.setOutBodyBindingFactory(IBindingFactory)
,
Client.setInBodyBindingFactory(IBindingFactory)
and addInFaultDetailsBindingFactory(IBindingFactory)
.
setBindingFactory
in class Client
factory
- the binding factory to use for outbound and/or inbound SOAP bodies, and/or SOAP fault details
WsBindingException
- if marshaller cannot be created due to an error with the JiBX bindingspublic void setOperationName(String operationName)
operationName
- the operation namepublic void setSoapEncodingStyle(String encodingStyle)
null
, then no encodingStyle attribute is added.
encodingStyle
- value to set in encodingStyle attributepublic void setOutHeaderHandlers(List outHeaderHandlers) throws WsConfigurationException
outHeaderHandlers
- the list of OutHandler
WsConfigurationException
- if the list contains objects of type other than OutHandler
s.public void addOutHeaderHandler(OutHandler headerHandler)
headerHandler
- the handler that will write the headerpublic void addOutHeader(Object obj) throws WsException
obj
- the object to include in the header
WsException
- if binding cannot be found, or other errorpublic void removeOutHeaderHandlers()
public void setInHeaderHandlers(List inHeaderHandlers) throws WsConfigurationException
inHeaderHandlers
- the list of InHandler
WsConfigurationException
- if the list contains objects of type other than InHandler
s.public void addInHeaderHandler(InHandler headerHandler)
InHandler.invoke(InContext, org.jibx.runtime.IXMLReader)
method, when the processing of that header is
deemed to be complete, and processing carries on with the next header.
headerHandler
- the handler that will write the headerpublic void removeInHeaderHandlers()
public void addInFaultDetailsBindingFactory(IBindingFactory factory) throws WsBindingException
SoapFault
and all other handlers will be skipped.
factory
- the JiBX binding factory to use for reading the inbound SOAP body
WsBindingException
- if unmarshaller cannot be created due to an error with the JiBX bindingspublic void addInFaultDetailsHandler(InHandler inFaultDetailsHandler)
SoapFault
and all other handlers will be skipped.
inFaultDetailsHandler
- the handler to use for reading the SOAP fault detailspublic void removeInFaultDetailsHandlers()
public void removeAllHandlers()
public void setSoapFaultResolver(SoapFaultResolver soapFaultResolver)
soapFaultResolver
- the resolverpublic Object call(Object request) throws IOException, WsException
call
in class Client
request
- object to be marshalled to XML as body of request (may be null
, for an empty
request body)
null
, for an empty response
body)
IOException
- on error in communicating with service
WsException
- on error in SOAP request processing, or a WsConfigurationException if either:
request
is non null and a binding factory or handler has not been set for the outbound SOAP
body, orSoapFaultException
- if the service returns a SOAP fault, and a custom SoapFaultResolver
has not
been set.
|
||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |