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-Typeheader 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 - SOAPActionheader field is left undefined, meaning- curlis not sending that field at all. You can check this if you run- curlwith- --trace-ascii /dev/stdoutoption.
- to send your XML (binary) payload as-is, you can use - --data-binaryoption, 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 - curlrequests, 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>  
0 comments:
Post a Comment