doulai8128
2015-12-01 12:46
浏览 34
已采纳

如何从SOAP响应中删除HTTP标头

I am currently integrating with Kashflow and using SOAP calls to send Customer data to my Kashflow account from my Symfony2 site, and it should return the ID of the new customer - I need this in order to save it in the database at my end.

However, upon return, I get the HTTP header and not just the ID, which means it is not inserting it into the database as it needs to be an integer.

Here is the SOAP response:

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>

I am trying to retrieve the new ID by using:

return new Response((int)$response->soapBody->InsertCustomerResponse->InsertCustomerResult);

But even though the ID does get returned, it spits out the HTTP header above it. Is there any way of removing this? I have tried using preg_replace like this (where $return is the response from the SOAP call):

preg_replace('/((.*)
)*(\d+)$/','$1',$return);

But it just returns a blank.

Any ideas?

Thanks in advance

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题