How to pass session id as part of a Soap request?

I call an authentication request to get the session id:

<S:Envelope xmlns:S="http://schemas.xmlsoap.org/soap/envelope/">
   <S:Body>
      <loginResponse xmlns="urn:company" xmlns:ns2="urn:company">
         <result>
            <sessionId>2342422342.dc8bizxsfapi03</sessionId>
            <msUntilPwdExpiration>2342342342342353452323</msUntilPwdExpiration>
         </result>
      </loginResponse>
   </S:Body>
</S:Envelope>

The docs for the Soap API that I use say:

A successful login will return a
session ID as an HTTP Cookie. This cookie must be passed back to all subsequent HTTP
Requests that invoke API operations in order to authenticate.

How is the session identifier passed to the next http request as it is not described?

I assume that I need to embed the session identifier in the XML tag as part of the substesnt request, but should this be described in detail in the API or is there a standard mechanism that I can use?

+4
source share
4 answers

API, , , , . HTTP-, /, . HTTP, -, , - SOAP , , , , . , , cookie , , API SOAP.

jax-ws, BindingProvider.SESSION_MAINTAIN_PROPERTY true RequestContext. .

+3

, .

API, Cookie ( HTTP-). , , - (, ). cookie HTTP. JAX-WS, BindingProvider.SESSION_MAINTAIN_PROPERTY:

Hello proxy = new HelloService().getHelloPort();
((BindingProvider)proxy).getRequestContext().put(BindingProvider.SESSION_MAINTAIN_PROPERTY,true);
String result = proxy.getMessage();
System.out.println(result); 

, , HTTP, -.

+1

.

.

def groovyUtils = new com.eviware.soapui.support.GroovyUtils( context )
def holder = groovyUtils.getXmlHolder("Properties#response")
log.info holder.getNodeValue("//sessionId")
log.info holder['//sessionId']

" " .

  • groovy - cookie . , cookie . , /.

,

//in script assertion
String message_size = messageExchange.responseHeaders["session-id"] /or whatever if the cookie name

def state = context.getProperty( com.eviware.soapui.model.testsuite.TestRunContext.HTTP_STATE_PROPERTY )

assert state != null : "Missing HttpState.. Try to set 'Maintain HTTP session' in test case options"

def cookies = state.cookies

http://forum.soapui.org/viewtopic.php?t=3066#p10957

  • , http-, , . soapUI .

, soapUI HttpState , TestCase " HTTP-".

: http://www.soapui.org/Functional-Testing/testcase-execution.html

+1

API, , , , , .

cookie ( <sessionId>xxxx</sessionId> ).

, , cookie API.

HTTP/SOAP- , HTTP Cookie, , , , URI.

SoapUI, , :

test case options

, , .

+1

Source: https://habr.com/ru/post/1536806/


All Articles