Reputation: 4483
I have a SOAP method called AuthenticateUser() that is defined in C# like this
[WebMethod(Description = "Returns a token string given a username and password.")]
[System.Web.Services.Protocols.SoapHeader(nameof(AuthenticationHeader))]
public AuthenticationResponse AuthenticateUser()
{
...
}
where AuthenticationHeader is type
public SecuredAuthenticationSoapHeader AuthenticationHeader;
I'm trying to make a call to this method to get a token so I can use the token to make calls to other methods in the webservice.
When I make this call in SOAP-UI the XML looks like this
<soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:web="https://www.example.com/webservices">
<soap:Header>
<web:SecuredAuthenticationSoapHeader>
<web:UserName>myusername</web:UserName>
<web:Password>mypassword</web:Password>
</web:SecuredAuthenticationSoapHeader>
</soap:Header>
<soap:Body>
<web:AuthenticateUser/>
</soap:Body>
</soap:Envelope>
However how can I do this in PowerSHell using Invoke-WebRequest
or New-WebServiceProxy
?
Is there an alternative way in which I just pass the XML as I do in SOAP-UI?
Upvotes: 1
Views: 155