在php中解析JBoss多部分消息

在php中解析JBoss多部分消息,php,web-services,jboss,Php,Web Services,Jboss,如何用PHP解析像这样的JBoss响应 ------=_Part_58_287452250.1366368388552 Content-Type: application/xop+xml; type="text/xml" Content-Transfer-Encoding: 8bit Content-ID: <rootpart@ws.jboss.org> <env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/enve

如何用PHP解析像这样的JBoss响应

------=_Part_58_287452250.1366368388552
Content-Type: application/xop+xml; type="text/xml"
Content-Transfer-Encoding: 8bit
Content-ID: <rootpart@ws.jboss.org>

<env:Envelope xmlns:env='http://schemas.xmlsoap.org/soap/envelope/'><env:Header></env:Header><env:Body><ns2:retrieveReportResponse xmlns:ns2="http://www.lince.it/WSCorporate_1/RetrieveReportService"><report><companyData><companyIdentification xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><reportInfo><deliveryDate>2013-04-19T00:00:00+02:00</deliveryDate><reference xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><reportInfo>87080394</reportInfo><deliveryCode>39415434</deliveryCode><originalRequestCode xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/></reportInfo><companyEvaluation xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><structuralData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><shareholdersData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><financialData xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><financialForecast xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><protests xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><closingDown xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/><companyName xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:nil="true"/></companyData><document><xop:Include xmlns:xop="http://www.w3.org/2004/08/xop/include" href="cid:document-8b0d480d-7006-4657-87ee-6523e0526b60@ws.jboss.org"/></document></report></ns2:retrieveReportResponse></env:Body></env:Envelope>
------=_Part_58_287452250.1366368388552
Content-Type: text/xml
Content-Transfer-Encoding: binary
Content-Id: <document-8b0d480d-7006-4657-87ee-6523e0526b60@ws.jboss.org>

<?xml version="1.0" encoding="ISO-8859-15"?>
<BasicAbbrevia><Metadata><Service><Type>CARTESIO</Type><Name>BASIC-ABBREVIA</Name></Service><Document><Id>15033</Id><Line>DOS</Line><Code>CVBA</Code><Name>CARTESIO:BASIC-ABBREVIA</Name><Title>BASIC ABBREVIA</Title><Description>Cerved Group Basic Abbrevia</Description></Document><Subject><IdCervedGroup>5913284</IdCervedGroup><Id>30128510</Id></Subject><Request><Id>87080394</Id><Subject>5913284</Subject><User>WPIT00</User><Time>19/04/2013 00:00:00</Time><Client><Type>WCRV</Type></Client><Output><Target>CERVED</Target><Version>1</Version><Format>XML</Format><Language>I</Language></Output></Request><Response><Stats><ServiceStartTime>19/04/2013 12:46:22.092</ServiceStartTime><ServiceResponseTime>19/04/2013 12:46:26.253</ServiceResponseTime><EnrichmentProcessingElapsed>00:00:01.467</EnrichmentProcessingElapsed><SectionProcessingElapsed>00:00:01.362</SectionProcessingElapsed><TotalElapsed>00:00:04.161</TotalElapsed><Actions count="2"><Action elapsed="00:00:01.346" name="DATI-CAMERALI:DATI-IDENTIFICATIVI" start="19/04/2013 12:46:24.898"/><Action elapsed="00:00:01.321" name="DATI-CAMERALI:CARICHE-E-QUALIFICHE" start="19/04/2013 12:46:24.903"/></Actions></Stats></Response></Metadata><CompanyIdentificationSection><TaxCode>02243110984</TaxCode><REAProvinceCode description="BRESCIA">BS</REAProvinceCode><REANumber>433793</REANumber><CompanyName>QUORUM S.R.L.</CompanyName><RHOAddress><ProvinceCode description="BRESCIA">BS</ProvinceCode><ISTATMunicipalityCode description="BRESCIA">BS029</ISTATMunicipalityCode><City>BRESCIA</City><ToponymCode description="VIALE">VLE</ToponymCode><StreetName>S. EUFEMIA</StreetName><StreetNo>216</StreetNo><PostCode>25135</PostCode></RHOAddress><RHOSlimActivityList><SlimBusinessActivity><Code description="Produzione di software non connesso all'edizione">62.01</Code><Coding>07</Coding></SlimBusinessActivity><SlimBusinessActivity><Code description="REALIZZAZIONE DI SOFTWARE; CONSULENZA SOFTWARE">72.2</Code><Coding>02</Coding></SlimBusinessActivity></RHOSlimActivityList><CertifiedEmail>ADALESISTEMISRL@LEGALMAIL.IT</CertifiedEmail></CompanyIdentificationSection><RepresentativesSection><RepresentativeList><Representative no="3"><TaxCode>02023060391</TaxCode><CompanyEquivalent><REAProvinceCode description="BOLOGNA">BO</REAProvinceCode><REANo>430474</REANo><CompanyName>ADALE SISTEMI S.R.L.</CompanyName><Address><ProvinceCode description="BOLOGNA">BO</ProvinceCode><City>BOLOGNA</City><ToponymCode description="VIA">VIA</ToponymCode><StreetName>CAIROLI</StreetName><StreetNo>8/F</StreetNo><PostCode>40121</PostCode></Address></CompanyEquivalent><OfficesAndAuthorityList><OfficesAndAuthority no="0"><OfficeHeldList><Office no="1"><Code description="SOCIO UNICO">SOU</Code><StartDate><Year>2003</Year><Month>7</Month><Day>29</Day><Value>29/07/2003</Value></StartDate><StartDateType>A</StartDateType></Office></OfficeHeldList></OfficesAndAuthority></OfficesAndAuthorityList></Representative><Representative no="7"><TaxCode>BRNSMN79C03C573X</TaxCode><Individual><LastName>BRANDINELLI</LastName><FirstName>SIMONE</FirstName><Sex>M</Sex><Birth><BirthplaceProvinceCode description="FORLI' - CESENA">FO</BirthplaceProvinceCode><ISTATMunicipalityCode description="CESENA"/><City>CESENA</City><BirthLabelGenere>M</BirthLabelGenere><BirthDate><Year>1979</Year><Month>3</Month><Day>3</Day><Value>03/03/1979</Value></BirthDate></Birth><TaxDomicile><ProvinceCode description="FORLI' - CESENA">FO</ProvinceCode><ISTATMunicipalityCode description="CESENA">FO007</ISTATMunicipalityCode><City>CESENA</City><ToponymCode description="VIA">VIA</ToponymCode><StreetName>C. LUGARESI</StreetName><StreetNo>8</StreetNo><PostCode>47023</PostCode></TaxDomicile><CompanyRepresentative>S</CompanyRepresentative></Individual><OfficesAndAuthorityList><OfficesAndAuthority no="0"><OfficeHeldList><Office no="1"><Code description="AMMINISTRATORE UNICO">AUN</Code><StartDateType>B</StartDateType><AppointmentDeedDate><Year>2012</Year><Month>5</Month><Day>10</Day><Value>10/05/2012</Value></AppointmentDeedDate><DurationCode description="FINO APPROVAZIONE DEL BILANCIO">AB</DurationCode><OfficeAcceptedDate><Year>2012</Year><Month>6</Month><Day>6</Day><Value>06/06/2012</Value></OfficeAcceptedDate><ReferenceDateCompanyReport><Year>2012</Year><Month>12</Month><Day>31</Day><Value>31/12/2012</Value></ReferenceDateCompanyReport><OfficeRegistrationDate><Year>2009</Year><Month>12</Month><Day>17</Day><Value>17/12/2009</Value></OfficeRegistrationDate></Office></OfficeHeldList></OfficesAndAuthority></OfficesAndAuthorityList></Representative></RepresentativeList></RepresentativesSection></BasicAbbrevia>
------=_Part_58_287452250.1366368388552--

是的,这是我手工制作的解决方案

将消息放入变量
$content
并使用以下代码:

preg_match('/\\-+=.*/', $content,$separator);
$separator = trim($separator[0]);
$parts = explode($separator,$content);
array_walk($parts, function(&$part) {
   $part = preg_replace("/.*[\r\n]{2}/ms", '', $part);
   if (trim($part)=='') $part = null;
   if (preg_match("/^[\-]+$/",trim($part))) $part = null;
});
$parts = array_values(array_filter($parts));

$parts
现在是一个数组,包含消息不同部分的内容。

SOAP是SOAP,无论使用什么客户端/服务器软件进行处理。PHP有soap支持库,只有googleforityes,soap就是soap,PHP有一个高效的类支持公共特性。实际上,Java JBoss和Microsoft.NET添加了一些未在基本php类中实现的函数(如.mime附件)