none
webservices

    Question

  • Hi,

    as I can make a script to check a Web service and that it is responding, restart the server? do a get for x seconds, but resolved only restart the web server.

    Thanks for your help.
    Friday, December 16, 2011 7:35 AM

Answers

All replies

  • This article should provide you all you need:

    Request/Response Testing with Windows PowerShell


    ([string](0..9|%{[char][int](32+("39826578846355658268").substring(($_*2),2))})).replace(' ','')
    Friday, December 16, 2011 7:58 AM
  • A simple test to check if a website is responding to Get commands is the following (replace $url with the site you want to test) :

     

    $url = 'http://www.mweb.co.za/default.html'
    $wc = new-object net.WebClient
    try {$wc.downloadData($url) | Out-Null
        Write-Host "Website $url is responding"
        }
    catch {
        Write-Host "Website $url is not responding"
        }

     


    ([string](0..9|%{[char][int](32+("39826578846355658268").substring(($_*2),2))})).replace(' ','')


    • Edited by Bigteddy Friday, December 16, 2011 8:52 AM
    Friday, December 16, 2011 8:18 AM
  • A webservice is not a web site.  A web service is a SOAP API call.  It needs to be done using the POwerSHell New-WebServiceProxy call. 

    The IIS can be up and we can get a responce fromIIS but the service itself mauy not be functioning to to apppool availability or a database or other resource not working.

    "Web Service Up" is relative to the functionality of the web service.

    The link to teh blog on Web Site testing is very good but is only useful for web sites and not specific to Web Services.

     


    jv
    • Edited by jrv Friday, December 16, 2011 9:04 AM
    Friday, December 16, 2011 9:02 AM
  • I see.  So what you're saying is how you implement New-WebServiceProxy will depend on the services/methods that the website under test provides?  For example, from the help of New-WebServiceProxy:

    $URI = "http://www.webservicex.net/uszip.asmx?WSDL"
    $zip = New-WebServiceProxy -uri $URI -namespace WebServiceProxy -class ZipClass
    $zip | get-member -type method
    $zip.getinfobyzip(20500).table

    ...produces the following output, because the method call 'getinfobyzip' was successfull:

    CITY      : Washington
        STATE     : DC
        ZIP       : 20500
        AREA_CODE : 202
        TIME_ZONE : E

     

    Am I getting the right idea?


    ([string](0..9|%{[char][int](32+("39826578846355658268").substring(($_*2),2))})).replace(' ','')
    Friday, December 16, 2011 9:19 AM
  • Not really - get a web proxy and call it.  If the call works then the service is probably up.

    Here is MS method: http://msdn.microsoft.com/en-us/library/ms243399(v=vs.80).aspx

    Try this:

    $ws=new-webserviceproxy http://www.w3schools.com/webservices/tempconvert.asmx
    $ws.CelsiusToFahrenheit(100)

    http://www.w3schools.com/webservices/ws_example.asp

    WSDL -> http://www.w3schools.com/webservices/tempconvert.asmx

     

     


    jv
    Friday, December 16, 2011 9:59 AM
  • Yes, that's what I said:

    $zip.getinfobyzip(20500).table

    ...produces the following output, because the method call 'getinfobyzip' was successfull

     

    I think I get the idea.  It does depend on the methods that the particular service provides.  The zip service doesn't have  .CelciusToFarenheit() method, and your site's service doesn't have a .GetInfoByZip() method.

     


    ([string](0..9|%{[char][int](32+("39826578846355658268").substring(($_*2),2))})).replace(' ','')

    • Edited by Bigteddy Friday, December 16, 2011 10:14 AM
    Friday, December 16, 2011 10:11 AM
  • The WSDL is provided as part of teh page that gives access to the service but the service is really what is behind the page in most cases although sometimes the page is the whole service.  "Up" has a meaning that is tied to the functionality of the service.  Some services are exposed database procedures.  The Web site WSDL may be available and straight HTML will return the definition page but the underlying database can be down.

    Yes - your example was coor3ect.  I think I did my post just before you posted the example as it was not a response to that post but a continuation of the earlier explanation which I though would be more helpful than the help version since it is an actual web service that you can call and test.

     

     


    jv
    Friday, December 16, 2011 3:39 PM
  • does not respond, as I can remotely run a net stop?  Thanks

    Thursday, December 22, 2011 5:57 PM
  • SO trhe real question was "How can a stop a web 'server' NOT 'service'

    How can you stop a service on a remote machine?

    net stop will not run remotely.

    SC will:

    sc server1 stop "World Wide Web Publishing Service"

     


    jv
    Thursday, December 22, 2011 6:25 PM