如何使用 PowerShell 在 SecuredAuthenticationSoapHeader 中传递用户名和密码?
我有一个名为 AuthenticateUser() 的 SOAP 方法,它是在 C# 中定义的,
[WebMethod(Description = "Returns a token string given a username and password.")]
[System.Web.Services.Protocols.SoapHeader(nameof(AuthenticationHeader))]
public AuthenticationResponse AuthenticateUser()
{
...
}
其中 AuthenticationHeader 的类型是
public SecuredAuthenticationSoapHeader AuthenticationHeader;
我正在尝试调用此方法来获取令牌,以便我可以使用该令牌来调用 Web 服务中的其他方法。
当我在 SOAP-UI 中进行此调用时,XML 如下所示
<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>
但是,如何在 PowerSHell 中使用 Invoke-WebRequest
或 New-WebServiceProxy
执行此操作? 是否有其他方法可以像在 SOAP-UI 中一样传递 XML?
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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论