Andre P. wrote:
> Hello everyone!
> Could anybody please enlighten my ideas!
>
> I was wondering, how the invocation in the BPEL is made. Does it
> dynamic (stubless) invoke all the (SOAP) services using their WSDLs or
> it's necessary to create all the proxies for the services first? How
> it is done, anybody have any idea?
>
> I'm using WSIF (actually WSIF from XSUL library developed in Indiana
> University), and I would like to use it with BPEL, to stubless and
> dynamically invoke all the (SOAP)services exposed and involved in my
> business process workflow! Is it possible?
hi Andre,
in short: yes.
steps are pretty simple
1. you identify which WSDL, operation name and XML message (content
combined by using XML API suchs xpath, xslt, xquery etc and actual
actions described in your workflow)
2. you load wsdl or just get it from cache (so you have
WsdlDefinitions object)
3. then using WSIF API you create WSIFPort that can be used to invoke
that operation
4. invoke and wait for async response (the tricky part if you want
scalbility you should do it as request-response as a pair of
one-way messages and other tricks to allow waiting for very long
running responses without tying a thread)
5. process response output (agian XML APIs come handy and it is in
your workflow)
about 3&4: you can use pure WSIF API for example (with extension that
WSIFMessage is XmlElement so you can directly manipulate it and even
access SOAP Header inside - very handy in workflows ...) - see
XsulDynamicInvoker for full contained example
WSIFProviderManager.getInstance().addProvider( new
xsul.wsif_xsul_soap_http.Provider() );
final WSIFServiceFactory factoryInstance =
WSIFServiceFactory.newInstance();
// Do this each time because they might not be thread safe.
WSIFService service =
factoryInstance.getService(this.definitions);
WSIFPort port = service.getPort();
WSIFOperation gFacOperation =
port.createOperation(operationName);
WSIFMessage inputMessage = gFacOperation.createInputMessage();
// access XML inside inputMessage and SOAP Header
XmlElement xmlMessage = ((XmlElementAdapter)
inputMessage).getTarget();
XmlDocument inputEnvelopeDoc =
soapFragrance.wrapBodyContent(xmlMessage);
if (logger.isFinestEnabled()) logger.finest(" message: "+
XsulUtil.safeXmlToString(inputEnvelopeDoc));
XmlElement inputEnvelope = inputEnvelopeDoc.getDocumentElement();
XmlElement inputHeader = inputEnvelope.element(inputEnvelope
.getNamespace(), XmlConstants.S_HEADER);
if (inputHeader == null) {
inputHeader = inputEnvelope.newElement(
inputEnvelope.getNamespace(), XmlConstants.S_HEADER);
inputEnvelope.insertChild(0, inputHeader);
inputHeader.setParent(inputEnvelope);
}
inputHeader.addElement(leadContextHeaderCopy);
// deep magic a.k.a. voodoo deployed here to connect all living
things together ...
((XmlElement) inputMessage).setParent(xmlMessage.getParent());
WSIFMessage outputMessage = gFacOperation.createOutputMessage();
WSIFMessage faultMessage = gFacOperation.createFaultMessage();
inputMessage.setObjectPart(parameterName, aparamvalue);
// ...
boolean success =
gFacOperation.executeRequestResponseOperation(inputMessage,
outputMessage, faultMessage);
if (!success) {
// and so on
or XWSIF extensions that allows client side handlers, control over asnc
responses, timeouts, etc. (see XwsifTestClient for full contained example)
WSIFClient wclient = WSIFRuntime.newClient(wsdlLoc)
.addHandler(new StickySoapHeaderHandler("use-lead-header",
leadContext))
.useAsyncMessaging(correlator)
//.setAsyncResponseTimeoutInMs(33 * 1000L); // to simplify
testing set to just few seconds
.setAsyncResponseTimeoutInMs(0); //unlimited wait
WSIFPort port = wclient.getPort();
WSIFOperation operation = port.createOperation("add");
WSIFMessage inputMessage = operation.createInputMessage();
WSIFMessage outputMessage = operation.createOutputMessage();
WSIFMessage faultMessage = operation.createFaultMessage();
inputMessage.setObjectPart("x", "2222");
inputMessage.setObjectPart("y", "3333");
// and so on like in typical WSIF app
HTH
best,
alek
--
The best way to predict the future is to invent it - Alan Kay