WebServiceProxy

Welcome Forums General PowerShell Q&A WebServiceProxy

This topic contains 2 replies, has 2 voices, and was last updated by

 
Participant
1 year, 8 months ago.

  • Author
    Posts
  • #64708

    Participant
    Points: 0
    Rank: Member

    I have a web-servie (ws) and I would like to use Windows authentication in order to control allowed users to the ws.
    I am able to use WebServiceProxy to connect to the ws using HTTP without any issues, but if I use HTTPS, then it fails with this error: "Exception calling "Mymethod" with "3" argument(s): "The request failed with HTTP status 401: Unauthorized."

    Any idea as to why I am getting this error? I am only experiencing this error if I use the WebServiceProxy connection from a computer that is not part of the domain.

    *** Works ***

    $URI = "http://myserver/mywebservice/myapp.asmx" 
    $User = "domain\user"
    $secureStringpassword = ConvertTo-SecureString -String "password" -AsPlainText -Force;
    $MyCredential = New-Object -TypeName System.Management.Automation.PSCredential ($User, $secureStringpassword);
    $Web = New-WebServiceProxy -Uri $URI -Credential $MyCredential
    $Web.Mymethod("TES01","text1",text2")
    

    *** Doesn't Work ***

    $URI = "https://myserver/mywebservice/myapp.asmx" 
    $User = "domain\user"
    $secureStringpassword = ConvertTo-SecureString -String "password" -AsPlainText -Force;
    $MyCredential = New-Object -TypeName System.Management.Automation.PSCredential ($User, $secureStringpassword);
    $Web = New-WebServiceProxy -Uri $URI -Credential $MyCredential
    $Web.Mymethod("TES01","text1",text2")
    
  • #64764

    Keymaster
    Points: 1,524
    Helping HandTeam Member
    Rank: Community Hero

    The web server is returning that error. Keep in mind that, unlike IE, Web service proxies do not automatically know how to pass along Windows credentials. Generally speaking, web services aren't set up to require integrated authentication – it's not the usual model, at least.

  • #64774

    Participant
    Points: 0
    Rank: Member

    Hello Mr. Jones,

    Is there any reason why it works when just using HTTP but not in HTTPS?
    Also, it looks like the authentication is ok, but it fails when executing "$Web.Mymethod("TES01","text1",text2")".

    Clarification on the authentication, the authentication that I would like to use is digest authentication so I can restrict users in combination with HTTPS to add security.

    Thanks,

The topic ‘WebServiceProxy’ is closed to new replies.