Page 1 of 1

Do I need to close the SOAP service

Posted: Fri Sep 30, 2016 6:17 pm
by HMJust
When using Lansa Integrator and the SOAP agent, in the sample the service is closed, unloaded and closed with this:

Code: Select all

* Close SOAP service
USE        BUILTIN(JSM_COMMAND) WITH_ARGS('CLOSE') TO_GET(#JSMSTS #JSMMSG)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

* Unload service
USE        BUILTIN(JSM_COMMAND) WITH_ARGS('SERVICE_UNLOAD') TO_GET(#JSMSTS #JSMMSG)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)

* Close service
USE        BUILTIN(JSM_CLOSE) TO_GET(#JSMSTS #JSMMSG)
EXECUTE    SUBROUTINE(CHECK) WITH_PARMS(#JSMSTS #JSMMSG)
Now, I am wondering if this part is absolutely necessary.

Yes, it is probably the right thing to do, but what if I open and initiate the service, run numerous operations after each other and then exit the function?

And would it be any different from a situation where my function ends abruptly, possibly because of a communications failure with the SOAP server? In that case, the function has not closed the service but just ended.

Re: Do I need to close the SOAP service

Posted: Sat Oct 01, 2016 1:46 am
by LANSAGuru
It depends.

If this is an INBOUND service, then you should NOT UNLOAD the service.
If you do the unload, the response will not be sent.

==================================
For a SOAP AGENT (pseudo code)
==================================
jsm open
load soapagent
open webservice(xxxxxx)
call operation(ops) service_exchange(*field)
get service_exchange(*field)
get fragment(frg) (n times)
unload service
jsm close

==================================
for a SOAP SERVER (pseudo code)
==================================
jsm open
load soapservice
open webservice(xxxxxxx)
get operation
process based on operation
get fragments
set paramenter(*return)
set fragments
unload service <<<<===== DO NOT DO THIS
jsm close

This pattern holds for any request/response type service in Integrator.
That is the request is processed, the response is prepared.
You close (which sends the response).

In your example you did not specify if this was inbound or outbound.
When the program ends, the resources will be recovered anyway, so strictly speaking, you do not need to unload the service.
I tend to as it appears to me to be good form (so that resources are released as soon as possible).

On your other comment about doing many calls in a row.
This only makes sense from the AGENT or CLIENT side context.
A server is going to be called once for each request in its own thread.
So, assuming an AGENT or CLIENT, if you were doing multiple sends, then you would NOT unload and reload the service for each cycle.
Instead you would do the following

jsm open
load service
start loop
send request
receive response
end loop
unload service
jsm close

I have not done this before specifically, but don't see why it would not work.
For instance, with HTTPService, I am fully confident there would be no issue with this.
For SOAP however, this is a special case as it uses a third party library.
I have typically only done an intermittent, send on demand, 1 document at time sort of processing with a full open, send, close loop

For batch processing of many documents however, I could see there would be some savings in doing it this way.

Re: Do I need to close the SOAP service

Posted: Tue Oct 04, 2016 9:51 pm
by HMJust
Thank you for the reply. I am using it as a client, and immediately after calling the (external) server, the program will end.

Your reply was exactly what I needed :)