我目前正在与Kashflow集成,并使用SOAP调用将客户数据从我的Symfony2站点发送到我的Kashflow帐户,它应该返回新客户的ID-我需要这个来将其保存在我端的数据库中。
然而,在返回时,我得到了HTTP头,而不仅仅是ID,这意味着它不会将其插入数据库,因为它需要是一个整数。
以下是SOAP响应:
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: length
<?xml version="1.0" encoding="utf-8"?>
<soap12:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope">
<soap12:Body>
<InsertCustomerResponse xmlns="KashFlow">
<InsertCustomerResult>int</InsertCustomerResult>
<Status>string</Status>
<StatusDetail>string</StatusDetail>
</InsertCustomerResponse>
</soap12:Body>
</soap12:Envelope>
我正在尝试使用检索新ID
return new Response((int)$response->soapBody->InsertCustomerResponse->InsertCustomerResult);
但是,即使ID被返回,它也会吐出上面的HTTP头。有什么方法可以删除它吗?我尝试过这样使用preg_replace($return是SOAP调用的响应):
preg_replace('/((.*)'n)*('d+)$/','$1',$return);
但它只是返回一个空白。
有什么想法吗?
提前感谢
我意识到我必须在返回时使用getContent()才能获得所需的数据。
因此:
$response = $response->soapBody->InsertCustomerResponse->InsertCustomerResult;
return $response->getContent();
然后它只得到我需要的数据,而不是标题。