duanqiongchong0354 2011-08-31 21:34
浏览 74
已采纳

UPS API使用cURL和PHP ...格式良好的XML问题

The UPS server keeps giving me this response :

HTTP/1.1 200 OK
Server: Apache
Content-Length: 429
X-Powered-By: Servlet/2.5 JSP/2.1
Content-Type: application/xml
Expires: Wed, 31 Aug 2011 21:28:12 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Wed, 31 Aug 2011 21:28:12 GMT
Connection: keep-alive

with this error:

<AddressValidationResponse>
   <Response>
      <TransactionReference>
         <XpciVersion>1.0001</XpciVersion>
      </TransactionReference>
      <ResponseStatusCode>0</ResponseStatusCode>
      <ResponseStatusDescription>Failure</ResponseStatusDescription>
      <Error>
         <ErrorSeverity>Hard</ErrorSeverity>
            <ErrorCode>10001</ErrorCode>
            <ErrorDescription>The XML document is not well formed</ErrorDescription>
      </Error>
   </Response>
</AddressValidationResponse>

Here is the PHP code I am sending to the server. Is there an error that I am missing and overlooking?

$data = '<?xml version=\"1.0\" ?>
                <AccessRequest xml:lang=\"en-US\">
                    <AccessLicenseNumber>$this->AccessLicenseNumber</AccessLicenseNumber>
                    <UserId>$this->UserId</UserId>
                    <Password>$this->Password</Password>
                </AccessRequest>
                <?xml version=\"1.0\" ?>
                <AddressValidationRequest xml:lang=\"en-US\">
                    <Request>
                        <TransactionReference>
                            <XpciVersion>1.0001</XpciVersion>
                        </TransactionReference> 
                        <RequestAction>XAV</RequestAction> 
                        <RequestOption>3</RequestOption>
                    </Request>
                    <AddressKeyFormat>
                        <AddressLine>$address</AddressLine>
                        <PoliticalDivision2>$city</PoliticalDivision2>
                        <PoliticalDivision1>$state</PoliticalDivision1>
                        <PostcodePrimaryLow>$zip</PostcodePrimaryLow>
                        <CountryCode>US</CountryCode>
                    </AddressKeyFormat>
                </AddressValidationRequest>';

Any help would be greatly appreciated. Thank you.

  • 写回答

1条回答 默认 最新

  • du3932066 2011-08-31 21:40
    关注

    You have to use " instead of ' to wrap your xml, like this:

    $data="<?xml...";
    

    PHP only replaces variables inside of "

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥30 自适应 LMS 算法实现 FIR 最佳维纳滤波器matlab方案
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c
  • ¥15 RPA正常跑,cmd输入cookies跑不出来
  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动