I am trying to:-
1- read data from excel for specific column header and sheet
2- loop each row and make a soap call
3- create the soap request, update some tags with cells value
4- store the request
5- make the call soap
5- store the soap response
6- update the same excel sheet row cells with returned value from specific tags
my code as below without step 6 but it is not working
# Define the path to the XLSX file and the SOAP endpoint
$xlsxPath = "C:Users????.xlsx"
# Define the path of SOAP response folder
$responseFolderPath = "C:Users??????"
# Define the path of SOAP endpoint
$soapEndpoint = "https://?????.???/????/ws"
# Define the excel sheet name
$sheetName = "??"
# Paybass the certitifcate
[System.Net.ServicePointManager]::ServerCertificateValidationCallback = {$true}
# Read the XLSX file
$data = Import-Excel -Path $xlsxPath -WorksheetName $sheetName -ImportColumns @("columnName1","columnName2") -NoHeader
# Iterate through each row of the data
$data | ForEach-Object {
# Read cells with specific headers (e.g., 'Header1', 'Header2')
$value1 = $row.columnName1
$value2 = $row.columnName2
# $value3 = $row.columnName
# Construct the SOAP request with the new values
$soapRequest = @"
<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:request xmlns:ns2="http://??/">
<aa>$value1</aa>
<bb>$value2</bb>
</ns2:request>
</soap:Body>
</soap:Envelope>
"@
# Store the XML request
$requestPath = "C:Userspathrequest_$($row.RowNumber).xml"
#$soapRequestContent = $soapRequest.Content
$soapRequest | Out-File -FilePath $requestPath
# Iterate through each SOAP request file in the folder
$filename = $_.Name
$responseFile = Join-Path -Path $responseFolderPath -ChildPath "${filename}_response.xml"
# Send SOAP request using Invoke-WebRequest
Invoke-WebRequest -Uri soapEndpoint -Method POST -ContentType "text/xml" -Body (Get-Content $_.FullName) -OutFile $responseFile
}
can you please help me