How to add WS security element to SOAP request in powershell?

This topic contains 1 reply, has 2 voices, and was last updated by  Don Jones 1 week, 5 days ago.

  • Author
    Posts
  • #85060

    Tatiana
    Participant

    Hi all,

    I have a SOAP request, the example is below.






    – 2017-11-28T06:11:16.669Z
    – 2017-11-28T06:515:16.669Z


    – xxx
    – PASSWORD
    – password
    – 2017-11-28T06:11:12.637Z





    – xxx
    – yyy
    – CSV

    – zzz

    – en_US

    – 2





    – display_options
    – default




    And I figured out how to add all parameters to the body.
    $URL = "https://expedialc.skillwsa.com/olsa/services/Olsa?WSDL"
    $proxy = New-WebServiceProxy -Uri $URL

    $type = $proxy.GetType().Namespace
    $mySubmitDT = ($type + '.SubmitReportRequest')
    $mySubmit = New-Object($mySubmitDT)
    $mySubmit.customerId = "xxx"
    $mySubmit.report = "yyy"
    $mySubmit.scopingUserId = "zzz"
    $mySubmit.language = "en_US"
    $mySubmit.duration = 1

    $reportFormatDT = ($type + '.reportFormat')
    $reportFormat = New-Object($reportFormatDT)
    $reportFormat.value__ = 2

    $MapItemtDT = ($type + '.MapItem')
    $MapItemt = New-Object($MapItemtDT)
    $MapItemt.key = "display_options"
    $MapItemt.value = "default"

    $mySubmit.reportFormat = $reportFormat
    $mySubmit.reportParameters = $MapItemt

    #[xml]$result = $proxy.UD_SubmitReport($mySubmit)

    But no idea how to add security header with UserToken and Timestamp.

    Thanks,
    Tatiana

  • #85079

    Don Jones
    Keymaster

    Note that you can't paste XML here. You'd need to make it a Gist, and paste the Gist URL, just as with code.

    Referencing https://stackoverflow.com/questions/1309767/adding-custom-http-headers-to-web-service-proxy, this isn't a straightforward thing. Because the proxy class is an abstraction, you'd need to do some heavier .NET coding in order to add custom HTTP headers. The WebServiceProxy command itself is meant to be simplistic, and it doesn't support custom headers.

You must be logged in to reply to this topic.