public class WSConnection extends BaseConnection<BrowseContext>
The most common customization of this class will be changing how the WebServiceExecutor is configured before
execution. The main entry point for this customization is the configureExecutor(com.boomi.model.connector.common.webservices.WebServiceOperation, java.lang.String, com.boomi.webservices.WebServiceExecutor)
method. One common
customization is choosing one of the predefined security types, which can be configured by adding a call to
configureBasicAuthSecurity(com.boomi.webservices.WebServiceExecutor)
or configureUsernameWSSecurity(com.boomi.model.connector.common.webservices.UserTokenPasswordType, com.boomi.webservices.WebServiceExecutor)
.
Modifier and Type | Field and Description |
---|---|
static String |
AUTH_TYPE_PROPERTY
connection property which users can use to set the authentication type
|
static String |
DEFAULT_SUCCESS_CODE
default status code used for successful response documents
|
static String |
PASSWORD_PROPERTY
connection property which users can use to set the password
|
static String |
URL_PROPERTY
connection property which users can use to change/specify the base url
|
static String |
USERNAME_PROPERTY
connection property which users can use to set the username
|
static String |
WS_SECURITY_PROPERTY
connection property which users can use to set the WS-Security options
|
Constructor and Description |
---|
WSConnection(BrowseContext context) |
Modifier and Type | Method and Description |
---|---|
protected static void |
appendErrorDetail(Element detail,
StringBuilder sb,
List<String> path)
Appends any non-empty details to the given StringBuilder.
|
protected void |
configureBasicAuthNonPreemptiveSecurity(com.boomi.webservices.WebServiceExecutor executor)
Configures the given WebServiceExecutor for "http basic auth" security support using the username and password
retrieved from calls to
getUsername() and getPassword() . |
protected void |
configureBasicAuthSecurity(com.boomi.webservices.WebServiceExecutor executor)
Configures the given WebServiceExecutor for "http basic auth" security support using the username and password
retrieved from calls to
getUsername() and getPassword() . |
protected void |
configureCustomWSSecurity(com.boomi.webservices.WebServiceExecutor executor) |
protected void |
configureExecutor(com.boomi.model.connector.common.webservices.WebServiceOperation operation,
String operationName,
com.boomi.webservices.WebServiceExecutor executor)
Configures the given WebServiceExecutor using the given web service operation information.
|
protected void |
configureSecurity(com.boomi.webservices.WebServiceExecutor executor)
Configures the given WebServiceExecutor for security support based on the auth type retrieved from
getAuthType() , delegating to configureBasicAuthSecurity(com.boomi.webservices.WebServiceExecutor) or configureUsernameWSSecurity(com.boomi.model.connector.common.webservices.UserTokenPasswordType, com.boomi.webservices.WebServiceExecutor)
as appropriate. |
protected void |
configureUsernameWSSecurity(com.boomi.model.connector.common.webservices.UserTokenPasswordType pwdType,
com.boomi.webservices.WebServiceExecutor executor)
Configures the given WebServiceExecutor for "WSSecurity username" security support (for the given password type)
using the username and password retrieved from calls to
getUsername() and getPassword() . |
NetworkAuthenticator |
createAuthenticator()
This method creates a
SimpleNetworkAuthenticator for
WebServiceAuthenticationType.NETWORK_AUTHENTICATION type connections. |
com.boomi.webservices.WebServiceExecutor |
createExecutor(String operationName)
Creates and configures a WebServiceExecutor for the given operationName.
|
com.boomi.model.connector.common.webservices.WebServiceAuthenticationType |
getAuthType()
Returns the authentication configured for this connection.
|
WSCache |
getCache()
Returns the connector cache for use for this connection, creating it if necessary.
|
WSConnector |
getConnector()
Returns a handle to the connector with which this connection is associated.
|
String |
getDefaultUrl()
Returns the "default" url for this web service to be used if none has been configured.
|
String |
getErrorCode(com.boomi.webservices.WebServiceResponse wsResponse)
Returns the error status code for the given fault response.
|
String |
getErrorMessage(com.boomi.webservices.WebServiceResponse wsResponse)
Returns the error status message for the given fault response.
|
String |
getPassword()
Returns the password configured for this connection.
|
protected SSLContext |
getSSLContext()
Gets the SSL Context to set on the
WebServiceExecutor during call to configureExecutor(com.boomi.model.connector.common.webservices.WebServiceOperation, java.lang.String, com.boomi.webservices.WebServiceExecutor) . |
String |
getSuccessCode()
Returns the status code to use for successful responses.
|
String |
getSuccessMessage()
Returns the status message to use for successful responses.
|
String |
getUrl()
Returns the currently configured url for the web service.
|
protected String |
getUrlFromContext()
Returns the url configured for this connection.
|
String |
getUsername()
Returns the username configured for this connection.
|
com.boomi.model.connector.common.webservices.WebServiceOperation |
getWsOperation()
Returns the current WebServiceOperation for this connector operation.
|
com.boomi.webservices.WSSecurityInfo |
getWSSecurityInfo() |
boolean |
isApplicationFault(com.boomi.webservices.WebServiceResponse wsResponse)
Called by operation implementations to determine if the given WebServiceResponse (which is a "fault" response) is
an
OperationStatus.APPLICATION_ERROR or an
OperationStatus.FAILURE . |
boolean |
isFatalException(Throwable t)
Called by operation implementations to determine if the given Throwable is "fatal".
|
Payload |
toPayload(com.boomi.webservices.WebServiceResponse wsResponse)
Returns a Payload appropriate for the given WebServiceResponse.
|
generateConnectionInfo, generateConnectionInfo, getContext, getOperationContext
public static final String URL_PROPERTY
public static final String USERNAME_PROPERTY
public static final String PASSWORD_PROPERTY
public static final String AUTH_TYPE_PROPERTY
public static final String WS_SECURITY_PROPERTY
public static final String DEFAULT_SUCCESS_CODE
public WSConnection(BrowseContext context)
public WSConnector getConnector()
getConnector
in class BaseConnection<BrowseContext>
public String getUrl()
The default implementation generates the value with a call to getUrlFromContext
and caches this value for
re-use on subsequent calls.
public String getUsername()
The default implementation returns the connector property with the key USERNAME_PROPERTY
.
public String getPassword()
The default implementation returns the connector property with the key PASSWORD_PROPERTY
.
public com.boomi.webservices.WSSecurityInfo getWSSecurityInfo()
public com.boomi.model.connector.common.webservices.WebServiceAuthenticationType getAuthType()
The default implementation returns the connector property with the key AUTH_TYPE_PROPERTY
, defaulting to
WebServiceAuthenticationType.NONE
if the property does not exist.
public NetworkAuthenticator createAuthenticator()
SimpleNetworkAuthenticator
for
WebServiceAuthenticationType.NETWORK_AUTHENTICATION
type connections. This method uses the overridable
getAuthType()
, getUsername()
, and getPassword()
to determine the authentication type
and create the authenticator. Implementing classes can override these methods to modify those values but still
create a simple authenticator. This method can be overridden if a different implementation is required.public String getDefaultUrl()
Default implementation returns null
.
protected String getUrlFromContext()
Default implementation returns the connection property with the key URL_PROPERTY
if non-blank, otherwise
returns the value given by getDefaultUrl()
.
ConnectorException
- if a valid url can not be found for the web servicepublic WSCache getCache()
WSConnector.createCacheKey(com.boomi.connector.ws.WSConnection)
. If the cache needs to be created, this will be done by a call to
WSConnector.createCache(com.boomi.connector.ws.WSCache.Key, com.boomi.connector.api.BrowseContext)
.public com.boomi.model.connector.common.webservices.WebServiceOperation getWsOperation()
The default implementation pulls this information from the cookie stored with the ObjectDefinition using
WSBrowser.parseCookie(java.lang.String)
.
public com.boomi.webservices.WebServiceExecutor createExecutor(String operationName)
The default implementation gets the current WebServiceOperation from getWsOperation()
and uses the
WebServiceDescription from that to create the WebServiceExecutor (via
WebServiceExecutorFactory.getExecutor(com.boomi.model.connector.common.webservices.WebServiceDescription)
). The resulting WebServiceExecutor is then configured in a call to
configureExecutor(com.boomi.model.connector.common.webservices.WebServiceOperation, java.lang.String, com.boomi.webservices.WebServiceExecutor)
.
protected void configureExecutor(com.boomi.model.connector.common.webservices.WebServiceOperation operation, String operationName, com.boomi.webservices.WebServiceExecutor executor)
Default implementation configures the url, operationName, MEP, returnResults, soapAction and rawInput properties
appropriately for the given operation information. Lastly, this method will configure security by calling
configureSecurity(com.boomi.webservices.WebServiceExecutor)
.
protected SSLContext getSSLContext()
WebServiceExecutor
during call to configureExecutor(com.boomi.model.connector.common.webservices.WebServiceOperation, java.lang.String, com.boomi.webservices.WebServiceExecutor)
.
Default implementation sets the SSL Context to use trusted JVM and deployed atom certificates.WebServiceExecutor
.protected void configureSecurity(com.boomi.webservices.WebServiceExecutor executor)
getAuthType()
, delegating to configureBasicAuthSecurity(com.boomi.webservices.WebServiceExecutor)
or configureUsernameWSSecurity(com.boomi.model.connector.common.webservices.UserTokenPasswordType, com.boomi.webservices.WebServiceExecutor)
as appropriate. Security for WebServiceAuthenticationType.NETWORK_AUTHENTICATION
is handled by
WSConnector.createAuthenticator(BrowseContext)
so nothing is done to "configure" it here.protected void configureCustomWSSecurity(com.boomi.webservices.WebServiceExecutor executor)
protected void configureBasicAuthSecurity(com.boomi.webservices.WebServiceExecutor executor)
getUsername()
and getPassword()
.protected void configureBasicAuthNonPreemptiveSecurity(com.boomi.webservices.WebServiceExecutor executor)
getUsername()
and getPassword()
.protected void configureUsernameWSSecurity(com.boomi.model.connector.common.webservices.UserTokenPasswordType pwdType, com.boomi.webservices.WebServiceExecutor executor)
getUsername()
and getPassword()
.public boolean isFatalException(Throwable t)
Default implementation returns false
.
public boolean isApplicationFault(com.boomi.webservices.WebServiceResponse wsResponse)
OperationStatus.APPLICATION_ERROR
or an
OperationStatus.FAILURE
. See the sdk documentation for more details on
application errors.
Default implementation returns true
.
public String getSuccessCode()
Default implementation returns DEFAULT_SUCCESS_CODE
.
public String getSuccessMessage()
Default implementation returns null
.
public String getErrorCode(com.boomi.webservices.WebServiceResponse wsResponse)
Detail implementation returns WebServiceResponse.getErrorCode()
.
public String getErrorMessage(com.boomi.webservices.WebServiceResponse wsResponse)
Detail implementation returns WebServiceResponse.getRawErrorMessage()
with any detail strings appended to
it.
public Payload toPayload(com.boomi.webservices.WebServiceResponse wsResponse) throws com.boomi.webservices.WebServiceException
null
.
Default implementation returns the response body converted to a Payload (using the most efficient conversion
possible) if there is a body, null
otherwise.
com.boomi.webservices.WebServiceException
protected static void appendErrorDetail(Element detail, StringBuilder sb, List<String> path)
"<error><code>1234</code></error>"
will result in the appended string
"; error.code=1234".