# To Login SOAP API

**URL:** <https://forum.ansible.com/t/to-login-soap-api/26660>\
**Category:** Ansible Project\
**Created:** [February 5, 2018, 5:11am UTC](https://forum.ansible.com/t/to-login-soap-api/26660 "2018-02-05T05:11:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![rajasekhar\_mutyala](https://avatars.discourse-cdn.com/v4/letter/r/2acd7d/32.png) [@rajasekhar\_mutyala](https://forum.ansible.com/u/rajasekhar_mutyala)\
**Post date:** [February 5, 2018, 5:11am UTC](https://forum.ansible.com/t/to-login-soap-api/26660/1 "2018-02-05T05:11:22Z")

</div>

Hi All,

I am trying to login and perform some taks using SOAP API with ansible. Can you please let me know how to call SOAP API along with examples would really help.

Thanks  
Rajasekhar

---

<div class="post-metadata">

**Author:** ![eshan\_TANDON](https://avatars.discourse-cdn.com/v4/letter/e/ac91a4/32.png) [@eshan\_TANDON](https://forum.ansible.com/u/eshan_TANDON)\
**Post date:** [February 5, 2018, 1:06pm UTC](https://forum.ansible.com/t/to-login-soap-api/26660/2 "2018-02-05T13:06:24Z")

</div>

Not sure if there is an explicit module to make soap call however u can use the shell module:

[http://docs.ansible.com/ansible/latest/shell\_module.html](http://docs.ansible.com/ansible/latest/shell_module.html)

Here is some documentation on how to make soap call using curl:

[http://lancegatlin.org/tech/test-a-soap-web-service-using-curl](http://lancegatlin.org/tech/test-a-soap-web-service-using-curl)

Combining the options above is what u want.

Thanks,  
Eshan

---

<div class="post-metadata">

**Author:** ![j.r.hawkesworth](https://avatars.discourse-cdn.com/v4/letter/j/a3d4f5/32.png) [@j.r.hawkesworth](https://forum.ansible.com/u/j.r.hawkesworth)\
**Post date:** [February 5, 2018, 1:22pm UTC](https://forum.ansible.com/t/to-login-soap-api/26660/3 "2018-02-05T13:22:27Z")

</div>

You may be able to use URI module.

If you are on windows, or have some windows hosts, you can make use of the webServiceProxy cmdlets. This is nice as you can use the wsdl and discover the available methods on the webservice interface at runtime.

Here’s a powershell script that can be used to connect to a soap webservice and return the methods it exposes.

`  
Function Check\_WebService{Param([string] $wsdl)  
Process{  
write-host “checking: $wsdl”

# create a credential object. Have to convert the pw to a ‘secure string’ before you can create the cred object

$username = “1”  
$secpasswd = ConvertTo-SecureString “password” -AsPlainText -Force  
$credential = New-Object System.Management.Automation.PSCredential ($username, $secpasswd)

# or use this to prompt for username and password

#$credential = Get-Credential  
try {

# create the proxy, specifying a namespace and target class to represent the interface

$ws\_proxy = New-WebServiceProxy -Uri $wsdl -Namespace “Soap11” -Class “Soap11” -Credential $credential

# get hold of the namespace so you can start creating a suitable request object

$namespace = $ws\_proxy.GetType().Namespace

# find out what you can do using the proxy

$ws\_proxy| Get-Member -MemberType Method

$ws\_proxy.Dispose()  
} catch {  
write-host $\_.Exception.Message  
write-host “Failed while checking: $wsdl”  
exit(1)  
}  
}}

write-host “checking that interfaces can be generated by .net”

# wsdl location for the web service to poke:

# Endpoint to check

Check\_WebService -wsdl “[http://hostname/path/to/your.wsdl](http://hostname/path/to/your.wsdl)”

`

Another way to do this would be to use a tool such as SoapUI which contains a program called ‘testrunner’ which lets you run soapui tests from the command line.

Jon
