title: Consuming Webservice Error - SOAP PHP
body: <p>I'm trying to send data to consume a webservice.
  But it returns the error:</p>
  
  <blockquote>
    <p>error: Server was unable to read request. --->  There is an error in
    XML document (2, 734). ---> The specified type is abstract:
    name='PaymentDataRequest', 
    namespace='https://www.pagador.com.br/webservice/pagador', at .</p>
  </blockquote>
  
  <p>Could anyone help me?
  Here my XML:</p>
  
  <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt;
      &lt;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/"&gt;
        &lt;soap:Body&gt;
      &lt;AuthorizeTransaction xmlns="https://www.pagador.com.br/webservice/pagador"&gt;
        &lt;request&gt;
          &lt;OrderData&gt;
            &lt;MerchantId&gt;xxxxxxxxxxxxxxx&lt;/MerchantId&gt;
            &lt;OrderId&gt;Test0003&lt;/OrderId&gt;
            &lt;BraspagOrderId xsi:nil="true" /&gt;
          &lt;/OrderData&gt;
          &lt;CustomerData&gt;
            &lt;CustomerIdentity&gt;99999999999&lt;/CustomerIdentity&gt;
            &lt;CustomerName&gt;Teste&lt;/CustomerName&gt;
            &lt;CustomerEmail&gt;compradot@teste.com&lt;/CustomerEmail&gt;
            &lt;CustomerAddressData xsi:nil="true" /&gt;
            &lt;DeliveryAddressData xsi:nil="true" /&gt;
          &lt;/CustomerData&gt;
          &lt;PaymentDataCollection&gt;
            &lt;PaymentDataRequest xsi:type="CreditCardDataRequest"&gt;
              &lt;PaymentMethod&gt;997&lt;/PaymentMethod&gt;
              &lt;Amount&gt;100&lt;/Amount&gt;
              &lt;Currency&gt;BRL&lt;/Currency&gt;
              &lt;Country&gt;BRA&lt;/Country&gt;
              &lt;NumberOfPayments&gt;1&lt;/NumberOfPayments&gt;
              &lt;PaymentPlan&gt;0&lt;/PaymentPlan&gt;
              &lt;TransactionType&gt;2&lt;/TransactionType&gt;
              &lt;CardHolder&gt;Comprador Teste&lt;/CardHolder&gt;
              &lt;CardNumber&gt;0000000000000001&lt;/CardNumber&gt;
              &lt;CardSecurityCode&gt;111&lt;/CardSecurityCode&gt;
              &lt;CardExpirationDate&gt;07/2017&lt;/CardExpirationDate&gt;
              &lt;AdditionalDataCollection xsi:nil="true" /&gt;
            &lt;/PaymentDataRequest&gt;
          &lt;/PaymentDataCollection&gt;
          &lt;RequestId&gt;80a51fb5-f9d7-44b8-bdc2-da2d533f3b8d&lt;/RequestId&gt;
          &lt;Version&gt;1.0&lt;/Version&gt;
        &lt;/request&gt;
      &lt;/AuthorizeTransaction&gt;
    &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>
  
  <p>Code:</p>
  
  <pre><code>$parameters             = new stdClass();
  $parameters-&gt;request    = new StdClass();
  
  $parameters-&gt;request-&gt;OrderData-&gt;MerchantId='xxxxxxxxxx';
  $parameters-&gt;request-&gt;OrderData-&gt;OrderId='Test0004';
  $parameters-&gt;request-&gt;CustomerData-&gt;CustomerIdentity='99999999999';
  $parameters-&gt;request-&gt;CustomerData-&gt;CustomerName='Teste';
  $parameters-&gt;request-&gt;CustomerData-&gt;CustomerEmail='compradot@teste.com';
  $parameters-&gt;request-&gt;CustomerData-&gt;CustomerEmail='compradot@teste.com';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest='997';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;Amount='100';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;Currency='BRL';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;Country='BRA';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;NumberOfPayments='1';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;PaymentPlan='0';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;TransactionType='2';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;CardHolder='Comprador Teste';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;CardNumber='0000000000000001';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;CardSecurityCode='111';
  $parameters-&gt;request-&gt;PaymentDataCollection-&gt;PaymentDataRequest-&gt;CardExpirationDate='07/2017';
  $parameters-&gt;request-&gt;RequestId='80a51fb5-f9d7-44b8-bdc2-da2d533f3b8d';                             
  $parameters-&gt;request-&gt;Version='1.0';
  
  try {
  
  $braspag = new SoapClient( 'https://homologacao.pagador.com.br/webservice/pagadorTransaction.asmx?WSDL',
  
          array(
                  'trace'                 =&gt; 1,
                  'exceptions'            =&gt; 1,
                  'style'                 =&gt; SOAP_DOCUMENT,
                  'use'                   =&gt; SOAP_LITERAL,
                  'soap_version'          =&gt; SOAP_1_1,
                  'encoding'              =&gt; 'UTF-8'
          )
  
  );
  
  
  $AuthorizeTransactionResponse  = $braspag-&gt;AuthorizeTransaction($parameters);
  
  print_r($AuthorizeTransactionResponse);
  
  echo $AuthorizeTransactionResponse-&gt;AuthorizeTransactionResponse;
  
  } 
  
  catch(SoapFault $fault) {
  
  echo 'Ocorreu um erro: ' , $fault-&gt;getMessage();
  
  }
  
  echo "&lt;hr&gt;";
  print_r($parameters);
  echo "&lt;hr&gt;";
  
  echo "&lt;pre&gt;";
  echo htmlspecialchars($braspag-&gt;__getLastRequestHeaders())."\n";
  echo htmlspecialchars($braspag-&gt;__getLastRequest())."\n";
  echo "Response:\n".htmlspecialchars($braspag-&gt;__getLastResponseHeaders())."\n";
  echo htmlspecialchars($braspag-&gt;__getLastResponse())."\n";
  echo "&lt;/pre&gt;"; 
  </code></pre>
  
  <p>Response:</p>
  
  <pre><code>&lt;soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"&gt;
     &lt;soap:Body&gt;
        &lt;AuthorizeTransactionResponse xmlns="https://www.pagador.com.br/webservice/pagador"&gt;
           &lt;AuthorizeTransactionResult&gt;
              &lt;CorrelationId&gt;xxxxxxxx&lt;/CorrelationId&gt;
              &lt;Success&gt;true&lt;/Success&gt;
              &lt;ErrorReportDataCollection/&gt;
              &lt;OrderData&gt;
                 &lt;OrderId&gt;Test0003&lt;/OrderId&gt;
                 &lt;BraspagOrderId&gt;74025d35-2bae-48cb-b84e-07e5a1df4a50&lt;/BraspagOrderId&gt;
              &lt;/OrderData&gt;
              &lt;PaymentDataCollection&gt;
                 &lt;PaymentDataResponse xsi:type="CreditCardDataResponse"&gt;
                    &lt;BraspagTransactionId&gt;40dd42b0-7d86-4c90-ac0c-266e454bc2fc&lt;/BraspagTransactionId&gt;
                    &lt;PaymentMethod&gt;997&lt;/PaymentMethod&gt;
                    &lt;Amount&gt;100&lt;/Amount&gt;
                    &lt;AcquirerTransactionId&gt;0118041611250&lt;/AcquirerTransactionId&gt;
                    &lt;AuthorizationCode&gt;20130118041611250&lt;/AuthorizationCode&gt;
                    &lt;ReturnCode&gt;6&lt;/ReturnCode&gt;
                    &lt;ReturnMessage&gt;Operation Successful&lt;/ReturnMessage&gt;
                    &lt;Status&gt;0&lt;/Status&gt;
                    &lt;CreditCardToken xsi:nil="true"/&gt;
                 &lt;/PaymentDataResponse&gt;
              &lt;/PaymentDataCollection&gt;
           &lt;/AuthorizeTransactionResult&gt;
        &lt;/AuthorizeTransactionResponse&gt;
     &lt;/soap:Body&gt;
  &lt;/soap:Envelope&gt;
  </code></pre>