Execute a one-way wcf service operation from powershell

后端 未结 5 1737
情歌与酒
情歌与酒 2021-02-06 12:52

I have a scheduled task which executes a powershell script every hour. The powershell script must make a call to a one-way WCF service operation. Essentially it just needs to

5条回答
  •  旧巷少年郎
    2021-02-06 13:42

    I believe that you'll need to set the HTTP method first before attempting to get a response. By default, I believe the WebRequest object defaults to POST, but you'll actually need to set it to GET.

    I haven't used PowerShell scripting much, but based off of your sample it would look something like this:

    $request = [System.Net.WebRequest]::Create("http://myserver.com/myservice/dosomething") 
    $request.Method = "GET"
    $request.GetResponse()
    

    Hope that helps!

提交回复
热议问题