Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2009-06-28
4
Medium Priority
?
3,007 Views
Last Modified: 2013-11-18
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
Comment
Question by:Michal-Drozd
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 25

Expert Comment

by:apeter
ID: 24734884
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
 
LVL 3

Author Comment

by:Michal-Drozd
ID: 24735265
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
 
LVL 25

Expert Comment

by:apeter
ID: 24735359
0
 
LVL 3

Accepted Solution

by:
Michal-Drozd earned 0 total points
ID: 24736742
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

Basic Security of Your VPC

So, you’ve got this shiny new VPC and a fancy new application configured on your EC2 servers ready to go. This application is only accessible from your computer, which is great for security, but you need your users to be able to access it! So, what’s the easiest way to do this?

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When it comes to write a Context Sensitive Help (an online help that is obtained from a specific point in state of software to provide help with that state) ,  first we need to make the file that contains all topics, which are given exclusive IDs. …
Q&A with Course Creator, Mark Lassoff, on the importance of HTML5 in the career of a modern-day developer.
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

688 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question