Skip to main content

Hi

Sorry if the question appears rudimentary but we need some help urgently. We are trying to upload files in a SOAP web service request using A360 to SAP Ariba. The SOAP web service action doesn’t seem to have any feature to attach any files.

 

Regards

Saptarshi

Hi @SaptarshiS104323 

 

The SOAP Web Service action in Automation Anywhere A360 doesn’t natively support file attachments. However, you can work around this limitation by using the REST Web Service action, which supports multipart/form-data for file uploads.

Here are some steps and example scripts for handling file attachments in a SOAP request using PowerShell and VBScript.

 

PowerShell Script

PowerShell is quite powerful for handling web requests and file operations. Here’s an example of how you can use PowerShell to attach a file to a SOAP request:

# Define the SOAP request with a placeholder for the file content
$soapRequest = @"
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:urn="urn:sap-com:document:sap:rfc:functions">
<soapenv:Header/>
<soapenv:Body>
<urn:YourFunction>
<FileContent>{0}</FileContent>
</urn:YourFunction>
</soapenv:Body>
</soapenv:Envelope>
"@

# Read the file content and encode it to Base64
$filePath = "C:\path\to\your\file.txt"
$fileContent = tSystem.IO.File]::ReadAllBytes($filePath)
$base64FileContent = tConvert]::ToBase64String($fileContent)

# Insert the Base64 encoded file content into the SOAP request
$soapRequest = $soapRequest -f $base64FileContent

# Define the SOAP endpoint
$soapEndpoint = "https://your.soap.endpoint"

# Send the SOAP request
$response = Invoke-WebRequest -Uri $soapEndpoint -Method Post -ContentType "text/xml" -Body $soapRequest

# Output the response
$response.Content

 

VBScript

VBScript can also be used to handle SOAP requests, though it’s a bit more cumbersome. Here’s an example:

 

' Define the SOAP request with a placeholder for the file content
Dim soapRequest
soapRequest = "<soapenv:Envelope xmlns:soapenv='http://schemas.xmlsoap.org/soap/envelope/' xmlns:urn='urn:sap-com:document:sap:rfc:functions'>" & _
"<soapenv:Header/>" & _
"<soapenv:Body>" & _
"<urn:YourFunction>" & _
"<FileContent>{0}</FileContent>" & _
"</urn:YourFunction>" & _
"</soapenv:Body>" & _
"</soapenv:Envelope>"

' Read the file content and encode it to Base64
Dim objFSO, objFile, fileContent, base64FileContent
Set objFSO = CreateObject("Scripting.FileSystemObject")
Set objFile = objFSO.OpenTextFile("C:\path\to\your\file.txt", 1)
fileContent = objFile.ReadAll
objFile.Close

' Encode to Base64 (requires a custom function or external library)
base64FileContent = EncodeBase64(fileContent)

' Insert the Base64 encoded file content into the SOAP request
soapRequest = Replace(soapRequest, "{0}", base64FileContent)

' Define the SOAP endpoint
Dim soapEndpoint
soapEndpoint = "https://your.soap.endpoint"

' Send the SOAP request
Dim xmlhttp
Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP")
xmlhttp.Open "POST", soapEndpoint, False
xmlhttp.setRequestHeader "Content-Type", "text/xml"
xmlhttp.send soapRequest

' Output the response
WScript.Echo xmlhttp.responseText

Function EncodeBase64(input)
' Custom function to encode to Base64
' Implementation depends on your environment
End Function

 

Custom Functions: In VBScript, you might need a custom function or external library to handle Base64 encoding.

 

 


That’s an interesting question, SaptarshiS104323 !

I think the following community members may be able to help 

@Zaid Chougle 

@Tamil Arasu10 

@Sridhar Yadlapalli 

@Ashwin A.K 

@Padmakumar 


Hi ​@SaptarshiS104323 ,

 

Direct file attachment is typically not supported as a binary upload in SOAP calls; instead, files are uploaded as Base64-encoded content within the XML payload. Constructing the SOAP XML manually and sending it via HTTP Request action is the most flexible approach in A360.

 

  1. Manually Construct SOAP XML:

    • Instead of using the SOAP action’s automatic parameter mapping, build the full SOAP XML request as a string variable.
    • Embed the Base64 file content in the correct XML tag.
    • Use the SOAP Web Service action or HTTP Request action to send this raw XML.
  2. Use HTTP Request Action:

    • If the SOAP Web Service action is limited, use the HTTP Request action to send a POST request.
    • Set the Content-Type to 

      text/xml

       or 

      application/soap+xml

    • Pass your constructed SOAP XML with the embedded Base64 file.

Reply