Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

cURL Options Issue - SOAP Envelope

Featured Replies

Hello All - I have a script that that uploads an XML Payload to my merchant service to process credit cards.  I have been using this script since 2016 and Pineapple Payments (formally Nelix/Transax) moved servers and added coding to include a SOAP envelope.  I'm using a Set Variable for the cURL options on the Insert from URL script step.  My coding works in Postman but NOT Filemaker 19.  I get the error from the Transax Server : <soap:Reason><soap:Text xml:lang="en">Server was unable to process request. ---&gt; Data at the root level is invalid. Line 1, position 1.</soap:Text></soap:Reason>

Does FMP 19 support SOAP?

Here is the Set Variable ($curlOptions):

 

Let (
   [
      $curlOptions = "--location" & "¶" &
      "--header \"Content-Type: text/xml\"" & "¶" &
      "--header \"SOAPAction: \"https://secure.transaxgateway.com/roxapi/ProcessTransaction\"\"" & "¶" &
      "--data-raw '<?xml version=\"1.0\" encoding=\"utf-8\"?><soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"><soap:Body><ProcessTransaction xmlns=\"https://secure.transaxgateway.com/roxapi/\"><objparameters>" &

      "<TransactionType>" & TRX__TRANSAX_tog::transactiontype & "</TransactionType>" &
      "<GatewayUserName>" & TRX__TRANSAX_tog::username & "</GatewayUserName>" &
      "<GatewayPassword>" & TRX__TRANSAX_tog::password & "</GatewayPassword>" &
      "<Custom_Field_1>" & TRX__TRANSAX_tog::merchantdefined1 & "</Custom_Field_1>" &
      "<Custom_Field_2/>" &
      "<PaymentType>" & TRX__TRANSAX_tog::paymenttype & "</PaymentType>" &
      "<SAFE_ID/>" &
      "<CCNumber>" & TRX__TRANSAX_tog::CCnumber & "</CCNumber>" &
      "<CCExpDate>" & TRX__TRANSAX_tog::CCExpDate & "</CCExpDate>" &
      "<CVV>" & TRX__TRANSAX_tog::cvv2 & "</CVV>" &
      "<Amount>" & TRX__TRANSAX_tog::amount & "</Amount>" &
      "<OrderDescription/>" &
      "<FirstName>" & TRX__TRANSAX_tog::firstname & "</FirstName>" &
      "<LastName>" & TRX__TRANSAX_tog::lastname & "</LastName>" &
      "<Company/>" &
      "<Address1>" & TRX__TRANSAX_tog::address1 & "</Address1>" &
      "<City>" & TRX__TRANSAX_tog::city & "</City>" &
      "<State>" & TRX__TRANSAX_tog::state & "</State>" &
      "<Zip>" & TRX__TRANSAX_tog::zip & "</Zip>" &
      "<Country>" & TRX__TRANSAX_tog::country & "</Country>" &

      "</objparameters></ProcessTransaction></soap:Body></soap:Envelope>'"
   ];
   "curl " & Quote("--request POST ") & Quote("--url 'https://secure.transaxgateway.com/roxapi/rox.asmx' ") & $curlOptions
)

Which gives me this output  AND works in Postman:

curl --location 'https://secure.transaxgateway.com/roxapi/rox.asmx' \ 
--header 'Content-Type: text/xml'  \
--header 'SOAPAction: "https://secure.transaxgateway.com/roxapi/ProcessTransaction"' \
--data-raw '<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
     <soap:Body>
           <ProcessTransaction xmlns="https://secure.transaxgateway.com/roxapi/">
               <objparameters>
                  <TransactionType>sale</TransactionType>
                  <GatewayUserName>TransaxDemo5</GatewayUserName>
                  <GatewayPassword>ApiUser@2023</GatewayPassword>
                  <Custom_Field_1>Test</Custom_Field_1>
                  <Custom_Field_2/>
                  <PaymentType>CreditCard</PaymentType>
                  <SAFE_ID/>
                  <CCNumber>411111111111111</CCNumber>
                  <CCExpDate>0426</CCExpDate>
                  <CVV>123</CVV>
                  <Amount>10400</Amount>
                  <OrderDescription/>
                  <FirstName></FirstName>
                  <LastName></LastName>
                  <Company/>
                  <Address1>2 AnyRoad Rd</Address1>
                  <City>Albany Township</City>
                  <State>ME</State>
                  <Zip>04217</Zip>
                  <Country>United States</Country>
              </objparameters>
         </ProcessTransaction>
   </soap:Body>
</soap:Envelope>'

And my Insert from URL:

Insert from URL [ TRX__TRANSAX_tog::results; "https://secure.transaxgateway.com/roxapi/rox.asmx"; cURL options: $curlOptions][ Do not automatically encode URL; Select; No dialog; Verify SSL Certificates ]  

TL;DR

So what was the actual problem?

  • Author

Syntax as far as I can tell.  I did not try to disprove the solution once I had it.  Several lines had small differences  For example:  Line 4 "http://www.w3.org/2001/XMLSchema-instance"  to "http://www.w3.org/2001/XMLSchema"  The big difference was removing the Let and setting everything with variables - perhaps this removed a "¶" or " " (you have helped me with those pesky nuisances before) that was throwing a spanner in the works?  Also in comparing the above example the leading "curl" code on line 1 is omitted in the working solution. I don't know the "under the hood" working of Insert from URL.  Does Filemaker implement that command innately?  Ultimately I did not write the original code and still have little understanding of cURL.  Thanks Comment!

 

Set Variable [ $url ; Value: "https://secure.transaxgateway.com/roxapi/rox.asmx" ]
Set Variable [ $content_type ; Value: "Content-Type: text/xml" ]
Set Variable [ $soap_action ; Value: "SOAPAction: \"https://secure.transaxgateway.com/roxapi/ProcessTransaction\"" ]

Set Variable [ $xml_data ; Value: "<?xml version=\"1.0\" encoding=\"utf-8\"?>
<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\">
    <soap:Body>
        <ProcessTransaction xmlns=\"https://secure.transaxgateway.com/roxapi/\">
            <objparameters>
                <!-- Your request data goes here -->
            </objparameters>
        </ProcessTransaction>
    </soap:Body>
</soap:Envelope>" ]

Set Variable [ $curl_options ; Value: "--location " & Quote($url) & " --header " & Quote($content_type) & " --header " & Quote($soap_action) & " --data-raw " & Quote($xml_data) ]

Insert from URL [ With dialog: Off ; $url ; your_table::your_target_field ; cURL options: $curl_options ]
 

41 minutes ago, Jim Gill said:

For example:  Line 4 "http://www.w3.org/2001/XMLSchema-instance"  to "http://www.w3.org/2001/XMLSchema" 

I see no such difference between your original post's version and the latest one. It's too bad we can't learn anything useful from your experience. I wonder if your original attempt wouldn't work if you had just removed the single quotes surrounding the XML data.

I would still recommend you try attaching the $xml_data variable to the command, as explained in the linked answer, instead of injecting it as text.

--
BTW, instead of constructing the variable using a mix of quoted text and field references, which is highly unreadable and (therefore) error-prone. I would suggest using a template with placeholder text, which you can then easily substitute with the real data. Such template can be created by the Insert Text script step with a variable as the target. This saves all the bother with escaping quotes and ambiguous line breaks.

 

 

  • Author

Thank you comment!  You have always been help and every time in interact with you I learn something new.

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Account

Navigation

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.