我正在尝试与支付网关(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消息
欢迎提供任何信息。
你是说$this->xml .= "..."
吗?否则每次都会覆盖字符串,对吧?