2017-12-22 3 views
0

Ich habe vor kurzem einen PHP-Webservice mit PHP native Soap erstellt. Ich habe die wsdl, xsd und den PHP-Code erstellt, um die Antwort zu konstruieren.php native, ignoriert Namespace in soapvar

In meiner soapvar, wenn ich das soap ArrayObject mit dem Namespace-Präfix erstellen, haben einige Knoten es und einige nicht. Was ich will, ist, dass alle Knoten das Präfix "ns1:" oder keine von ihnen haben.

Um das Problem zu beheben, entfernte ich den Namespace von soapvar. Also das hat die ns Präfix entfernt Aber ich habe immer die Nachricht von meinem wsdl "retrieveDataResponse" Knoten mit "ns1:" Präfix und und den Rest ich ohne gebaut. In meinem PHP habe ich foreach Lauf in jedem Knoten verschachtelt und Kinder hinzufügen "XSD_STRING" oder "SOAP_ENC_OBJECT" abhängig von der enc_type.

Mein SoapVar in PHP in der foreach ist:

$dataStruct[] = new SoapVar($ListOfDataStruct, SOAP_ENC_OBJECT, null, null, 'ListOfData', 'http://localhost/soap/retrieveCstData'); 

Meine XML-Antwort ist

<?xml version="1.0" encoding="UTF-8"?> 
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://localhost/soap/retrieveCstData"> 
    <SOAP-ENV:Body> 
     <ns1:retrieveDataResponse> 
     <ns1:cstData> 
      <ns1:Description>Discription N/A</ns1:Description> 
      <ns1:ListOfData> 
       <ns1:Customer-Data-Header> 
        <ns1:AssetDescription>Basic 12 Months</ns1:AssetDescription> 
        <ns1:AssetId>1-3QGMHQ9</ns1:AssetId> 
        <ns1:ProductDescription>Basic 12 Months</ns1:ProductDescription> 
        <ns1:ProductId>1-2E543A</ns1:ProductId> 
        <ns1:ProductName>Basic Product Subscription</ns1:ProductName> 
        <ns1:ListOfCstData-Asset> 
        <ns1:CstData-Asset> 
         <AssetIntegrationId>1-3Q3KSNI</AssetIntegrationId> 
         <ProductName>Basic Product Subscription</ProductName> 
         <ProductPartNumber>SAT0028</ProductPartNumber> 
         <StartDate>08/19/2015 21:00:00</StartDate> 
         <Status>Active</Status> 
         <ListOfProductXA/> 
         <ListOfAddress/> 
         <ListOfContact/> 
        </ns1:CstData-Asset> 
        </ns1:ListOfCstData-Asset> 
       </ns1:Customer-Data-Header> 
       <ns1:Customer-Data-Header> 
        <ns1:AssetId>1-7MRO-241</ns1:AssetId> 
        <ns1:ProductDescription>SubProduct A</ns1:ProductDescription> 
        <ns1:ProductId>1-65TVM</ns1:ProductId> 
        <ns1:ProductName>SubProduct A Type</ns1:ProductName> 
        <ns1:ProductType>Product</ns1:ProductType> 
        <ns1:ListOfCstData-Asset> 
        <ns1:CstData-Asset> 
         <AssetIntegrationId>1-5T126KG</AssetIntegrationId> 
         <ProductName>Asset-Product 1</ProductName> 
         <ProductPartNumber>N/A</ProductPartNumber> 
         <StartDate>08/16/2016 21:00:00</StartDate> 
         <Status>Active</Status> 
         <ListOfProductXA/> 
         <ListOfAddress/> 
         <ListOfContact/> 
        </ns1:CstData-Asset> 
        <ns1:CstData-Asset> 
         <AssetIntegrationId>W-C5PLG-11H-1</AssetIntegrationId> 
         <ProductName>SubProduct A Type</ProductName> 
         <ProductPartNumber>Data Packets</ProductPartNumber> 
         <RegisteredDate>02/21/1978</RegisteredDate> 
         <ServiceID>#56487%</ServiceID> 
         <StartDate>02/21/1978 00:00:00</StartDate> 
         <ListOfProductXA/> 
         <ListOfAddress> 
          <CutAddress> 
           <AddressType>Installation</AddressType> 
           <TEK>1651</TEK> 
           <Type>Old</Type> 
           <Country>US</Country> 
           <StreetNumberFrom>37</StreetNumberFrom> 
           <PostalCode>66857</PostalCode> 
           <State>CA</State> 
           <StreetName> 
           <State>JAX Avenue</State> 
           </StreetName> 
          </CutAddress> 
         </ListOfAddress> 
         <ListOfContact> 
          <Contact> 
           <ActiveStatus>Y</ActiveStatus> 
           <IsPrimaryMVG>Y</IsPrimaryMVG> 
           <CellularPhone>555687676</CellularPhone> 
           <FirstName>Jhon</FirstName> 
           <LastName>Doe</LastName> 
           <PrefferedCommunicationMethod>SMS</PrefferedCommunicationMethod> 
           <ContactType>Technical</ContactType> 
          </Contact> 
         </ListOfContact> 
        </ns1:CstData-Asset> 
        </ns1:ListOfCstData-Asset> 
       </ns1:Customer-Data-Header> 
       <ns1:Customer-Data-Header> 
        <ns1:AssetDescription>Satelite 80CM</ns1:AssetDescription> 
        <ns1:AssetId>1-3QGMHX9</ns1:AssetId> 
        <ns1:ProductDescription>Satelite 80CM</ns1:ProductDescription> 
        <ns1:ProductId>1-2DIYLT</ns1:ProductId> 
        <ns1:ProductName>TV SAT</ns1:ProductName> 
        <ns1:ProductType>Product</ns1:ProductType> 
        <ns1:ListOfCstData-Asset> 
        <ns1:CstData-Asset> 
         <SubscriberId>664668941</SubscriberId> 
         <Comments>Suspension/Reactivation</Comments> 
         <AssetIntegrationId>1-3Q3KSNJ</AssetIntegrationId> 
         <ProductName>TV SAT</ProductName> 
         <ProductPartNumber>TV_SAT</ProductPartNumber> 
         <ServiceID>9995654321587</ServiceID> 
         <StartDate>08/19/2015 21:00:00</StartDate> 
         <Status>Active</Status> 
         <ListOfProductXA/> 
         <ListOfAddress> 
          <CutAddress> 
           <AddressType>Installation</AddressType> 
           <TEK>1651</TEK> 
           <Type>Old</Type> 
           <Area>CA</Area> 
           <Country>US</Country> 
           <StreetNumberFrom>37</StreetNumberFrom> 
           <ResidenceType>Business</ResidenceType> 
           <Floor>0</Floor> 
           <MailBox>US</MailBox> 
           <PostalCode>66857</PostalCode> 
           <State>CA</State> 
           <StreetName>JAX AVENUE</StreetName> 
           <District>DownTown</District> 
          </CutAddress> 
         </ListOfAddress> 
         <ListOfContact/> 
        </ns1:CstData-Asset> 
        </ns1:ListOfCstData-Asset> 
       </ns1:Customer-Data-Header> 
      </ns1:ListOfData> 
     </ns1:retrieveDataResponse> 
     </ns1:retrieveDataResponse> 
    </SOAP-ENV:Body> 
</SOAP-ENV:Envelope> 

So wie Sie Präfix ist in jedem Knoten nicht sehen kann.

Antwort

0

Nun, ich habe das Problem gefunden.

In einer der vielen foreach-Schleifen habe ich ein vorheriges deklariertes ArrayObject anstelle des Array-Schlüssels verwendet.

Also Seife gone nicht Namespace :)

+0

Könnten Sie dies als die Antwort dann markieren? – jjok

Verwandte Themen