Take the 2-minute tour ×
Tridion Stack Exchange is a question and answer site for Tridion developers and administrators. It's 100% free, no registration required.

Is is possible to retrieve Tridion item XML though the core service client in Tridion?

In TOM.NET this would be Tridion.ContentManager.IdentifiableObject.ToXml().

I am not looking for the Core Service Client's Tridion.ContentManager.Data.ContentManagement.ComponentData.Content. This is useful indeed but only gives the XML representation of the component fields.

share|improve this question
    
Great question Jan. I also recently wanted to do the same thing but could not find the way to do it with one call. There is also the .Info class as part of the ComponentData, but I didn't see a method to put that info in the original XML. –  robrtc Apr 16 at 21:51
1  
Why would you want to do it? –  user978511 Apr 17 at 6:26
    
In this case I wanted to inspect a multimedia components namespace. As a multi media component does not have a XML content like a text component I thought having a look at the raw item xml might be helpful. –  Jan H Apr 17 at 12:30
    
FWIW - you might try this: $core.Read($core.Read("tcm:3-4371",$null).Schema.IdRef,$null).NamespaceURI –  Dominic Cronin Apr 17 at 16:46

2 Answers 2

If you really want the XML you can get it. Basically, the CoreService response is actually in XML, and the WCF client will serialize/deserialize from/to XML, and what you can do is tell WCF that you want the XML for a given object.

Like this. (originally posted here)

SessionAwareCoreServiceClient client = new SessionAwareCoreServiceClient("wsHttp_2011");
ReadOptions readOptions = new ReadOptions();
IdentifiableObjectData tridionObject = client.Read("tcm:0-12-1", readOptions);
DataContractSerializer dcs = new DataContractSerializer(tridionObject.GetType()); 
using (MemoryStream ms = new MemoryStream())
{
    dcs.WriteObject(ms, tridionObject);
    ms.Position = 0;
    XmlDocument document = new XmlDocument();
    document.Load(ms);
    Console.Write(document.OuterXml);
}

This will return R6 XML, it's not your father's R5 XML anymore, so you may have to play around with it for a while.

share|improve this answer
    
Cool, so on the soap request response level the core service uses R6 XML and its the core service client dll hiding that. R6 xml is fine, I never asked for R5 specifically. –  Jan H Apr 17 at 12:20
    
I think it's a level deeper than the CS client dll, it is a "native WCF" transformation. –  Nuno Linhares Apr 17 at 12:48

You haven't overlooked anything; there is no easy way to get the "R5 XML". There's a separate assembly used to create that XML for the CME, but even that is likely to be phased out in the upcoming releases. Managed objects are usually much easier to work with.

You can always serialize objects using the standard .NET serializers if you just want it in XML (or JSON) - for transportation purposes for example.

share|improve this answer
    
True, the thing is that Tridion doesn't store items in XML. It was used a lot in the old Business Connector days, but since then a lot of effort was spent to move away from it. –  user978511 Apr 17 at 8:38
    
For transportation, migration the xml would be easier to handle than serialized objects I think. Good to know that Tridion is moving away from it though. –  Jan H Apr 17 at 8:53
    
The information in question - i.e. the parts of a component other than the content, were not generally stored as XML even going back quite some versions. The "R5 XML" was generated dynamically. –  Dominic Cronin Apr 17 at 10:09

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.