public class SoapHandler extends LegacyWebServiceHandler
Service registration is being performed via SourceNameMapper
, which loads the programs marked with
with-services
, via addService(com.goldencode.p2j.util.LegacyService, java.lang.Class<? extends com.goldencode.p2j.oo.lang._BaseObject_>, com.goldencode.p2j.util.LegacyService, java.lang.reflect.Method)
API.
Any converted Java code mapped to a service must have a class-level LegacyService
annotation. If
this has operations defined via internal entries (procedure, function, method), then each Java method must
be annotated via LegacyService
.
The implicit basepath is /ws
, and the implicit timeout is 10 seconds (set to 0 to disable it).
This timeout is read from the appserver's timeout.
The values which need to be configured in the directory are:
soap/wsdl
, a comma-separated list of WSDL files, relative to the root Java package.soap/basepath
, to specify the basepath. Defaults to /ws
.soap/alias
, a process certificate alias associated with the workers which will process
the SOAP requests; these will delegate the call to the appserver. This context will automatically
be set as HEADLESS.soap/keyStore
, the key store with the certificate to authenticate this process. If is
missing, the store will be built from the directory.soap/storePassword
, the store password, only if soap/keyStore
is set.soap/poolSize
- the pool size of workers. Defaults to 10.soap/appserver
- the name of the appserver handling the requests.Each queue of SOAP workers is ordered by the number of pending tasks to be executed - for each incoming request, the worker with the smallest number of pending tasks will be chosen.
org.eclipse.jetty.server.handler.AbstractHandler.ErrorDispatchHandler
org.eclipse.jetty.util.component.AbstractLifeCycle.AbstractLifeCycleListener
Modifier and Type | Field and Description |
---|---|
private static org.eclipse.jetty.server.handler.ContextHandlerCollection |
handler
The context handler.
|
private static java.util.List<SoapHandler> |
instances
The list of instances for this handler.
|
private static java.util.logging.Logger |
LOG
Anonymous log instance.
|
private java.util.Map<java.lang.String,WsdlConfig> |
wsdl
Map of WSDL configuration by their namespace.
|
private java.util.Map<java.lang.String,org.w3c.dom.Document> |
wsdlDocs
Map of WSDL DOM documents by their namespace.
|
private java.util.Map<java.lang.String,java.lang.String> |
wsdlFiles
Set of WSDL files served by this instance, by their namespace.
|
DELETE, JAVA, PERSISTENT, services, SINGLE_RUN, SINGLETON
basePath
Constructor and Description |
---|
SoapHandler(java.lang.String basePath,
java.util.Map<java.lang.String,java.lang.String> wsdls)
Initialize this handler with the 'soap' type and '/ws' default basepath.
|
Modifier and Type | Method and Description |
---|---|
static void |
addService(LegacyService ls,
java.lang.Class<? extends _BaseObject_> cls,
LegacyService mls,
java.lang.reflect.Method m)
Register a legacy service associated with a legacy OO class method.
|
static void |
addService(LegacyService ls,
java.lang.String pname,
LegacyService iels,
InternalEntry ie,
boolean function)
Register a legacy service associated with an internal entry for an external program.
|
static void |
addService(LegacyService ls,
java.lang.String pname,
java.lang.reflect.Method m)
Register a legacy service associated with a legacy external program.
|
protected ServiceKey |
buildServiceKey(LegacyService ls)
Build a
SoapServiceKey for the specified legacy service. |
private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> |
getWsdlByEndpoints(java.lang.String basePath)
Get all the WSDLs by their endpoints.
|
private static java.io.InputStream |
getWsdlStream(java.lang.String file)
Find the input stream for a file relative to the project's root Java package.
|
void |
handle(java.lang.String target,
org.eclipse.jetty.server.Request baseRequest,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response)
Code to process web requests.
|
static org.eclipse.jetty.server.handler.AbstractHandler |
initialize()
Initialize the SOAP worker(s) and start the workers.
|
static void |
initializePost()
Initialization performed after the
main initialization was completed. |
private static void |
invoke(RestService service,
java.lang.String token,
LegacyServiceWorker worker,
java.lang.String target,
javax.servlet.http.HttpServletRequest request,
javax.servlet.http.HttpServletResponse response,
org.apache.axiom.om.OMElement soapRequest,
WsdlConfig wsdlConfig,
javax.wsdl.Operation soapOperation,
javax.wsdl.BindingOperation soapBinding)
Execute the SOAP request.
|
private static java.util.Map<java.lang.String,java.util.List<java.lang.Object[]>> |
loadWsdl(java.lang.String url,
java.lang.String basePath,
java.lang.String file)
Load the WSDL document from the specified file.
|
private void |
loadWsdls(java.lang.String basePath)
Load all the configured
soap/wsdl files and will set their service location to the current
host/port handling the SOAP services. |
private boolean |
namespaceMatch(java.lang.String ns,
javax.wsdl.WSDLElement el)
Check if the specified element is part of this namespace.
|
private static java.lang.String |
readProcedureHandle(WsdlConfig wsdlConfig,
org.apache.axiom.soap.SOAPHeader header,
javax.wsdl.BindingOperation binding)
From a SOAP request, read the procedure handle ID, as the UUID element from the SOAP header.
|
protected void |
registerService(LegacyService ls,
java.lang.String pname,
LegacyService iels,
InternalEntry ie,
boolean function)
Register a legacy service associated with an internal entry for an external program.
|
private static void |
registerService(java.lang.String namespace,
java.util.function.Consumer<SoapHandler> consumer)
Register the specified operation with all instance handling that namespace.
|
(package private) static void |
removeNamespaces(org.apache.axiom.om.OMElement el)
Remove all namespaces from the specified element.
|
protected java.lang.String |
resolveBasePath(java.lang.String basePath)
Resolve the configured basepath for this handler.
|
static void |
terminate()
Terminate the SOAP worker threads.
|
static boolean |
useWebServiceAuthentication()
Determine if this web service is configured to authenticate the APIs.
|
private void |
writeError(java.lang.String msg,
java.lang.String reason,
javax.servlet.http.HttpServletResponse response)
Serialize the error, to be included in the response.
|
registerService, registerService
authorize, getBasePath, getPaths, getTimeout, getType, handle, handle, initializeHandler, postHandle, readBody, terminateWorkers, useAuthorization
destroy, doError, doStart, doStop, getServer, setServer
addBean, addBean, addEventListener, addManaged, contains, dump, dump, dump, dump, dump, dumpBeans, dumpObject, dumpObjects, dumpStdErr, dumpThis, getBean, getBeans, getBeans, getContainedBeans, getContainedBeans, isAuto, isManaged, isUnmanaged, manage, removeBean, removeBeans, removeEventListener, setBeans, setStopTimeout, start, stop, unmanage, updateBean, updateBean, updateBeans
addLifeCycleListener, getState, getState, getStopTimeout, isFailed, isRunning, isStarted, isStarting, isStopped, isStopping, removeLifeCycleListener, start, stop, toString
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
private static final java.util.logging.Logger LOG
private static java.util.List<SoapHandler> instances
private static org.eclipse.jetty.server.handler.ContextHandlerCollection handler
private java.util.Map<java.lang.String,java.lang.String> wsdlFiles
private java.util.Map<java.lang.String,WsdlConfig> wsdl
private java.util.Map<java.lang.String,org.w3c.dom.Document> wsdlDocs
public SoapHandler(java.lang.String basePath, java.util.Map<java.lang.String,java.lang.String> wsdls)
basePath
- The basepath served by this handler.wsdls
- The set of WSDL files.public static boolean useWebServiceAuthentication()
true
if the authentication is enabled for this web service, in the directory.public static void terminate()
public static org.eclipse.jetty.server.handler.AbstractHandler initialize()
public static void initializePost()
main initialization
was completed.
This will load all the configured WSDL files for each handler, and will set their service location to the current host/port handling the SOAP services.
public static void addService(LegacyService ls, java.lang.Class<? extends _BaseObject_> cls, LegacyService mls, java.lang.reflect.Method m)
ls
- The annotation describing the service, at the legacy class.cls
- The BaseObject
sub-class implementing this
service.mls
- The annotation describing the service, at the legacy method.m
- The target operation.public static void addService(LegacyService ls, java.lang.String pname, java.lang.reflect.Method m)
ls
- The annotation describing the service.pname
- The legacy program name.m
- The target Java method for this service.public static void addService(LegacyService ls, java.lang.String pname, LegacyService iels, InternalEntry ie, boolean function)
ls
- The annotation describing the service, at the external program.pname
- The legacy program name.iels
- The annotation describing the service, at the internal entry.ie
- The target internal entry for this service.function
- Flag identifying if the internal entry is a function.static void removeNamespaces(org.apache.axiom.om.OMElement el)
This will remove only namespaces which are meant to be for the SOAP envelope, keeping everything else.
el
- The element.private static java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.String>> getWsdlByEndpoints(java.lang.String basePath)
basePath
- The base path.private static void registerService(java.lang.String namespace, java.util.function.Consumer<SoapHandler> consumer)
namespace
- The WSDL namespace.consumer
- The code used to register the WSDL file.private static java.io.InputStream getWsdlStream(java.lang.String file)
file
- The file to resolve.private static void invoke(RestService service, java.lang.String token, LegacyServiceWorker worker, java.lang.String target, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.apache.axiom.om.OMElement soapRequest, WsdlConfig wsdlConfig, javax.wsdl.Operation soapOperation, javax.wsdl.BindingOperation soapBinding) throws java.io.IOException
service
- The SOAP service instance which will handle the request.token
- When not null, it represents the token of a FWD context created for an authenticated and
authorized web service call. The API call will be performed in that context.worker
- The SOAP worker.target
- The target path.request
- The HTTP servlet request instance.response
- The HTTP servlet response instance.soapRequest
- The SOAP body element which encodes the request.wsdlConfig
- The WSDL configuration to which the request belongs.soapOperation
- The WSDL operation defining this request.soapBinding
- The WSDL binding to which this SOAP operation definition belongs.java.io.IOException
private static java.lang.String readProcedureHandle(WsdlConfig wsdlConfig, org.apache.axiom.soap.SOAPHeader header, javax.wsdl.BindingOperation binding)
wsdlConfig
- The WSDL configuration to which the request belongs.header
- The SOAP header for the request.binding
- The WSDL binding to which this SOAP operation definition belongs.null
if it can't be found.public void handle(java.lang.String target, org.eclipse.jetty.server.Request baseRequest, javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
handle
in interface org.eclipse.jetty.server.Handler
handle
in class LegacyServiceHandler
target
- The target path.request
- The HTTP request.response
- The HTTP response.java.io.IOException
protected void registerService(LegacyService ls, java.lang.String pname, LegacyService iels, InternalEntry ie, boolean function)
registerService
in class LegacyWebServiceHandler
ls
- The annotation describing the service, at the external program.pname
- The legacy program name.iels
- The annotation describing the service, at the internal entry.ie
- The internal entry name.function
- Flag identifying if the internal entry is a function.protected ServiceKey buildServiceKey(LegacyService ls)
SoapServiceKey
for the specified legacy service.buildServiceKey
in class LegacyWebServiceHandler
ls
- The legacy service annotation.protected java.lang.String resolveBasePath(java.lang.String basePath)
resolveBasePath
in class LegacyServiceHandler
basePath
- The default base path.basePath
.private void writeError(java.lang.String msg, java.lang.String reason, javax.servlet.http.HttpServletResponse response) throws java.io.IOException
msg
- The message to be used as the SOAP fault code ('faultString').reason
- The message to be used as the SOAP fault detail.response
- The servlet response.java.io.IOException
private boolean namespaceMatch(java.lang.String ns, javax.wsdl.WSDLElement el)
ns
- The namespace to match.el
- The WSDL message (input, output or fault).true
if the element is part of the namespace.private void loadWsdls(java.lang.String basePath)
soap/wsdl
files and will set their service location to the current
host/port handling the SOAP services.basePath
- The basePath to append to the WSDL endpoint path.private static java.util.Map<java.lang.String,java.util.List<java.lang.Object[]>> loadWsdl(java.lang.String url, java.lang.String basePath, java.lang.String file) throws javax.xml.parsers.ParserConfigurationException, java.io.IOException, org.xml.sax.SAXException, javax.wsdl.WSDLException
basePath
- The basePath to append to the WSDL endpoint path.file
- The file name, relative to project's root Java package.javax.xml.parsers.ParserConfigurationException
- if the XML parser has been configured incorrectly.java.io.IOException
- if an I/O error occurs during parsing or stream cleanup.org.xml.sax.SAXException
- if an error occurs parsing the XML document.javax.wsdl.WSDLException
- if an error occurs parsing the WSDL document.