Love to code, although it bugs me.

Posting SOAP request from Windows Powershell

No comments
A previous post on this blog showed how posting a SOAP request from the command line on Linux could be done.

Following the post about Invoke-Web-Request, I'll show how to achieve the same task using Windows Powershell v3 CTP 1.

The first step is to build a sample SOAP request and save it on a text file, maybe called “soap.txt”. For the sake of this example I saved it on a temporary folder "C:\Temp"

Afterwards, open a powershell command prompt window and type this in:
Invoke-WebRequest http://[your web service endpoint address] -Method Post -ContentType "text/xml" -InFile C:\Temp\soap.txt -OutFile c:\Temp\soapRes.txt

The command has the following parameters:

  • method: indicating the request should be sent using HTTP POST

  • content type: stating the request is an XML message

  • input file: the SOAP request text file

  • output file: the name and path for saving the SOAP response


After execution, the resulting SOAP response is saved on the temporary folder under the name "soapresult.txt".

Cool!

No comments :

Post a Comment