CyberSource / cybersource-sdk-php

PHP SDK for Cybersource SOAP Toolkit API
Other
55 stars 58 forks source link

XML Parsing Error #27

Open ziyadparekh opened 7 years ago

ziyadparekh commented 7 years ago

This is my XML

<?xml version="1.0" encoding="UTF-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:data="urn:schemas-cybersource-com:transaction-data-1.120" xmlns:tns="urn:schemas-cybersource-com:transaction-data:TransactionProcessor" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <soap:Body>
      <requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.120">
         <merchantReferenceCode>Unknown</merchantReferenceCode>
         <purchaseTotals>
            <currency>USD</currency>
            <grandTotalAmount>5.55</grandTotalAmount>
         </purchaseTotals>
         <billTo>
            <firstName>John</firstName>
            <lastName>Tester</lastName>
            <street1>123 Main Street</street1>
            <city>Columbia</city>
            <state>Sindh</state>
            <postalCode>75080</postalCode>
            <country>PK</country>
            <email>john.tester@example.com</email>
            <ipAddress>0.0.0.0</ipAddress>
         </billTo>
         <card>
            <accountNumber>4111111111111111</accountNumber>
            <expirationMonth>12</expirationMonth>
            <expirationYear>2018</expirationYear>
            <cvNumber>111</cvNumber>
         </card>
      </requestMessage>
   </soap:Body>
</soap:Envelope>

Not sure why its throwing a Parsing Error. Is it because its wrapped in a <soap:envelope> and <soap:Body> tags

juniormc commented 6 years ago

I have the same problem :(

Apparently the xml is fine.

Help please.

mrclmrvn commented 6 years ago

Using https://github.com/savonrb/savon

I'm getting the same error

2.1.2 :113 >   client = Savon.client(
2.1.2 :114 >       wsdl: 'https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.145.wsdl',
2.1.2 :115 >       element_form_default: :unqualified,
2.1.2 :116 >       namespace: 'urn:schemas-cybersource-com:transaction-data-1.145',
2.1.2 :117 >       namespaces: {
2.1.2 :118 >           'xmlns:wsse' => 'http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd'
2.1.2 :119?>       },
2.1.2 :120 >       pretty_print_xml: true,
2.1.2 :121 >       log: true
2.1.2 :122?>   )
 => #<Savon::Client:0x007fcdbfd0ad88 @globals=#<Savon::GlobalOptions:0x007fcdbfd0ad60 @option_type=:global, @options={:encoding=>"UTF-8", :soap_version=>1, :namespaces=>{"xmlns:wsse"=>"http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"}, :logger=>#<Logger:0x007fcdbfd0ace8 @progname=nil, @level=0, @default_formatter=#<Logger::Formatter:0x007fcdbfd0ac98 @datetime_format=nil>, @formatter=nil, @logdev=#<Logger::LogDevice:0x007fcdbfd0abd0 @shift_size=nil, @shift_age=nil, @filename=nil, @dev=#<IO:<STDOUT>>, @mutex=#<Logger::LogDevice::LogDeviceMutex:0x007fcdbfd0ab80 @mon_owner=nil, @mon_count=0, @mon_mutex=#<Mutex:0x007fcdbfd0ab30>>>>, :log=>true, :filters=>[], :pretty_print_xml=>true, :raise_errors=>true, :strip_namespaces=>true, :convert_response_tags_to=>#<Proc:0x007fcdbfd0aab8@/Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/options.rb:85 (lambda)>, :convert_attributes_to=>#<Proc:0x007fcdbfd0aa90@/Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/options.rb:86 (lambda)>, :multipart=>false, :adapter=>nil, :use_wsa_headers=>false, :no_message_tag=>false, :follow_redirects=>false, :unwrap=>false, :host=>nil, :wsdl=>"https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.145.wsdl", :element_form_default=>:unqualified, :namespace=>"urn:schemas-cybersource-com:transaction-data-1.145"}>, @wsdl=#<Wasabi::Document:0x007fcdbfd0a900 @document="https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.145.wsdl", @adapter=nil, @namespace="urn:schemas-cybersource-com:transaction-data-1.145", @request=#<HTTPI::Request:0x007fcdbfd0a838 @follow_redirect=false>>>
2.1.2 :123 >
2.1.2 :124 >
2.1.2 :125 >   body = {
2.1.2 :126 >       'merchantID' => 'strippedcreds',
2.1.2 :127 >       'merchantReferenceCode' => '201801-99999222',
2.1.2 :128 >       'billTo' => {
2.1.2 :129 >           'street1' => '1295 charleston boulevard',
2.1.2 :130 >           'city' => 'Mtn view',
2.1.2 :131 >           'state' => 'ca',
2.1.2 :132 >           'postalCode' => '94043'
2.1.2 :133?>       },
2.1.2 :134 >       'davService_run' => { :@run => 'true' }
2.1.2 :135?>   }
 => {"merchantID"=>"strippedcreds", "merchantReferenceCode"=>"201801-99999222", "billTo"=>{"street1"=>"1295 charleston boulevard", "city"=>"Mtn view", "state"=>"ca", "postalCode"=>"94043"}, "davService_run"=>{:@run=>"true"}}
2.1.2 :136 >
2.1.2 :137 >
2.1.2 :138 >   client.call(:run_transaction, message: body, attributes: { 'xmlns' => 'urn:schemas-cybersource-com:transaction-data-1.145' })
D, [2018-04-09T07:13:44.446728 #8606] DEBUG -- : HTTPI GET request to ics2wstest.ic3.com (httpclient)
D, [2018-04-09T07:13:44.447102 #8606] DEBUG -- : [httplog] Sending: GET https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor/CyberSourceTransaction_1.145.wsdl
D, [2018-04-09T07:13:44.447196 #8606] DEBUG -- : [httplog] Data:
D, [2018-04-09T07:13:44.447486 #8606] DEBUG -- : [httplog] Connecting: ics2wstest.ic3.com:443
D, [2018-04-09T07:13:45.802036 #8606] DEBUG -- : [httplog] Status: 200
D, [2018-04-09T07:13:45.802138 #8606] DEBUG -- : [httplog] Benchmark: 1.354723 seconds
D, [2018-04-09T07:13:45.802282 #8606] DEBUG -- : [httplog] Response:
<?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" name="CyberSourceTransactionWS" targetNamespace="urn:schemas-cybersource-com:transaction-data:TransactionProcessor" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:tns="urn:schemas-cybersource-com:transaction-data:TransactionProcessor" xmlns:data="urn:schemas-cybersource-com:transaction-data-1.145">
   <wsdl:types>
      <xsd:schema>
         <xsd:import namespace="urn:schemas-cybersource-com:transaction-data-1.145" schemaLocation="CyberSourceTransaction_1.145.xsd"/>
      </xsd:schema>
   </wsdl:types>
   <wsdl:message name="messageIn">
      <wsdl:part name="input" element="data:requestMessage"/>
   </wsdl:message>
   <wsdl:message name="messageOut">
      <wsdl:part name="result" element="data:replyMessage"/>
   </wsdl:message>
   <wsdl:portType name="ITransactionProcessor">
      <wsdl:operation name="runTransaction">
         <wsdl:input name="inputMessageIn" message="tns:messageIn"/>
         <wsdl:output name="outputMessageOut" message="tns:messageOut"/>
      </wsdl:operation>
   </wsdl:portType>
   <wsdl:binding name="ITransactionProcessor" type="tns:ITransactionProcessor">
      <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
      <wsdl:operation name="runTransaction">
         <soap:operation soapAction="runTransaction" style="document"/>
         <wsdl:input name="inputMessageIn">
            <soap:body use="literal"/>
         </wsdl:input>
         <wsdl:output name="outputMessageOut">
            <soap:body use="literal"/>
         </wsdl:output>
      </wsdl:operation>
   </wsdl:binding>
   <wsdl:service name="TransactionProcessor">
      <wsdl:documentation>CyberSource Web Service</wsdl:documentation>
      <wsdl:port name="portXML" binding="tns:ITransactionProcessor">
         <soap:address location="https://ics2wstest.ic3.com:443/commerce/1.x/transactionProcessor"/>
      </wsdl:port>
   </wsdl:service>
</wsdl:definitions>
I, [2018-04-09T07:13:45.804717 #8606]  INFO -- : SOAP request: https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor
I, [2018-04-09T07:13:45.804793 #8606]  INFO -- : SOAPAction: "runTransaction", Content-Type: text/xml;charset=UTF-8, Content-Length: 778
D, [2018-04-09T07:13:45.805096 #8606] DEBUG -- : <?xml version="1.0" encoding="UTF-8"?>
<env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:data="urn:schemas-cybersource-com:transaction-data-1.145" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd">
  <env:Body>
    <data:requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.145">
      <merchantID>strippedcreds</merchantID>
      <merchantReferenceCode>201801-99999222</merchantReferenceCode>
      <billTo>
        <street1>1295 charleston boulevard</street1>
        <city>Mtn view</city>
        <state>ca</state>
        <postalCode>94043</postalCode>
      </billTo>
      <davService_run run="true"/>
    </data:requestMessage>
  </env:Body>
</env:Envelope>

D, [2018-04-09T07:13:45.805514 #8606] DEBUG -- : HTTPI POST request to ics2wstest.ic3.com (httpclient)
D, [2018-04-09T07:13:45.805872 #8606] DEBUG -- : [httplog] Sending: POST https://ics2wstest.ic3.com/commerce/1.x/transactionProcessor
D, [2018-04-09T07:13:45.805995 #8606] DEBUG -- : [httplog] Data: <?xml version="1.0" encoding="UTF-8"?><env:Envelope xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:data="urn:schemas-cybersource-com:transaction-data-1.145" xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsse="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd"><env:Body><data:requestMessage xmlns="urn:schemas-cybersource-com:transaction-data-1.145"><merchantID>strippedcreds</merchantID><merchantReferenceCode>201801-99999222</merchantReferenceCode><billTo><street1>1295 charleston boulevard</street1><city>Mtn view</city><state>ca</state><postalCode>94043</postalCode></billTo><davService_run run="true"></davService_run></data:requestMessage></env:Body></env:Envelope>
D, [2018-04-09T07:13:45.806297 #8606] DEBUG -- : [httplog] Connecting: ics2wstest.ic3.com:443
D, [2018-04-09T07:13:47.169590 #8606] DEBUG -- : [httplog] Status: 500
D, [2018-04-09T07:13:47.169687 #8606] DEBUG -- : [httplog] Benchmark: 1.363457 seconds
D, [2018-04-09T07:13:47.169798 #8606] DEBUG -- : [httplog] Response:
<?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>

I, [2018-04-09T07:13:47.169992 #8606]  INFO -- : SOAP response (status 500)
D, [2018-04-09T07:13:47.170287 #8606] DEBUG -- : <?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>

Savon::SOAPFault: (soap:Client)
XML parse error.

    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/response.rb:85:in `raise_soap_and_http_errors!'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/response.rb:14:in `initialize'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/operation.rb:72:in `new'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/operation.rb:72:in `create_response'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/operation.rb:58:in `call'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/savon-2.11.1/lib/savon/client.rb:36:in `call'
    from (irb):138
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/railties-4.2.8/lib/rails/commands/console.rb:110:in `start'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/railties-4.2.8/lib/rails/commands/console.rb:9:in `start'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:68:in `console'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/railties-4.2.8/lib/rails/commands/commands_tasks.rb:39:in `run_command!'
    from /Users/user1/.rvm/gems/ruby-2.1.2@ls-member/gems/railties-4.2.8/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'
geowulf commented 5 years ago

You are missing the entire security section of the SOAP REQUEST

    <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>{{username}}</wsse:Username>
                <wsse:Password Type="http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordText">{{password}}</wsse:Password>
            </wsse:UsernameToken>
        </wsse:Security>
    </soapenv:Header>