1

Web サービスを利用するためにデータを送信しようとしています。しかし、それはエラーを返します:

エラー: サーバーはリクエストを読み取れませんでした。---> XML 文書にエラーがあります (2, 734)。---> 指定された型は抽象型です: name='PaymentDataRequest', namespace='https://www.pagador.com.br/webservice/pagador', at .

誰でも私を助けることができますか?ここに私のXML:

<?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>
    <AuthorizeTransaction xmlns="https://www.pagador.com.br/webservice/pagador">
      <request>
        <OrderData>
          <MerchantId>xxxxxxxxxxxxxxx</MerchantId>
          <OrderId>Test0003</OrderId>
          <BraspagOrderId xsi:nil="true" />
        </OrderData>
        <CustomerData>
          <CustomerIdentity>99999999999</CustomerIdentity>
          <CustomerName>Teste</CustomerName>
          <CustomerEmail>compradot@teste.com</CustomerEmail>
          <CustomerAddressData xsi:nil="true" />
          <DeliveryAddressData xsi:nil="true" />
        </CustomerData>
        <PaymentDataCollection>
          <PaymentDataRequest xsi:type="CreditCardDataRequest">
            <PaymentMethod>997</PaymentMethod>
            <Amount>100</Amount>
            <Currency>BRL</Currency>
            <Country>BRA</Country>
            <NumberOfPayments>1</NumberOfPayments>
            <PaymentPlan>0</PaymentPlan>
            <TransactionType>2</TransactionType>
            <CardHolder>Comprador Teste</CardHolder>
            <CardNumber>0000000000000001</CardNumber>
            <CardSecurityCode>111</CardSecurityCode>
            <CardExpirationDate>07/2017</CardExpirationDate>
            <AdditionalDataCollection xsi:nil="true" />
          </PaymentDataRequest>
        </PaymentDataCollection>
        <RequestId>80a51fb5-f9d7-44b8-bdc2-da2d533f3b8d</RequestId>
        <Version>1.0</Version>
      </request>
    </AuthorizeTransaction>
  </soap:Body>
</soap:Envelope>

コード:

$parameters             = new stdClass();
$parameters->request    = new StdClass();

$parameters->request->OrderData->MerchantId='xxxxxxxxxx';
$parameters->request->OrderData->OrderId='Test0004';
$parameters->request->CustomerData->CustomerIdentity='99999999999';
$parameters->request->CustomerData->CustomerName='Teste';
$parameters->request->CustomerData->CustomerEmail='compradot@teste.com';
$parameters->request->CustomerData->CustomerEmail='compradot@teste.com';
$parameters->request->PaymentDataCollection->PaymentDataRequest='997';
$parameters->request->PaymentDataCollection->PaymentDataRequest->Amount='100';
$parameters->request->PaymentDataCollection->PaymentDataRequest->Currency='BRL';
$parameters->request->PaymentDataCollection->PaymentDataRequest->Country='BRA';
$parameters->request->PaymentDataCollection->PaymentDataRequest->NumberOfPayments='1';
$parameters->request->PaymentDataCollection->PaymentDataRequest->PaymentPlan='0';
$parameters->request->PaymentDataCollection->PaymentDataRequest->TransactionType='2';
$parameters->request->PaymentDataCollection->PaymentDataRequest->CardHolder='Comprador Teste';
$parameters->request->PaymentDataCollection->PaymentDataRequest->CardNumber='0000000000000001';
$parameters->request->PaymentDataCollection->PaymentDataRequest->CardSecurityCode='111';
$parameters->request->PaymentDataCollection->PaymentDataRequest->CardExpirationDate='07/2017';
$parameters->request->RequestId='80a51fb5-f9d7-44b8-bdc2-da2d533f3b8d';                             
$parameters->request->Version='1.0';

try {

$braspag = new SoapClient( 'https://homologacao.pagador.com.br/webservice/pagadorTransaction.asmx?WSDL',

        array(
                'trace'                 => 1,
                'exceptions'            => 1,
                'style'                 => SOAP_DOCUMENT,
                'use'                   => SOAP_LITERAL,
                'soap_version'          => SOAP_1_1,
                'encoding'              => 'UTF-8'
        )

);


$AuthorizeTransactionResponse  = $braspag->AuthorizeTransaction($parameters);

print_r($AuthorizeTransactionResponse);

echo $AuthorizeTransactionResponse->AuthorizeTransactionResponse;

} 

catch(SoapFault $fault) {

echo 'Ocorreu um erro: ' , $fault->getMessage();

}

echo "<hr>";
print_r($parameters);
echo "<hr>";

echo "<pre>";
echo htmlspecialchars($braspag->__getLastRequestHeaders())."\n";
echo htmlspecialchars($braspag->__getLastRequest())."\n";
echo "Response:\n".htmlspecialchars($braspag->__getLastResponseHeaders())."\n";
echo htmlspecialchars($braspag->__getLastResponse())."\n";
echo "</pre>"; 

応答:

<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">
   <soap:Body>
      <AuthorizeTransactionResponse xmlns="https://www.pagador.com.br/webservice/pagador">
         <AuthorizeTransactionResult>
            <CorrelationId>xxxxxxxx</CorrelationId>
            <Success>true</Success>
            <ErrorReportDataCollection/>
            <OrderData>
               <OrderId>Test0003</OrderId>
               <BraspagOrderId>74025d35-2bae-48cb-b84e-07e5a1df4a50</BraspagOrderId>
            </OrderData>
            <PaymentDataCollection>
               <PaymentDataResponse xsi:type="CreditCardDataResponse">
                  <BraspagTransactionId>40dd42b0-7d86-4c90-ac0c-266e454bc2fc</BraspagTransactionId>
                  <PaymentMethod>997</PaymentMethod>
                  <Amount>100</Amount>
                  <AcquirerTransactionId>0118041611250</AcquirerTransactionId>
                  <AuthorizationCode>20130118041611250</AuthorizationCode>
                  <ReturnCode>6</ReturnCode>
                  <ReturnMessage>Operation Successful</ReturnMessage>
                  <Status>0</Status>
                  <CreditCardToken xsi:nil="true"/>
               </PaymentDataResponse>
            </PaymentDataCollection>
         </AuthorizeTransactionResult>
      </AuthorizeTransactionResponse>
   </soap:Body>
</soap:Envelope>
4

2 に答える 2

0

WSDLリンクから

PagadorWebService-WSDL

私はそれを集めることができるだけです:

  <s:complexType name="PaymentDataRequest" abstract="**true**">
    <s:sequence>
      <s:element minOccurs="1" maxOccurs="1" name="PaymentMethod" type="s:short"/>
      <s:element minOccurs="1" maxOccurs="1" name="Amount" type="s:long"/>
      <s:element minOccurs="0" maxOccurs="1" name="Currency" type="s:string"/>
      <s:element minOccurs="0" maxOccurs="1" name="Country" type="s:string"/>
      <s:element minOccurs="0" maxOccurs="1" name="AdditionalDataCollection" type="tns:ArrayOfAdditionalDataRequest"/>
    </s:sequence>

PaymentDataRequestは抽象です。PaymentDataRequestを拡張するCreditCardDataRequestが必要です。

于 2013-01-21T13:23:26.227 に答える