How to check response content type using SOAP interface

I am new to this SOAP interface. I received a request to check if the response body is not empty.

Could you tell me how to decide.

My idea was to test the content-lengthresponse using an assertion script, but it does not work for equals().

contains()works, but notequals :

// works:
assert ((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["Content-Length"]).contains("0")
// not working:
assert ((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["C‌​ontent-Length"]).equals("0") 
// not working:
assert ((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["C‌​ontent-Length"]) == 0 

Please help me solve the problem.

+1
source share
1 answer

In your code:

// works:
assert ((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["Content-Length"]).contains("0")
// not working:
assert ((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["C‌​ontent-Length"]).equals("0") 
// not working:
assert ((com.eviware.soapui.support.types.StringList)messageExchange.responseHeaders["C‌​ontent-Length"]) == 0 

The expression messageExchange.responseHeaders["Content-Length"]returns a StringList [see here doc] which is ArrayList<String>.

It will be something like a few Strings, such as ( "abc", "def", "ghi").

contains("0"):

, list.contains("abc"), , "abc" . Content-Length - , , , ("0"). list.contains("0") true, String "0" .

equals("0"):

, : list.equals(something), true, something, , String. "0" String s, .

== 0:

, list == 0, , list 0, .

messageExchange.responseHeaders["Content-Length"] == 0 , . messageExchange.responseHeaders["Content-Length"] list String s, , 0.

messageExchange.getResponse().getContentLength() == 0 , messageExchange.getResponse().getContentLength() Content-Length long.

messageExchange.getResponse().getContentLength() long. , : Long.valueOf(messageExchange.responseHeaders["Content-Length"].get(0)) == 0.

+1

All Articles