2

This is my code

String publicationName="WebSite";

PublicationData publicationData=(PublicationData)client.getDefaultData(ItemType.PUBLICATION,"tcm:0",new ReadOptions());

 publicationData.setTitle(publicationName);

publicationData.setPublicationUrl(publicationName);

 publicationData.setKey(publicationName);

publicationData.setPublicationType("Web");

 publicationData.setPublicationPath(publicationName);

 System.out.println("in publication");

publicationData=(PublicationData)client.create(publicationData,new ReadOptions());

when i am creating publication by this code i am getting an exception

Exception in thread "main" com.sdltridion.contentmanager.coreservice.ICoreServiceCreateCoreServiceFaultFaultFaultMessage: The transaction has aborted.

5
  • which version of Tridion are you using? Commented Mar 12, 2014 at 5:57
  • Sdl Tridion 2013 Commented Mar 12, 2014 at 6:10
  • Does it take a long time to save when creating through the GUI? Do you have hundreds or thousands of Publications? You can increase the core service timeout in the config binding of your app.
    – robrtc
    Commented Mar 12, 2014 at 6:17
  • Take a look at the event log on the server and there should be an event log with additional details and stack trace please share that.
    – Likhan
    Commented Mar 12, 2014 at 6:46
  • Yes it take a long time to save when creating through the GUI and i am getting same error on GUI also Commented Mar 12, 2014 at 8:37

2 Answers 2

1

you can try the code below, as you did not mention the version. this should work for 2011

       String publicationName="WebSite";

       PublicationData publicationData = new PublicationData() ;
       publicationData.Id = "tcm:0-0-0";
       publicationData.Title = publicationName;
       publicationData.PublicationUrl = publicationName;
       publicationData.Key = publicationName;

        publicationData.PublicationType = "Web";

        publicationData.PublicationPath = publicationName;

        publicationData = (PublicationData)tridionClient.Create(publicationData, new ReadOptions());
2
  • I think pankaj is using a Java client. This is a snippet for .NET.
    – Likhan
    Commented Mar 12, 2014 at 6:44
  • @Likhan : well, I have not consumed core service in java application ever. How it is different using in java? or you are talking about the syntex? Commented Mar 12, 2014 at 6:58
1

Set the publication ID property as well with tcm:0-0-0 and this should resolve the issue.

Add below line as well in your code before you call the create method:

publicationData.setPublicationID("tcm:0-0-0");

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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