class WebServiceImpl extends java.lang.Object implements WebService, SessionListener
| Modifier and Type | Class and Description |
|---|---|
private static class |
WebServiceImpl.WebServiceData
Data structure that is used to store data on client side between calls from P2J server side.
|
private static class |
WebServiceImpl.WorkArea
Container for the context-local data.
|
| Modifier and Type | Field and Description |
|---|---|
private static ContextLocal<WebServiceImpl> |
instance
The single instance available of this class.
|
private static ContextLocal<WebServiceImpl.WorkArea> |
local
The context-local data of this class.
|
private static CentralLogger |
LOG
Logger
|
private static java.lang.Object |
modToken
Token used to authenticate with the dispatcher when registering APIs.
|
private static org.apache.axiom.soap.SOAPFactory |
soapFactory
A SOAP factory to create message data.
|
ERR_BINDING_NOT_IN_WSDL_DOCUMENT, ERR_BINDING_NOT_SUPPORTED, ERR_INVALID_PARAMS_IN_CONNECTION_STRING, ERR_LOADING_WSDL_DOCUMENT, ERR_NO_SERVICE_ERROR, ERR_NO_SERVICE_SPECIFIED, ERR_PORT_NOT_IN_WSDL_DOCUMENT, ERR_SERVICE_AND_PORT_NOT_FOUND, ERR_SERVICE_NOT_IN_WSDL_DOCUMENT, ERR_TARGETNAMESPACE_NOT_MATCH_WDSL| Modifier | Constructor and Description |
|---|---|
private |
WebServiceImpl(boolean local)
Private c'tor, to not allow explicit usage of this class.
|
| Modifier and Type | Method and Description |
|---|---|
private static org.apache.axiom.om.OMElement |
buildInputMessage(WebServiceImpl.WebServiceData wsd,
javax.wsdl.Operation op,
javax.xml.namespace.QName[][] inMsgParams,
java.lang.Object[] inputParams)
Using the input parameters configured at the operation's input message and the input
parameters sent by the caller, create a new XML payload representing the input message
passed to the operation call.
|
private static void |
buildSchema(WebServiceImpl.WebServiceData serviceData)
If the
WebServiceImpl.WebServiceData.xmlSchemas list is not yet build, extract all the schema
extensibility elements from the WSDL definition and save
them in the WebServiceImpl.WebServiceData.xmlSchemas list. |
void |
cleanupInvocation(int id)
Clears the temporary state of an invocation.
|
private static java.lang.Object[] |
collectParameters(java.lang.String modes,
java.lang.Object[] args,
boolean input)
Search the given parameter modes and return the input or output parameters, based on the
input flag. |
int |
connect(WebServiceConnectOptions options)
Validate parameters and establish a new connection using the given options.
|
boolean |
disconnect(int id)
Disconnect the web service.
|
private static java.lang.String |
getEnvelopeNameSpaces(org.apache.axis2.client.ServiceClient sc)
Build a string containing the SOAP Envelope namespaces in reverse order.
|
private static <T> T |
getExtension(java.util.List<?> extensions,
java.lang.Class<T> type)
Search the through the list of
ExtensibilityElements for one matching the give
type. |
java.lang.String[] |
getHeaderEntries(int id)
Get the header entries of the response to last invoked operation on the specified connection.
|
private static javax.wsdl.Port |
getImplicitSoapPort(java.util.Collection<?> ports)
Get the implicit port from the given collection of ports.
|
(package private) static WebServiceImpl |
getInstance(boolean local)
Retrieve the target instance.
|
private static javax.xml.namespace.QName[][] |
getMessageParameters(javax.wsdl.Message msg,
WebServiceImpl.WebServiceData wsd)
Resolve the parameters for the given message.
|
java.lang.String |
getNamespace(int id)
Get the wsdl namespace of this connection.
|
java.lang.Object[] |
getOutputValues(int id)
Obtain the values of output parameters after a successful Web Service invocation.
|
private static java.lang.String |
getPortName(java.lang.String portTypeName,
javax.wsdl.Definition wsdlDef)
Get the WSDL port name we'd like to access.
|
java.lang.String |
getPortTypeName(int id)
Get the name of the PortType of the specified connection.
|
void |
initialize(Session session)
This callback will be called after the security context has been set up.
|
boolean |
invoke(int id,
java.lang.String operationName,
java.lang.String portTypeName,
java.lang.String requestHeader)
Do the actual Web Service invocation.
|
private static java.lang.String |
marshallValue(javax.xml.namespace.QName paramName,
javax.xml.namespace.QName paramType,
BaseDataType value)
Marshall a value from Java/Progress style to SOAP style.
|
private static Text |
mergeNameSpaces(Text res,
java.lang.String envns)
Merge response namespace with SOAP Envelope namespaces.
|
private static void |
noServicesError()
Show a specific 4GL-style error meaning that no service could be resolved from the WSDL
document.
|
boolean |
prepareInvoke(int id,
java.lang.String portTypeName,
java.lang.String operationName,
java.lang.String modes,
java.lang.Object... args)
Prepare the connection for an invocation of an operation on the Web Service.
|
private static boolean |
processOutputMessage(javax.xml.namespace.QName[][] outMsgParams,
java.lang.Object[] outputParams,
org.apache.axiom.om.OMElement message)
Process the message received after an operation invocation and populate the output
parameters sent by the caller accordingly.
|
private static void |
resolveParameters(org.apache.ws.commons.schema.XmlSchemaElement element,
javax.xml.namespace.QName name,
java.util.List<javax.xml.namespace.QName[]> params)
Resolve the parameters from the specified schema element and save them in the
params list: on index 0 the name and on index 1 the schema type. |
void |
terminate(Session session)
This method is called when the session is ending.
|
private static BaseDataType |
unmarshallValue(javax.xml.namespace.QName paramName,
javax.xml.namespace.QName paramType,
org.apache.axiom.om.OMElement param)
Unmarshall a value received as a response for an service operation request to a
BaseDataType, depending on the parameter's type defined at the operation's output
message. |
private static boolean |
validateParameters(javax.wsdl.Operation op,
javax.wsdl.Service service,
java.lang.Object[] input,
java.lang.Object[] output,
int inParams,
int outParams)
Validate the operation's parameters against the input and output parameters sent by the
caller.
|
private static final CentralLogger LOG
private static ContextLocal<WebServiceImpl.WorkArea> local
private static java.lang.Object modToken
private static final ContextLocal<WebServiceImpl> instance
private static final org.apache.axiom.soap.SOAPFactory soapFactory
private WebServiceImpl(boolean local)
local - true to register purely on a local basis (no remote/network access to these
methods).static WebServiceImpl getInstance(boolean local)
local - true to register purely on a local basis (no remote/network access to these
methods).public void initialize(Session session)
initialize in interface SessionListenersession - The session that is starting.public void terminate(Session session)
terminate in interface SessionListenersession - The session that is ending.public int connect(WebServiceConnectOptions options)
The Web Services are not real connection and no actual connection remains open. Instead, the following actions are taken:
ErrorManager is used to report them
WebServiceImpl.WebServiceData structure is created and populated with validated values
and stored in context local data structures. At this moment object is populated
only with final information needed for further service invocation. The
object is assigned to a unique identifier that will be used from this point forward
for accessing this connection. This id is returned in case of success.
The #CONNECT_OPTION_MAX_CONNECTIONS, #CONNECT_OPTION_CONNECTION_LIFETIME,
#CONNECT_OPTION_NO_SESSION_REUSE and #CONNECT_OPTION_NO_HOST_VERIFY options
are not supported.
connect in interface WebServiceoptions - A collection of all parameters used for this connection.ErrorManager for details
about any errors.public java.lang.String getPortTypeName(int id)
getPortTypeName in interface WebServiceid - The id of the connection.public boolean disconnect(int id)
disconnect in interface WebServiceid - The ID of the associated web service on P2J Client side.true if no errors were encountered during disconnect.public boolean prepareInvoke(int id,
java.lang.String portTypeName,
java.lang.String operationName,
java.lang.String modes,
java.lang.Object... args)
prepareInvoke in interface WebServiceid - The id of an open connection.portTypeName - The name of the port type to be invoked.operationName - The name of the operation to be invoked on the Web Service.modes - A string representation of the modes of each parameter. May not be null.args - The operation's arguments.true if validation was successful and false if some errors occurred
and invocation is not available (incorrect operation name, invalid parameters or
could not build the request message).public java.lang.String getNamespace(int id)
getNamespace in interface WebServiceid - The id of an open connection.null if id does not
represent the identifier of a valid open connection.public java.lang.String[] getHeaderEntries(int id)
getHeaderEntries in interface WebServiceid - The id of an open connection.null if the id is
not the identifier of an open and prepared connection or the last response envelope
does not contain any headers.public void cleanupInvocation(int id)
id is invalid nothing happens.cleanupInvocation in interface WebServiceid - The id of an open connection.public boolean invoke(int id,
java.lang.String operationName,
java.lang.String portTypeName,
java.lang.String requestHeader)
id.invoke in interface WebServiceid - The id of an open connection.operationName - The name of the operation to be invoked on the Web Service.portTypeName - The name of the port type to be invoked.requestHeader - The request header if any was obtained form a call to a configured header callback.true if the service operation was successful and false if
id does not represent a valid connection or other error occurred.public java.lang.Object[] getOutputValues(int id)
getOutputValues in interface WebServiceid - The id of an open connection.private static java.lang.Object[] collectParameters(java.lang.String modes,
java.lang.Object[] args,
boolean input)
input flag.
The INPUT-OUTPUT will be returned in both cases.
modes - The parameter modes.args - The passed arguments.input - On true, collect input parameters; else, collect output parameters.args array.private static void resolveParameters(org.apache.ws.commons.schema.XmlSchemaElement element,
javax.xml.namespace.QName name,
java.util.List<javax.xml.namespace.QName[]> params)
params list: on index 0 the name and on index 1 the schema type.element - The schema element which needs to be resolved.name - The name of this element.params - The list where to save the parameters.private static <T> T getExtension(java.util.List<?> extensions,
java.lang.Class<T> type)
ExtensibilityElements for one matching the give
type.extensions - The list of extensibility elements.type - The type to be matched.null if not found.private static javax.wsdl.Port getImplicitSoapPort(java.util.Collection<?> ports)
Port must be
associated with a Binding with a SOAP 1.1. extensibility. If
more than one port matches or no port found, return null.ports - The Port instances to be searched.Port following the above rules.private static void noServicesError()
private static boolean validateParameters(javax.wsdl.Operation op,
javax.wsdl.Service service,
java.lang.Object[] input,
java.lang.Object[] output,
int inParams,
int outParams)
The rules are:
BaseDataType;
op - The service operation to be invoked.service - TBAinput - The passed input parameters.output - The passed output parameters.inParams - The number of input parameters defined at the operation.outParams - The number of output parameters defined at the operation.true if the parameters are valid.private static org.apache.axiom.om.OMElement buildInputMessage(WebServiceImpl.WebServiceData wsd, javax.wsdl.Operation op, javax.xml.namespace.QName[][] inMsgParams, java.lang.Object[] inputParams)
The caller may not pass null or unknown values. If the caller passes only one input
parameter of type Text or String, then it is assumed we are in wrapped
mode and the parameter holds the entire XML payload.
wsd - The definition of the WSDL that contains the operation.op - The operation to be invoked.inMsgParams - The (name, type) mappings of each parameter, defined at the operation's input.inputParams - The input parameters sent by the caller.OMElement structure with the XML payload for the input message.private static java.lang.String marshallValue(javax.xml.namespace.QName paramName,
javax.xml.namespace.QName paramType,
BaseDataType value)
See the "Table 3-2: Supported XML data types" from OpenEdge(R) Development: Web Services, page 3-15.
paramName - The parameter's name, as defined at the SOAP message.paramType - The parameter's type, as defined at the schema.value - The JAva or Progress-style value to be converted.BaseDataType.toStringMessage() method.private static BaseDataType unmarshallValue(javax.xml.namespace.QName paramName, javax.xml.namespace.QName paramType, org.apache.axiom.om.OMElement param)
BaseDataType, depending on the parameter's type defined at the operation's output
message. This will also validate the value with the parameter's type defined at the schema.
See the "Table 3-2: Supported XML data types" from OpenEdge(R) Development: Web Services, page 3-15.
paramName - The parameter's name, as defined at the SOAP message.paramType - The parameter's type, as defined at the schema.param - The response received after an operation invocation.BaseDataType instance for the received parameter or null if
conversion is not possible.private static boolean processOutputMessage(javax.xml.namespace.QName[][] outMsgParams,
java.lang.Object[] outputParams,
org.apache.axiom.om.OMElement message)
If the caller passes only one input parameter of type Text, then it is assumed we
are in wrapped mode and that parameter will hold the entire XML payload for the received
message, serialized as string.
outMsgParams - The (name, type) mappings of each parameter, defined at the operation's output.outputParams - The output parameters sent by the caller; each element is a BaseDataType.message - The message received after the operation invocation.true if message processed or false if there were
problems during conversion of the received to their BaseDataType expected
type.private static java.lang.String getPortName(java.lang.String portTypeName,
javax.wsdl.Definition wsdlDef)
portTypeName is in the list
of WSDL ports. If true the portTypeName is equals to port name and could be
used for bindings. If false return null and let service to choose the
appropriate SOAP port.portTypeName - port type name.wsdlDef - The definition of the WSDL that contains the port type.private static javax.xml.namespace.QName[][] getMessageParameters(javax.wsdl.Message msg,
WebServiceImpl.WebServiceData wsd)
msg - The message.wsd - A WebServiceData structure that contains information about schemas and
parameters.private static void buildSchema(WebServiceImpl.WebServiceData serviceData)
WebServiceImpl.WebServiceData.xmlSchemas list is not yet build, extract all the schema
extensibility elements from the WSDL definition and save
them in the WebServiceImpl.WebServiceData.xmlSchemas list.serviceData - The structure that contains information about the current connection and where the
schema will be stored.private static java.lang.String getEnvelopeNameSpaces(org.apache.axis2.client.ServiceClient sc)
throws org.apache.axis2.AxisFault
sc - ServiceClient instance.org.apache.axis2.AxisFault - In case of errors.private static Text mergeNameSpaces(Text res, java.lang.String envns)
res - Response string in XML format.envns - A string containing serialized SOAP Envelope namespaces