public class SOAPMapCallingConvention extends SOAPCallingConvention
Manageable.State
Modifier and Type | Field and Description |
---|---|
protected static String |
REQUEST_BODY
The key used to store the Body element of the request.
|
protected static String |
REQUEST_ENVELOPE
The key used to store the Envelope element of the request.
|
protected static String |
REQUEST_FUNCTION
The key used to store the function element of the request.
|
REQUEST_NAMESPACE, RESPONSE_CONTENT_TYPE, RESPONSE_ENCODING
BOOTSTRAPPED, BOOTSTRAPPING, DEINITIALIZING, INITIALIZING, UNUSABLE, USABLE
Constructor and Description |
---|
SOAPMapCallingConvention(API api)
Creates a new
SOAPCallingConvention instance. |
Modifier and Type | Method and Description |
---|---|
protected FunctionRequest |
convertRequestImpl(HttpServletRequest httpRequest)
Converts an HTTP request to a XINS request (implementation method).
|
protected void |
convertResultImpl(FunctionResult xinsResult,
HttpServletResponse httpResponse,
Map<String,Object> backpack)
Converts a XINS result to an HTTP response (implementation method).
|
protected API |
getAPI()
Determines the current API.
|
protected String[] |
getSupportedMethods(HttpServletRequest request)
Determines which HTTP methods are supported for function invocations,
for the specified request.
|
protected boolean |
matches(HttpServletRequest httpRequest)
Checks if the specified request can be handled by this calling
convention.
|
protected Element |
parseXMLRequest(HttpServletRequest httpRequest)
Parses XML from the specified HTTP request and checks that the content
type is correct.
|
protected Element |
parseXMLRequest(HttpServletRequest httpRequest,
boolean checkType)
Parses XML from the specified HTTP request and optionally checks that
the content type is correct.
|
protected FunctionRequest |
readInput(Element functionElem,
String functionName,
Map<String,Object> backpack)
Generates the function request based the the SOAP request.
|
protected Element |
readInputElem(Element inputElem,
String functionName,
String parent,
Element parentElement,
Map<String,String> inputParams)
Parses the SOAP request element according to the rules specified in this
class description.
|
protected void |
setDataElementAttribute(Element builder,
String attributeName,
String attributeValue,
String elementNameSpacePrefix)
Writes the attribute a output data element for the returned SOAP element.
|
protected void |
writeOutputDataElement(Map dataSectionSpec,
Element dataElement,
Element parent)
Write the given output data element in the SOAP response.
|
protected void |
writeOutputDataSection(String functionName,
FunctionResult xinsResult,
Element response)
Writes the output data section to the SOAP XML.
|
protected void |
writeOutputParameter(String parameterName,
String parameterValue,
Element parent)
Write an output parameter to the SOAP response.
|
protected void |
writeOutputParameters(String functionName,
FunctionResult xinsResult,
Element response)
Writes the output parameters to the SOAP XML.
|
protected Element |
writeResponse(FunctionResult xinsResult,
Map<String,Object> backpack) |
getSupportedMethods, readDataSection, readInputParameters, soapElementTransformation, soapInputValueTransformation, soapOutputValueTransformation, writeFaultSection, writeOutputDataSection, writeOutputParameters
assertUsable, bootstrap, bootstrapImpl, deinit, deinitImpl, getState, init, initImpl, isBootstrapped, isUsable
protected static final String REQUEST_ENVELOPE
protected static final String REQUEST_BODY
protected static final String REQUEST_FUNCTION
public SOAPMapCallingConvention(API api) throws IllegalArgumentException
SOAPCallingConvention
instance.api
- the API, needed for the SOAP messages, cannot be null
.IllegalArgumentException
- if api == null
.protected boolean matches(HttpServletRequest httpRequest) throws Exception
SOAPCallingConvention
This method will not throw any exception.
matches
in class SOAPCallingConvention
httpRequest
- the HTTP request to investigate, cannot be null
.true
if this calling convention is possibly
able to handle this request, or false
if it
definitely not able to handle this request.Exception
- if analysis of the request causes an exception;
false
will be assumed.protected FunctionRequest convertRequestImpl(HttpServletRequest httpRequest) throws InvalidRequestException, FunctionNotSpecifiedException
httpRequest
argument is not null
;
getSupportedMethods()
.
Note that getSupportedMethods(HttpServletRequest)
will not
have been called prior to this method call.
convertRequestImpl
in class SOAPCallingConvention
httpRequest
- the HTTP request.null
.InvalidRequestException
- if the request is considerd to be invalid.FunctionNotSpecifiedException
- if the request does not indicate the name of the function to execute.protected FunctionRequest readInput(Element functionElem, String functionName, Map<String,Object> backpack)
functionElem
- the SOAP element of the function request, cannot be null
.functionName
- the name of the function, cannot be null
.backpack
- the backpack of this request, cannot be null
.null
.protected Element readInputElem(Element inputElem, String functionName, String parent, Element parentElement, Map<String,String> inputParams) throws Exception
inputElem
- the SOAP request element, cannot be null
.functionName
- the name of the function, cannot be null
.parent
- the name of the super element, can be null
.parentElement
- the input data element that is being created, can be null
.inputParams
- the Map where the input parameters should be stored, cannot be null
.null
if the SOAP
request does not need to create a input data element.Exception
- if anything goes wrong such specifications not available or incorrect SOAP request.protected void convertResultImpl(FunctionResult xinsResult, HttpServletResponse httpResponse, Map<String,Object> backpack) throws IOException
null
.convertResultImpl
in class SOAPCallingConvention
xinsResult
- the XINS result object that should be converted to an HTTP response,
will not be null
.httpResponse
- the HTTP response object to configure.backpack
- the backpack.IOException
- if the invocation of any of the methods in either
httpResponse
or httpRequest
caused an I/O
error.protected Element writeResponse(FunctionResult xinsResult, Map<String,Object> backpack) throws IOException
IOException
protected void writeOutputParameters(String functionName, FunctionResult xinsResult, Element response)
functionName
- the name of the function called, cannot be null
.xinsResult
- the result of the call to the function, cannot be null
.response
- the SOAP response element, cannot be null
.protected void writeOutputParameter(String parameterName, String parameterValue, Element parent)
parameterName
- the name of the output parameter, cannot be null
.parameterValue
- the value of the output parameter, cannot be null
.parent
- the parent element to put the created element in, cannot be null
.protected void writeOutputDataSection(String functionName, FunctionResult xinsResult, Element response)
functionName
- the name of the function called.xinsResult
- the result of the call to the function.response
- the SOAP response element, cannot be null
.protected void writeOutputDataElement(Map dataSectionSpec, Element dataElement, Element parent)
dataSectionSpec
- the specification of the output data elements for the function, cannot be null
.dataElement
- the data element to tranform as SOAP element, cannot be null
.parent
- the parent element to add the created element, cannot be null
.protected void setDataElementAttribute(Element builder, String attributeName, String attributeValue, String elementNameSpacePrefix)
SOAPCallingConvention
setDataElementAttribute
in class SOAPCallingConvention
builder
- the builder used to create the SOAP Element, cannot be null
.attributeName
- the name of the attribute, cannot be null
.attributeValue
- the value of the attribute, cannot be null
.elementNameSpacePrefix
- the namespace prefix of the parent element, can be null
.protected final API getAPI()
API
, never null
.protected String[] getSupportedMethods(HttpServletRequest request)
Each String
in the returned array must be one
supported method.
The returned array may be null
. If it is not, then the
returned array must only contain valid HTTP method names, so they may
not contain whitespace, for example. HTTP method names must be in uppercase.
There must be at least one HTTP method supported for function invocations.
Note that OPTIONS must not be returned by this method, as it is not an HTTP method that can ever be used to invoke a XINS function.
The set of supported methods must be a subset of the set returned by
getSupportedMethods()
.
The default implementation of this method returns the set returned by
getSupportedMethods()
.
request
- the request to determine the supported methods for.String
array, can be null
.protected Element parseXMLRequest(HttpServletRequest httpRequest) throws IllegalArgumentException, InvalidRequestException
This method uses a cache to optimize performance if either of the
parseXMLRequest
methods is called multiple times for the
same request.
Calling this method is equivalent with calling
parseXMLRequest(HttpServletRequest,boolean)
with the
checkType
argument set to true
.
httpRequest
- the HTTP request, cannot be null
.null
.IllegalArgumentException
- if httpRequest == null
.InvalidRequestException
- if the HTTP request cannot be read or cannot be parsed correctly.protected Element parseXMLRequest(HttpServletRequest httpRequest, boolean checkType) throws IllegalArgumentException, InvalidRequestException
Since XINS 1.4.0, this method uses a cache to optimize performance if
either of the parseXMLRequest
methods is called multiple
times for the same request.
httpRequest
- the HTTP request, cannot be null
.checkType
- flag indicating whether this method should check that the content
type of the request is text/xml.null
.IllegalArgumentException
- if httpRequest == null
.InvalidRequestException
- if the HTTP request cannot be read or cannot be parsed correctly.See http://www.xins.org/.