发送针对transun响应的XML请求(显示订阅者号码无效)

时间:2016-08-27 10:46:07

标签: php xml curl soap xmlhttprequest

我正在使用Transunion XMLAPI,我得到了响应NVALID SUBSCRIBER CODE.我对Transunion支持部门的反应持续了好几周。

你可以帮我解决一下这个问题吗?

控制器代码

    $req = file_get_contents("xmlsample5.xml");

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, "https://secure.transunion.co.za/TUBureau118test/Consumer.asmx");
    curl_setopt($ch, CURLOPT_POST, 1);  //        POST /TUBureau118test/Consumer.asmx HTTP/1.1
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: secure.transunion.co.za'));//Host: secure.transunion.co.za
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/soap+xml; charset=utf-8', 'Content-Length: ' . strlen($req)));//Content-Type: application/soap+xml; charset=utf-8  //Content-Length: length
    curl_setopt($ch, CURLOPT_POSTFIELDS, $req);
   $response = curl_exec($ch);
    if (!($res = curl_exec($ch))) {
        curl_close($ch);
        exit;
    }
    curl_close($ch);

xmlsample5.xml代码

    <?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
             xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
    <ProcessRequestTrans41 xmlns="https://secure.transunion.co.za/TUBureau">
        <BureauEnquiry41>
            <EnquirerContactName></EnquirerContactName>
            <EnquirerContactPhoneNo></EnquirerContactPhoneNo>
            <EnquiryAmount></EnquiryAmount>
            <EnquiryType>TBA</EnquiryType>
            <Surname>MARY-JANE</Surname>
            <Forename1>MARY</Forename1>
            <Forename2></Forename2>
            <Forename3></Forename3>
            <MaidenName></MaidenName>
            <BirthDate>02011992</BirthDate>
            <IdentityNo1>srting</IdentityNo1>
            <IdentityNo2>srting</IdentityNo2>
            <Sex>M</Sex>
            <Title></Title>
            <MaritalStatus></MaritalStatus>
            <NoOfDependants></NoOfDependants>
            <AddressLine1>string</AddressLine1>
            <AddressLine2></AddressLine2>
            <Suburb>PARKTOWN</Suburb>
            <City>JOHANNESBURG</City>
            <PostalCode>2000</PostalCode>
            <ProvinceCode></ProvinceCode>
            <Address1Period></Address1Period>
            <OwnerTenant></OwnerTenant>
            <HomeTelCode>+270831234567</HomeTelCode>
            <HomeTelNo>+270831234567</HomeTelNo>
            <WorkTelCode>+270831234567</WorkTelCode>
            <WorkTelNo>+270831234567</WorkTelNo>
            <SpouseForename1></SpouseForename1>
            <SpouseForename2></SpouseForename2>
            <Address2Line1>TRANSUNION HOUSE</Address2Line1>
            <Address2Line2>8 JUNCTION AV</Address2Line2>
            <Address2Suburb>PARKTOWN</Address2Suburb>
            <Address2City>City  JOHANNESBURG</Address2City>
            <Address2PostalCode>200</Address2PostalCode>
            <Address2ProvinceCode></Address2ProvinceCode>
            <Address2Period></Address2Period>
            <Occupation></Occupation>
            <Employer></Employer>
            <EmploymentPeriod></EmploymentPeriod>
            <Salary></Salary>
            <BankName></BankName>
            <BankBranch></BankBranch>
            <BankBranchCode></BankBranchCode>
            <BankAccountNumber></BankAccountNumber>
            <OperatorIdentity></OperatorIdentity>
            <CellNo></CellNo>
            <EmailAddress></EmailAddress>
        </BureauEnquiry41>
        <Destination>Test</Destination>
    </ProcessRequestTrans41>
</soap12:Body>

Transunion对代码的回复

"<?xml version="1.0" encoding="utf-8"?><soap:Envelope xmlns:soap="http://www.w3.org/2003/05/soap-envelope" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"><soap:Body><ProcessRequestTrans41Response xmlns="https://secure.transunion.co.za/TUBureau"><ProcessRequestTrans41Result><RawData /><ResponseStatus>Failure</ResponseStatus><ErrorCode>R0017</ErrorCode><ErrorMessage>INVALID SUBSCRIBER NUMBER. THE SUBSCRIBER NUMBER SENT TO TRANSUNION IS INVALID. RESUBMIT WITH A VALID SUBSCRIBER NUMBER  </ErrorMessage><ProcessingStartDate>2016-08-27T12:25:21.2845072+02:00</ProcessingStartDate><ProcessingTimeSecs>0.031200199999999997</ProcessingTimeSecs><UniqueRefGuid>f743291b-2598-467a-accc-c7608355399c</UniqueRefGuid></ProcessRequestTrans41Result></ProcessRequestTrans41Response></soap:Body></soap:Envelope>"

然后我也尝试在信封之后和正文之前在xml文件中添加标题。使用从Transunion获得的订户ID到订阅者代码&#39;标题中的参数。

.....<soap12:Header>
    <xsi:element minOccurs="1" maxOccurs="1" name="ValidationError" type="xsi:boolean"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="ErrorMessage" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="TransactionVersion" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="SystemID" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="TransactionType" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="ClientRequestID" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="SubscriberCode" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="ClientReference" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="BranchNumber" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="BatchNumber" type="xsi:string"></xsi:element>
    <xsi:element minOccurs="0" maxOccurs="1" name="SecurityCode" type="xsi:string"></xsi:element>
</soap12:Header>
<soap12:body>.....

仍然得到相同的回应。

PS:我是xml请求的新手。请指导我正确的方向。

1 个答案:

答案 0 :(得分:0)

根据WSDL,BureauEnquiry41扩展了BureauEnquiry,其中包含其他字段,其中一个是SubscriberCode - 而且您的XML请求中缺少该字段。

尝试将其添加到您的XML:

<SubscriberCode>YOUR SUBSCRIBER NUMBER</SubscriberCode>
<EnquirerContactName></EnquirerContactName>
<EnquirerContactPhoneNo></EnquirerContactPhoneNo>
<EnquiryAmount></EnquiryAmount>
<EnquiryType>TBA</EnquiryType>
.
.
.