1

我有一个名为 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-WebRequestor来做到这一点New-WebServiceProxy?是否有另一种方法可以像在 SOAP-UI 中那样传递 XML?

4

0 回答 0