简体   繁体   English

卷曲解析文本不是xml

[英]Curl is parsing text not xml

I am trying to get rate quotes back from a freight carrier. 我正在尝试从货运公司索取报价。 I am getting the info parsed back to me but in the form of raw data not xml. 我正在将信息解析回给我,但是是以原始数据而不是xml的形式。 I need it in XML so I can parse just once element of the response. 我需要XML格式的文件,因此可以只解析一次响应。 Here is the code i am using: 这是我正在使用的代码:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

require_once('Curler.php');

use grafhax\Curler;

$soap = file_get_contents('request.xml');
//print_r($soap);exit;

$user= '******';
$pass= '*******';

$curl = new Curler();
$curl->fail_on_error = 0;
$curl->debug=true;
$curl->SetHeader('Content-Type', 'text/xml;charset="utf-8"');

//$curl->PostData('https://webservices.averittexpress.com/LTLRateQuoteService', $soap, false, true,        false, '', "$user:$pass");
//var_dump($curl->response);

//exit;

//$curl->PostData('https://webservices.averittexpress.com/LTLRateQuoteService', $soap, $this-  >lastUrl, true, false, '', "$user:$pass");
$curl->PostData('https://webservices.averittexpress.com/LTLRateQuoteService', $soap);

var_dump($curl->response);

Which gives me a response of: 这给了我以下回应:

Library: Curler set header variable: Content-Type=>"text/xml;charset="utf-8"" Library: Curler post request: " https://webservices.averittexpress.com/LTLRateQuoteService " string(3419) "HTTP/1.1 100 Continue HTTP/1.1 200 OK Date: Mon, 17 Nov 2014 16:30:47 GMT X-Powered-By: Servlet/3.0 Content-Length: 3107 Content-Type: text/xml; charset=utf-8 Content-Language: en-US Set-Cookie: BIGipServerPoolC=84279562.20480.0000; path=/ X-PvInfo: [S10413.C0.A0.R0.G0].[OT/plaintext.OG/documents] 07816643490520RANDLEMANNC27317GREENSBORO SERVICE CENTERMiamiFL33101MIAMI SERVICE CENTER11/17/20142Class 6050037.48 Rated As Class 50.0$187.40[None]0[None]0[None]0[None]0[None]0[None]0[None]0[None]0[None]0[None]0[None]0$125.5667.0900CZARLITE $0.00$17.0757.50$78.91$187.40$187.40500Mon Nov 17 10:30:50 CST 2014" 库:Curler设置标头变量:Content-Type =>“ text / xml; charset =” utf-8“”库:Curler发布请求:“ https://webservices.averittexpress.com/LTLRateQuoteService ” string(3419)“ HTTP /1.1 100继续HTTP / 1.1 200 OK日期:2014年11月17日,星期一GMT X-Powered-By:Servlet / 3.0内容长度:3107内容类型:text / xml; charset = utf-8内容-语言:英文Set-Cookie:BIGipServerPoolC = 84279562.20480.0000; path = / X-PvInfo:[S10413.C0.A0.R0.G0]。[OT / plaintext.OG / documents] 07816643490520RANDLEMANNC27317GREENSBORO服务中心MiamiFL33101MIAMI服务17 / 20142Class 6050037.48额定为50.0类$ 187.40 [None] 0 [None] 0 [None] 0 [None] 0 [None] 0 [None] 0 [None] 0 [None] 0 [None] 0 [None] 0 [无] 0 $ 125.5667.0900CZARLITE $ 0.00 $ 17.0757.50 $ 78.91 $ 187.40 $ 187.40500Mon Nov 17 10:30:50 CST 2014“

You have left out the most important part of your code... 您遗漏了代码中最重要的部分...

require_once('Curler.php');

^ That included file, which has the class you use later on: ^包含的文件,具有您稍后使用的类:

$curl = new Curler();

^ Which has all the relevant information about how the cURL script is programmed and run. ^其中包含有关cURL脚本如何编程和运行的所有相关信息。

A lot of the response here is clearly with the opt CURLOPT_HEADER set to true, which is fine for debug, but not really something you are actually interested in. 显然,这里的很多响应都是将opt CURLOPT_HEADER设置为true,这对于调试很合适,但实际上并不是您真正感兴趣的东西。

I actually did a google search for your 'Curler.php', and I found this . 我实际上在Google上搜索了您的“ Curler.php”,并且发现了这个 It just so happens that the function you're using is forcing the header to be returned, so I was correct in this assumption. 碰巧您正在使用的函数会强制返回标头,因此在这种假设下我是正确的。

I also did some google searching for Axis2 web server, because that's what the server you linked to said. 我也做了一些谷歌搜索Axis2 Web服务器,因为这就是您链接到的服务器。 It would seem they are offering various "objects/functions/methods" you can call on, like 似乎他们提供了您可以调用的各种“对象/函数/方法”,例如

https://webservices.averittexpress.com/LTLRateQuoteService.HTTPEndpoint/getCustomerContact

^ I don't know if that command is valid, but you probably need to use the correct function/link. ^我不知道该命令是否有效,但是您可能需要使用正确的功能/链接。 If you are using the correct function, then you may need to parse the data yourself. 如果使用正确的功能,则可能需要自己解析数据。 It is very hard for me to guess how the server is programmed. 我很难猜测服务器的编程方式。 You will have to contact those who set it up or look at their code or api/documentation etc. 您将必须与设置它​​的人联系,或者查看他们的代码或api /文档等。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM