Guest User

Untitled

a guest
Nov 21st, 2023
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <#
  2.     .SYNOPSIS
  3.     Submits a SOAP request to Jack Henry.
  4.  
  5.     .DESCRIPTION
  6.     This function submits SOAP calls to Jack Henry that normally would be done in Enterprise Workflow.
  7.     With this, you're able to perform customer inquries, maintenance, and modifications exteranlly
  8.     from SilverLake/Synapsis/etc.
  9.  
  10.     .NOTES
  11.     Creating the soapBody:
  12.         I recommend you keep the SOAP call in a separate file in a formatted string format, and use
  13.         Get-Content to load the call into a variable, then load your missing values for the call.
  14.  
  15.         $rawSoapString = Get-Content -Path "C:\Path\To\XmlCall" -Raw
  16.         [xml] $testSoapBody = [string]::Format($rawSoapString, $val1, $val2, etc.)
  17.  
  18.     .PARAMETER soapCallId
  19.     The name of the SOAP to be performed. A list of valid options can be found in .LINK
  20.  
  21.     .PARAMETER soapBody
  22.     The body of the SOAP request. This will need to be created and sent as an XML object.
  23.  
  24.     .EXAMPLE
  25.     InvokeSoapRequest -soapCallId CRMEventInq -soapBody $testSoapBody
  26.  
  27.     .LINK
  28.     SilverLake SOAP Calls: https://jackhenry.dev/open-enterprise-api-docs/enterprise-soap-api/api-provider/silverlake/
  29.     Synapsis SOAP Calls: https://jackhenry.dev/open-enterprise-api-docs/enterprise-soap-api/api-provider/synapsys/
  30. #>
  31.  
  32. function InvokeSoapRequest {
  33.     [CmdletBinding()]
  34.     param (
  35.         # The actual tag name for the SOAP call you want to perform.
  36.         [Parameter(Mandatory)]
  37.         [string]
  38.         $soapCallId,
  39.         # The XML SOAP Body of the call you want to perform
  40.         [Parameter(Mandatory)]
  41.         [xml]
  42.         $soapBody
  43.     )
  44.     begin {
  45.         # Set Variables
  46.         $return = [PSCustomObject]@{
  47.             StatusCode  = $null
  48.             Content     = $null
  49.             ErrorReason = $null
  50.         }
  51.  
  52.         [PSCustomObject]$headers = @{}
  53.         $headers.Add('SOAPAction', "http://jackhenry.com/ws/$($soapCallId)")
  54.  
  55.         $urlEndpoint = "https://jxappinternal.jha-sys.com/jxchange/2008/servicegateway/servicegateway.svc"
  56.     }
  57.     process {
  58.         try {
  59.             $wr = Invoke-WebRequest -Uri $urlEndpoint -Headers $headers -Body $soapBody -Method POST `
  60.              -ContentType 'text/xml'
  61.            
  62.             $return.StatusCode = $wr.StatusCode
  63.             $return.Content = [xml] $wr.Content
  64.         }
  65.         catch {
  66.             $return.StatusCode = 500
  67.             $errContent = [xml] $_
  68.             $errElem = $errContent.Envelope.Body.Fault.detail.HdrFault.FaultRecInfoArray.FaultMsgRec.ErrElem
  69.             $errMsg = $errContent.Envelope.Body.Fault.detail.HdrFault.FaultRecInfoArray.FaultMsgRec.ErrDesc
  70.             $return.ErrorReason = "($errElem): $errMsg"
  71.         }
  72.     }
  73.     end {
  74.         return $return
  75.     }
  76. }
Advertisement
Add Comment
Please, Sign In to add comment