3 Replies Latest reply on May 12, 2016 9:54 AM by Steve Sommers

    Problems with ColdFusion11 and Cybersource SOAP

    User Since V1.5

      I'm having a great deal of trouble trying to implement a SOAP call to CyberSource, and I'd appreciate any help that anyone can provide.

       

      The environment: ColdFusion 11 on Windows 2012 Server, 64-bit.

       

      The SOAP packet (personal info redacted) is as follows; it's basically the CyberSource sample provided in their documentation:

       

      <?xml version="1.0" encoding="utf-8"?>

      <soapenv:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"

           xsi:schemaLocation="http://schemas.xmlsoap.org/soap/envelope/"

           xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/">

          <soapenv:Header>

          <wsse:Security soapenv:mustUnderstand="1" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">

          <wsse:UsernameToken>

          <wsse:Username>XXXXXXX</wsse:Username>

          <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0##Passwo rdText">XXXXXXX</wsse:Password>

          </wsse:UsernameToken>

          </wsse:Security>

          </soapenv:Header>

          <soapenv:Body>

              <requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.126">

              <merchantID>XXXXXXX</merchantID>

              <merchantReferenceCode>XXXXXXX</merchantReferenceCode>

              <billTo>

                  <firstName>XXXXXXX</firstName>

                  <lastName>XXXXXXX</lastName>

                  <street1>XXXXXXX</street1>

                  <street2></street2>

                  <city>XXXXXXX</city>

                  <state>XX</state>

                  <postalCode>XXXXXXX</postalCode>

                  <country>XX</country>

                  <phoneNumber>000 000 0000</phoneNumber>

                  <email>null@cybersource.com</email>

              </billTo>

              <item id="0">

                  <unitPrice>65.00</unitPrice>

                  <quantity>1</quantity>

              </item>

              <purchaseTotals>

                  <currency>USD</currency>

              </purchaseTotals>

              <card>

                  <accountNumber>4111111111111111</accountNumber>

                  <cvNumber>000</cvNumber>

                  <expirationMonth>10</expirationMonth>

                  <expirationYear>2018</expirationYear>

              </card>

              <ccAuthService run="true"/>

              </requestMessage>

          </soapenv:Body>

      </soapenv:Envelope>

       

      The transmission is as follows:

       

      <cfhttp url="https://ics2wstesta.ic3.com/commerce/1.x/transactionProcessor" method="post" port="443" resolveurl="false" result="httpResponse">

      <cfhttpparam type="header" name="content-type" value="text/xml; charset=utf-8"/>

      <cfhttpparam type="header" name="accept-encoding" value="no-compression"/>

      <cfhttpparam type="header" name="content-length" value="#Len(Trim(variables.soap_packet))#"/>

      <cfhttpparam type="xml" value="#Trim(variables.soap_packet)#"/>

      </cfhttp>

       

      The response from CyberSource is:

       

      <?xml version="1.0" encoding="UTF-8"?> <soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"> <soap:Body> <soap:Fault xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/04/secext" xmlns:c="urn:schemas-cybersource-com:transaction-data-1.0"> <faultcode>soap:Client</faultcode> <faultstring> XML parse error. </faultstring> </soap:Fault> </soap:Body> </soap:Envelope>

       

      There are two interesting things going on.

       

      1. Initially, I built the SOAP packet by enclosing the above item like this:

       

          <cfsavecontent var="soap_packet"><cfoutput>.....</cfoutput></cfsavecontent>.

       

      When I tested the resulting string via #IsXML(Trim(XMLFormat(variables.soap_packet)))#, I got "NO".

       

      Then I built the packet by enclosing the above item like this:

       

          <cfxml variable="soap_xml"><cfoutput>.....</cfoutput></cfxml>,

       

      which produces a SOAP document object. I then converted that document object to a string via

       

          <cfset soap_packet = #ToString(variables.soap_xml)#>

         

      Testing the result via #IsXML(Trim(variables.soap_packet))#, I got "YES", and that's what I'm passing in the transmission.

       

      So there's the first issue: Why is ColdFusion apparently producing different results for the two approaches?

       

      2. Assuming I'm passing well-formed and valid XML with the second approach, why is the interaction with CyberSource failing?

       

      As I've said, this is becoming very frustrating. Can anyone tell me what I'm doing wrong?

        • 1. Re: Problems with ColdFusion11 and Cybersource SOAP
          Steve Sommers Level 4

          "XML parse error" is usually a pretty straight forward issue to fix. I ran your sample above through a parser and it appears valid. I'm guessing that the username and/or password that you masked in the sample contains one or more characters that require encoding and this is not being done - or being encoded incorrectly.

           

          Off-topic, your sample included card information. Cybersource should have either a tokenization solution or a hosted payment page so your site does not touch the actual card information. If at all possible you want to avoid having your site touch card data as it will be very costly to maintain PCI compliance and makes you a target for hackers. A single breach can easily cost you thousands of dollars.

          • 2. Re: Problems with ColdFusion11 and Cybersource SOAP
            User Since V1.5 Level 1

            Thanks, but I don't believe that's the issue. The password, which I show here because (a) it's to a test environment and (b) it's useless without the username, is this:

             

            BZeCO7/q0Gvz3NiZVjr338wgT73xV8afdvoH56n7+AZhmy+0utbpKQbCivk8JzM9N4dl40MmY2aFZRFH1a3aPF8Wnr PLASatfGk+W1p9aA67odWxbIC0Wsd5hFzLrJsTGbe90TkXcApimgkYI4MOGYRERcOKbIabzQodjPxebhNbWWI71Ary szF/F04wmwrJVx1RG8aLrAG2SLouO+iJ5qvNNKib7QB3+AcWKWAqDWvSgYs0LVcHmNFwYvOmi1alo5gNh1nCiRBbQD ueZZ55C9/aiXNms+Rkumaqass9T4qpPW1qXmoBToYLFVdMCN6dfhsKmCWTfoFjGtlWr0zpUw==

             

            As you can see, no XML-averse characters. But just to be certain, I'm now doing this: #Trim(EncodeForXML(the above string))# before passing it in my XML packet. No difference in the return result. And the username is pure alphanumerics. So I'm back to Square One. I suppose the username/password could have been created incorrectly by CyberSource, and I will look into that. I guess that it's also possible that CyberSource's documentation is incorrect.

             

            In any case, I wonder if anyone else has seen the apparent CF inconsistency that I described:

             

            <cfsavecontent var="soap_packet"><cfoutput>my text</cfoutput></cfsavecontent> produces a string. Then, IsXML(Trim(XMLFormat(that string))) returns FALSE.

             

            But <cfxml><cfoutput>my text</cfoutput></cfxml> produces an XML document object, and ToString(the XML document object) also produces a string. Then, IsXML(Trim(that string)) returns TRUE. What's going on?? The two processes should produce identical results, no?

             

            Regarding the card info, that's above my pay grade. I've just been told to get this process to work. Any further suggestions? I'll also be consulting CyberSource, of course....

            • 3. Re: Problems with ColdFusion11 and Cybersource SOAP
              Steve Sommers Level 4

              Maybe try visually comparing the two strings. I still think there is some encoding going on that you're not seeing. I never use cfxml so I can't help much further on that. When creating XML output, if it's a real simple XML doc I'll use cfsavecontent similar to what you show above. Anything more complex than the simplest of XML documents I'll create the xml manually and then use toString:

               

                <cfscript>

                  local.xml = xmlNew();

                  local.xml.xmlRoot = xmlElemNew(variables.xml,"i4goauth");

                  ...

                  local.outstr = toString(local.xml);

                </cfscript>