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

Welcome Forums General PowerShell Q&A How to add WS security element to SOAP request in powershell?

Viewing 1 reply thread
  • Author
    Posts
    • #85060
      Participant
      Topics: 1
      Replies: 0
      Points: 0
      Rank: Member

      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
      Keymaster
      Topics: 18
      Replies: 4872
      Points: 1,904
      Helping HandTeam Member
      Rank: Community Hero

      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.

Viewing 1 reply thread
  • The topic ‘How to add WS security element to SOAP request in powershell?’ is closed to new replies.