Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3057
  • Last Modified:

How to save stdClass (result of SOAP function) to XML file?

I am trying to save result from SOAP function to XML file. I am calling SOAP function getProductListResult of web service http://public.ws.cz.elinkx.biz/service.asmx (description is available without logging).
I want save getProductListResult->ProductList to XML but it is stdClass and cant be converted to string and i got:
Catchable fatal error: Object of class stdClass could not be converted to string

I tried calling $data->getProductListResult->ProductList->any but didnt help (nor $data->getProductListResult->any)

thanks for help
$soap = new SoapClient(CONST_SOAP_EDSoapURL,
	array(  'style'    => SOAP_DOCUMENT,
                    'use'      => SOAP_LITERAL,
		    'trace' => true));
$data = $soap->getProductList(
	array(	'login' => CONST_SOAP_EDLogin,
			'password' => CONST_SOAP_EDPassword,  
			'onStock' => 'true')); //Products on store.	
$doc = new DOMDocument();
$doc->loadXML((string) $data->getProductListResult->ProductList);  // we get exception
$doc->save('_data/ceniky/cenikED.xml');

Open in new window

0
Michal-Drozd
Asked:
Michal-Drozd
  • 2
  • 2
1 Solution
 
apeterCommented:
You can serialize your object to xml from ur web service itself. See below link to see how to serialize
http://www.codeproject.com/KB/XML/xml_serializationasp.aspx
0
 
Michal-DrozdAuthor Commented:
thanks for comment, but i need some tip how serialize in PHP, becouse in C# it is not helpful for me

I need to know how do it in PHP and use it in my PHP site
0
 
apeterCommented:
0
 
Michal-DrozdAuthor Commented:
thanks, this url is about serializing objects in generally
I am searching for some class or function or another API to create XML from stdClass
There is PHP function get_object_vars($stdClass) to get members from stdClass and so its possible to create my own stdClass XML serializer, but it is what i didnt want to do

probably there is no general stdClass XML serializer so i will make my own
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now