为了账号安全,请及时绑定邮箱和手机立即绑定

如何通过 HTTP POST 将 XML 消息发送到测试 URL?

如何通过 HTTP POST 将 XML 消息发送到测试 URL?

PHP
白衣染霜花 2022-01-02 15:43:59
请注意,我是初学者,仍在学习 javascript 和后端概念。我有一个 HTML 表单,用于收集用户信息并在提交时通过验证并转换为 XML。我让它在控制台中作为对象的位置工作并输出以下代码,但是:我需要做的是通过 HTTP POST 将该 XML 发送到测试 URL 并获得响应。我的测试网址是https://plmdemo.infinityels.com/plm.net/lead/xml/Processor.ashx我不知道从哪里开始。该 URL 需要这样的 XML:<LeadRequest>    <Username>test</Username>    <Password>test</Password>    <FirstName>Bill</FirstName>    <LastName>Jones</LastName>    <SSN>sdf</SSN>    <Gender>F</Gender>    <Email>sdf@gmail.com</Email>    <DOB>2018-07-22</DOB>    <DriversLicense>sdf</DriversLicense>    <DriversLicenseState>sdf</DriversLicenseState>    <HomeAddress>sdf</HomeAddress>    <HomeCity>sdf</HomeCity>    <HomeState>AL</HomeState>    <HomeZip>sdf</HomeZip>    <TimeAtAddress>3</TimeAtAddress>    <HomePhone>123-456-7890</HomePhone>    <WorkPhone>123-456-7890</WorkPhone>    <CellPhone>123-456-7890</CellPhone>    <BankInfo>        <BankName>Citi</BankName>        <BankPhone>123-456-7890</BankPhone>        <AbaNumber>1</AbaNumber>        <CheckingAccount>2</CheckingAccount>        <SavingsAccount>2</SavingsAccount>        <AccountToUse>C</AccountToUse>        <AccountLength>2</AccountLength>    </BankInfo>    <EmploymentInfo>        <MonthlyIncome>12</MonthlyIncome>        <PayFrequency>1</PayFrequency>        <IncomeType>1</IncomeType>        <PayrollType>1</PayrollType>        <NextPayDay>2019-09-12</NextPayDay>        <SecondNextPayDay>2019-09-26</SecondNextPayDay>        <Employer>sdf</Employer>        <Occupation>sdf</Occupation>        <EmploymentLength>2</EmploymentLength>        <Phone>123-456-7890</Phone>    </EmploymentInfo>    <LoanInfo>        <Amount>300</Amount>        <DueDate>2019-10-18</DueDate>    </LoanInfo></LeadRequest>
查看完整描述

1 回答

?
慕桂英3389331

TA贡献2036条经验 获得超8个赞

我能够得到一些有用的错误消息。我编辑了 SSN,该错误消失了。


<?php


error_reporting(E_ALL);

ini_set('display_errors', true);


$xml = '<?xml version="1.0"?><LeadRequest><Username>test</Username><Password>test</Password><FirstName>Bill</FirstName><LastName>Jones</LastName><SSN>sdf</SSN><Gender>F</Gender><Email>sdf@gmail.com</Email><DOB>2018-07-22</DOB><DriversLicense>sdf</DriversLicense><DriversLicenseState>sdf</DriversLicenseState><HomeAddress>sdf</HomeAddress><HomeCity>sdf</HomeCity><HomeState>AL</HomeState><HomeZip>sdf</HomeZip><TimeAtAddress>3</TimeAtAddress><HomePhone>123-456-7890</HomePhone><WorkPhone>123-456-7890</WorkPhone><CellPhone>123-456-7890</CellPhone><BankInfo><BankName>Citi</BankName><BankPhone>123-456-7890</BankPhone><AbaNumber>1</AbaNumber><CheckingAccount>2</CheckingAccount><SavingsAccount>2</SavingsAccount><AccountToUse>C</AccountToUse><AccountLength>2</AccountLength></BankInfo><EmploymentInfo><MonthlyIncome>12</MonthlyIncome><PayFrequency>1</PayFrequency><IncomeType>1</IncomeType><PayrollType>1</PayrollType><NextPayDay>2019-09-12</NextPayDay><SecondNextPayDay>2019-09-26</SecondNextPayDay><Employer>sdf</Employer><Occupation>sdf</Occupation><EmploymentLength>2</EmploymentLength><Phone>123-456-7890</Phone></EmploymentInfo><LoanInfo><Amount>300</Amount><DueDate>2019-10-18</DueDate></LoanInfo></LeadRequest>';


$opts = array('http' =>

    array(

        'method'  => 'POST',

        'header'  => 'Content-Type: application/x-www-form-urlencoded',

        'content' => $xml

    )

);


$context  = stream_context_create($opts);


$result = file_get_contents('https://plmdemo.infinityels.com/plm.net/lead/xml/Processor.ashx', false, $context);


var_dump($result);


查看完整回答
反对 回复 2022-01-02
  • 1 回答
  • 0 关注
  • 138 浏览

添加回答

举报

0/150
提交
取消
意见反馈 帮助中心 APP下载
官方微信