Monday, November 27, 2017

Soap UI vs Curl Response tIme Difference

Leave a Comment

I have hosted a soap service built using spring in one of our data centers. When I test via SOAP UI , I get the response in 1 second or less. However when I run the same request via CURL , it takes more than 30 seconds to execute. I am running both the commands from same machine. What could be causing this difference?

curl  -H "Content-Type: text/xml; charset=utf-8" -H "SOAPAction:"  -d @request.xml <endpoint> 

1 Answers

Answers 1

A few things to consider:

  • the media type (Content-Type header field) for SOAP requests should be application/soap+xml (see SOAP 1.2 specs, end of section 1.3). If your encoding is UTF-8, then set Content-Type: application/soap+xml; charset=UTF-8.

  • your SOAPAction header field is left undefined, meaning curl is not sending that field at all. You can check this if you run curl with --trace-ascii /dev/stdout option.

  • to send your XML (binary) payload as-is, you can use --data-binary option, instead of -d/--data. It will preserve newlines and carriage returns. For XML content that shouldn't make any difference, but that probably depends on strictness of parser and schema used.

  • when debugging curl requests, it's useful to bounce the request off of echo sites like httpbin, as well as enable full verbosity with -vvv, maybe even use --trace* to inspect the exact payload sent/received.

Applying those fixes, your curl command will look like:

curl -H 'Content-Type: application/soap+xml; charset=UTF-8' \      -H 'SOAPAction: Some-Action' \      --data-binary @request.xml \      <endpoint> 
If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment