Jump to content
Server Maintenance This Week. ×

cURL Options Issue - SOAP Envelope


Recommended Posts

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 ]  

Link to comment
Share on other sites

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 ]
 

Link to comment
Share on other sites

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.

 

 

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

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