{"id":61,"date":"2013-11-08T05:16:09","date_gmt":"2013-11-08T10:16:09","guid":{"rendered":"http:\/\/powershell.erichcottom.com\/?p=61"},"modified":"2014-03-05T04:52:55","modified_gmt":"2014-03-05T09:52:55","slug":"61","status":"publish","type":"post","link":"https:\/\/powershell.erichcottom.com\/?p=61","title":{"rendered":"SOAP Example"},"content":{"rendered":"<p>This is a bit of example code for connecting to a SOAP API that uses an auth call and cookies for logging into the API. For more complex type like xml you will have to handle the output.<\/p>\n<pre class=\"brush: powershell; gutter: true\"># Connection vars\r\n$HostName = ''\r\n$UserName = ''\r\n$Password = ''\r\n$SoapUrl = \"http:\/\/$HostName\/soap3\/api.wsdl\";\r\n$Client = New-WebServiceProxy -Uri $SoapUrl\r\n$Client.CookieContainer = New-Object System.Net.CookieContainer\r\nif(!$Client.authenticate($UserName, $Password))\r\n{\r\n    Write-Host -BackgroundColor black -ForegroundColor red \"Unable to connect to $HostName\"\r\n}\r\n$Client.getAuthenticatedLevel()\r\n$a = $Client.core_getDevices()\r\n$a.getType()\r\n$a<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>This is a bit of example code for connecting to a SOAP API that uses an auth call and cookies for logging into the API. For more complex type like xml you will have to handle the output. # Connection &hellip; <a href=\"https:\/\/powershell.erichcottom.com\/?p=61\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16,7,8],"tags":[26,27],"class_list":["post-61","post","type-post","status-publish","format-standard","hentry","category-poshtested","category-powershell","category-scripts","tag-api","tag-soap"],"_links":{"self":[{"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=\/wp\/v2\/posts\/61","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=61"}],"version-history":[{"count":15,"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions"}],"predecessor-version":[{"id":77,"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=\/wp\/v2\/posts\/61\/revisions\/77"}],"wp:attachment":[{"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=61"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=61"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/powershell.erichcottom.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=61"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}