1

I have response from WSDL Service in XML format with headers (service was done bad but I don't have any influence on that). Response looks like that:

  --uuid:5ef54ff9-16d1-4675-823a-f692be71a142+id=295
  Content-ID: <http://tempuri.org/0>M
  Content-Transfer-Encoding: 8bitM
  Content-Type: application/xop+xml;charset=utf-8;type="application/soap+xml"

  <s:Envelope xmlns:s="http://www.w3.org/2003/05/soap-envelope" xmlns:a="http://www.w3.org/2005/08/addressing"><s:Header><a:Action s:mustUnderstand="1">http://CIS/BIR/PUBL/2014/07/IUslugaBIRzewnPubl/ZalogujResponse</a:Action></s:Header><s:Body><ZalogujResponse xmlns="http://CIS/BIR/PUBL/2014/07"><ZalogujResult>s4e4c8u5h4s7s4y6z6p6</ZalogujResult></ZalogujResponse></s:Body></s:Envelope>
  --uuid:5ef54ff9-16d1-4675-823a-f692be71a142+id=295--

Now i need to get only XML string from that response. I know that i can explode and get it from array or just parse after 2nd apperance of "<" but I want to do it more global... Because that way if they will add any header or remove it my scripts would stop working so it's dangerous solution. Is there a better way to do it ? I have Symfony2 Application (PHP).

Michal Olszowski
  • 795
  • 1
  • 8
  • 25

1 Answers1

0

Till now I have found only the following solution to fix MTOM used with XOP:

    $response = 'YOUR XML STRING....'; //WSDL Response (with CURL or SOAP)

    //if resposnse content type is mtom strip away everything but the xml.
    if( strpos($response, "Content-Type: application/xop+xml") !== false){
        $tempstr = stristr($response, "<s:Envelope");
        $response = substr($tempstr, 0, strpos($tempstr, "</s:Envelope>")) . "</s:Envelope>";
    }
    return $response;
Reza Mamun
  • 5,991
  • 1
  • 43
  • 42