PHP / SOAP / XML根元素之前的文档中的标记必须格式正确

时间:2013-02-07 22:47:56

标签: php xml soap

我正在尝试与支付网关(FirstData)进行交互。到目前为止,我已经创建了cURL请求,并最终使其工作。现在我到了能够生成SOAP包装的XML的地步。我收到一条错误消息:

输入SOAP请求格式不正确。异常是org.xml.sax.SAXParseException:根元素之前的文档中的标记必须格式正确。

这是我正在喂它的xml:

$this->xml = "<?xml version=\"1.0\"?>";
$this->xml = "<SOAP-ENV:Envelope xmlns:SOAP-ENV=\"http://schemas.xmlsoap.org/soap/envelope/\">";
$this->xml = "<SOAP-ENV:Header />";
$this->xml = "<SOAP-ENV:Body>";
$this->xml = "<fdggwsapi:FDGGWSApiOrderRequest xmlns:fdggwsapi=\“http://secure.linkpt.net/fdggwsapi/schemas_us/fdggwsapi\">";
$this->xml = "<v1:Transaction xmlns:v1=\"http://secure.linkpt.net/fdggwsapi/schemas_us/v1\">";
$this->xml = "<v1:CreditCardTxType>";
$this->xml = "<v1:Type>sale</v1:Type>";
$this->xml = "</v1:CreditCardTxType>";
$this->xml = "<v1:CreditCardData>";
$this->xml = "<v1:CardNumber>4012000033330026</v1:CardNumber>";
$this->xml = "<v1:ExpMonth>12</v1:ExpMonth>";
$this->xml = "<v1:ExpYear>12</v1:ExpYear>";
$this->xml = "</v1:CreditCardData>";
$this->xml = "<v1:Payment>";
$this->xml = "<v1:ChargeTotal>12</v1:ChargeTotal>";
$this->xml = "</v1:Payment>";
$this->xml = "</v1:Transaction>";
$this->xml = "</fdggwsapi:FDGGWSApiOrderRequest>";
$this->xml = "</SOAP-ENV:Body>";
$this->xml = "</SOAP-ENV:Envelope>";

return $this->xml;

我无法找到这方面的内容,并尝试了一切。以下是我通过cURL请求发送的标题:

$headers = array(
        "Content-type: text/xml;charset=\"utf-8\"", 
        "Accept: text/xml", 
        "Cache-Control: no-cache", 
        "Pragma: no-cache", 
        "SOAPAction: \"run\"", 
        "Content-length: ".strlen($this->genXML()),
        );

* genXML()包含带有上面列出的XML的XML消息

任何信息表示赞赏。

1 个答案:

答案 0 :(得分:2)

你的意思是$this->xml .= "..."?否则它每次只是覆盖字符串,对吗?