r/PHPhelp • • Feb 03 '26

Solved SOAP Response Object Tree from XML String

In a project we have a SOAP Service with about 500 generated Classes that are described in a WSDL. We are using WsdlToPhp for generating the PHP services, enums and structs. Everything is working fine so far.

We are storing the SOAP response - the raw XML - in a database. From time to time we need the information from the SOAP response. Which brings me to my question:

Is it possible to get the PHP object tree instantiated by an XML string (from the database) and not from a SOAP service call?

P.S. And with possible I mean something that is not too hacky.

3 Upvotes

17 comments sorted by

View all comments

Show parent comment

1

u/thmsbrss Feb 03 '26 edited Feb 03 '26

" ...back to objects..." by manually mapping 300 objects or so?

The SOAP service will not change for the next 25 years I assume. Its a financial government thing.

1

u/bahaki Feb 03 '26

Sorry, maybe I misunderstood. Is wsdltophp generating your classes? If that's the case, then you should be able to deserialize the DB data (json or XML - writing out schemas for that many classes does seem like overkill) to the same classes you're working with on the soap side.

1

u/thmsbrss Feb 03 '26

Yes, exactly.

And simply serializing and writing to DB and reading from DB and unserializing is the answer.