cancel
Showing results for 
Search instead for 
Did you mean: 

Stateful Web Service from FM

Former Member
0 Kudos

FM SRT_TESTS_FB_SUM is "stateful". It increments and returns value of global variabe.

I created Web Service from this FM and set in Configuration parameter Stateful Communication = Stateful .

I try call this WS with SOAP UI. I copy set-cookie header (MYSAPSSO2) from first response and paste in Cookie header in second request. But return value is not increment. Call is stateless ...

set-cookie of first response:

MYSAPSSO2=Aj...(many symbols)...Du; path=/; domain=.<host>

I think MYSAPSSO2 used only for save pair user-password. But no session.

Perhaps here must be cookies: ap-appcontext,sap-contextid,JSESSIONID ?

Accepted Solutions (0)

Answers (3)

Answers (3)

Former Member
0 Kudos

Done!

Default http request handler in SICF for my web service was CL_SOAP_HTTP_EXTENSION in /default_host/sap/bc/srt/rfc. I dont know how to use this handler for stateful session.

But i know how to use this handler: CL_HTTP_EXT_SOAPHANDLER_RFC.

It uses variable session_mode from request:

server->request->get_form_field( name = 'session_mode' )

You have to use session_mode = 1 in first web service call to open session.

If session_mode = 1. 
server->stateful = server->co_enabled.
server->response->set_cookie ... 'sap-contextid' ...

You have to used session_mode = 2 in last call to close session.

If session_mode = 2. 
server->stateful = server->co_disabled.
server->response->delete_cookie_at_client ... 'sap-contextid' ...

I made copy - ZCL_HTTP_EXT_SOAPHANDLER_RFC.

My class can read session_mode from http headers. It is more convenient for me.

server->request->get_header_field( 'session_mode' ).

I created service /default_host/zmysoap and add my Z handler here. In my wsdl i changed soap:address to http://<host:port>/mysoap. And i have stateful session!

Former Member
0 Kudos

I have this doc about stateful communication. It is not helpful for me. I don't get cookie. Call is stateless.

In my WSDL i have strings:

<sapsession:Session xmlns:sapsession="http://www.sap.com/webas/630/soap/features/session/">

<sapsession:enableSession>false</sapsession:enableSession>

</sapsession:Session>

I think i can use http request handlers to change state to statefull. But i don't know how to use it in my case.

Edited by: Dmitry Pliskov on Jun 6, 2011 1:58 PM

Former Member
0 Kudos

Hi Dmitry,

Try & research:

sap session-oriented communication

It might be useful for enabling stateful communication.

Also, check the following guide / whitepaper (which you're obviously using but see the section on session-oriented communication). It's a bit outdated but provides an excellent example (with source code for cookie management on the Abap stack) of how to manage stateful communication with a remote-enabled function module on SAP:

[http://blogs.msdn.com/b/saptech/archive/2007/12/11/an-another-whitepaper-this-time-about-stateful-web-service-communication.aspx]

Regards, Trevor

Edited by: Trevor Naidoo on Jun 3, 2011 8:25 AM