[web-services] Curl command line for consuming webServices?

Do you guys know how I can use the Curl command line to POST SOAP to test a web service?

I have a file (soap.xml) which has all the soap message attached to it I just don't seem to be able to properly post it.

Thanks!

This question is related to web-services testing curl

The answer is


Posting a string:

curl -d "String to post" "http://www.example.com/target"

Posting the contents of a file:

curl -d @soap.xml "http://www.example.com/target"

For a SOAP 1.2 Webservice, I normally use

curl --header "content-type: application/soap+xml" --data @filetopost.xml http://domain/path

For a SOAP 1.2 Webservice, I normally use

curl --header "content-type: application/soap+xml" --data @filetopost.xml http://domain/path

Wrong. That doesn't work for me.

For me this one works:

curl 
-H 'SOAPACTION: "urn:samsung.com:service:MainTVAgent2:1#CheckPIN"'   
-X POST 
-H 'Content-type: text/xml'   
-d @/tmp/pinrequest.xml 
192.168.1.5:52235/MainTVServer2/control/MainTVAgent2

Wrong. That doesn't work for me.

For me this one works:

curl 
-H 'SOAPACTION: "urn:samsung.com:service:MainTVAgent2:1#CheckPIN"'   
-X POST 
-H 'Content-type: text/xml'   
-d @/tmp/pinrequest.xml 
192.168.1.5:52235/MainTVServer2/control/MainTVAgent2

curl -H "Content-Type: text/xml; charset=utf-8" \
-H "SOAPAction:" \
-d @soap.txt -X POST http://someurl

curl -H "Content-Type: text/xml; charset=utf-8" \
-H "SOAPAction:" \
-d @soap.txt -X POST http://someurl

If you want a fluffier interface than the terminal, http://hurl.it/ is awesome.


If you want a fluffier interface than the terminal, http://hurl.it/ is awesome.


Questions with web-services tag:

How do I POST XML data to a webservice with Postman? How to send json data in POST request using C# org.springframework.web.client.HttpClientErrorException: 400 Bad Request How to call a REST web service API from JavaScript? The request was rejected because no multipart boundary was found in springboot Generating Request/Response XML from a WSDL How to send a POST request using volley with string body? How to send post request to the below post method using postman rest client How to pass a JSON array as a parameter in URL Postman Chrome: What is the difference between form-data, x-www-form-urlencoded and raw No found for dependency: expected at least 1 bean which qualifies as autowire candidate for this dependency. Dependency annotations: Cannot deserialize instance of object out of START_ARRAY token in Spring Webservice How can I get the named parameters from a URL using Flask? Connect HTML page with SQL server using javascript PUT and POST getting 405 Method Not Allowed Error for Restful Web Services Create a asmx web service in C# using visual studio 2013 PowerShell script to check the status of a URL Java String to JSON conversion java.net.UnknownHostException: Unable to resolve host "<url>": No address associated with hostname and End of input at character 0 of WCF Exception: Could not find a base address that matches scheme http for the endpoint SOAP vs REST (differences) 415 Unsupported Media Type - POST json to OData service in lightswitch 2012 What is the difference between a web API and a web service? SOAP request to WebService with java IntelliJ, can't start simple web application: Unable to ping server at localhost:1099 how to fix java.lang.IndexOutOfBoundsException How to POST URL in data of a curl request Read response body in JAX-RS client from a post request Angular JS POST request not sending JSON data jQuery .ajax() POST Request throws 405 (Method Not Allowed) on RESTful WCF How to get info on sent PHP curl request What is the difference between JAX-RS and JAX-WS? Junit test case for database insert method with DAO and web service How can I pass a username/password in the header to a SOAP WCF Service Working Soap client example How to do a SOAP Web Service call from Java class? HTTP POST and GET using cURL in Linux Uri not Absolute exception getting while calling Restful Webservice Difference between a SOAP message and a WSDL? Jquery Ajax Call, doesn't call Success or Error Default username password for Tomcat Application Manager how to increase MaxReceivedMessageSize when calling a WCF from C# How correctly produce JSON by RESTful web service? UEFA/FIFA scores API How to consume REST in Java How to generate service reference with only physical wsdl file what's the correct way to send a file from REST web service to client? Importing xsd into wsdl How to create web service (server & Client) in Visual Studio 2012? how to send an array in url request

Questions with testing tag:

Test process.env with Jest How to configure "Shorten command line" method for whole project in IntelliJ Jest spyOn function called Simulate a button click in Jest Mockito - NullpointerException when stubbing Method toBe(true) vs toBeTruthy() vs toBeTrue() How-to turn off all SSL checks for postman for a specific site What is the difference between smoke testing and sanity testing? ReferenceError: describe is not defined NodeJs How to properly assert that an exception gets raised in pytest? How do you print in a Go test using the "testing" package? How do I install jmeter on a Mac? How to run only one unit test class using Gradle Select a date from date picker using Selenium webdriver Exception in thread "main" java.lang.Error: Unresolved compilation problems How to identify and switch to the frame in selenium webdriver when frame does not have id How can I solve the error LNK2019: unresolved external symbol - function? How to select option in drop down protractorjs e2e tests Selenium and xpath: finding a div with a class/id and verifying text inside Integration Testing POSTing an entire object to Spring MVC controller How to type in textbox using Selenium WebDriver (Selenium 2) with Java? How can I test that a variable is more than eight characters in PowerShell? Spring Test & Security: How to mock authentication? What is the difference between mocking and spying when using Mockito? iOS Simulator to test website on Mac Switch tabs using Selenium WebDriver with Java How to check if a string array contains one string in JavaScript? Automated testing for REST Api How to check whether dynamically attached event listener exists or not? ScalaTest in sbt: is there a way to run a single test without tags? How to test an SQL Update statement before running it? Load vs. Stress testing Verify a method call using Moq Selenium: Can I set any of the attribute value of a WebElement in Selenium? Is there any publicly accessible JSON data source to test with real world data? How to test code dependent on environment variables using JUnit? How to mock private method for testing using PowerMock? WebDriver: check if an element exists? How to test my servlet using JUnit How to create unit tests easily in eclipse How to create large PDF files (10MB, 50MB, 100MB, 200MB, 500MB, 1GB, etc.) for testing purposes? What's the difference between unit, functional, acceptance, and integration tests? Trying to mock datetime.date.today(), but not working How to write a test which expects an Error to be thrown in Jasmine? Gradle: How to Display Test Results in the Console in Real Time? Can I run multiple versions of Google Chrome on the same machine? (Mac or Windows) What's the difference between a mock & stub? Writing unit tests in Python: How do I start? Difference between acceptance test and functional test? jquery (or pure js) simulate enter key pressed for testing

Questions with curl tag:

What is the incentive for curl to release the library for free? curl: (35) error:1408F10B:SSL routines:ssl3_get_record:wrong version number Converting a POSTMAN request to Curl git clone error: RPC failed; curl 56 OpenSSL SSL_read: SSL_ERROR_SYSCALL, errno 10054 How to post raw body data with curl? Curl : connection refused How to use the curl command in PowerShell? Curl to return http status code along with the response How to install php-curl in Ubuntu 16.04 curl: (35) SSL connect error Solving sslv3 alert handshake failure when trying to use a client certificate curl: (6) Could not resolve host: application How do I install the ext-curl extension with PHP 7? Ubuntu: Using curl to download an image Curl command without using cache Using client certificate in Curl command PHP: Call to undefined function: simplexml_load_string() Adding subscribers to a list using Mailchimp's API v3 Correct way to set Bearer token with CURL Making an API call in Python with an API that requires a bearer token cURL error 60: SSL certificate: unable to get local issuer certificate Upload Image using POST form data in Python-requests PHP - SSL certificate error: unable to get local issuer certificate How to use curl to get a GET request exactly same as using Chrome? Curl not recognized as an internal or external command, operable program or batch file Simulate a specific CURL in PostMan Display curl output in readable JSON format in Unix shell script pass JSON to HTTP POST Request Execute curl command within a Python script How to define the basic HTTP authentication using cURL correctly? Perform curl request in javascript? How to use Python to execute a cURL command? wget/curl large file from google drive curl: (6) Could not resolve host: google.com; Name or service not known curl: (60) SSL certificate problem: unable to get local issuer certificate how to get curl to output only http response body (json) and no other headers etc Unable to resolve "unable to get local issuer certificate" using git on Windows with self-signed certificate curl Failed to connect to localhost port 80 How to insert data into elasticsearch Basic HTTP and Bearer Token Authentication Creating a REST API using PHP Posting raw image data as multipart/form-data in curl Curl error: Operation timed out POST request send json data java HttpUrlConnection How to count items in JSON object using command line? Curl GET request with json parameter Curl and PHP - how can I pass a json through curl by PUT,POST,GET Curl error 60, SSL certificate issue: self signed certificate in certificate chain PHP cURL error code 60 Curl: Fix CURL (51) SSL error: no alternative certificate subject name matches