I am trying to publish a component using core services in Java but on running the code, I am getting this error :-

Exception in thread "main" com.sdltridion.contentmanager.coreservice.ICoreServicePublishCoreServiceFaultFaultFaultMessage: Value cannot be null. Parameter name: publishInstruction.ResolveInstruction.

Here's my code

         ReadOptions readOptions = new ReadOptions();

    ArrayOfstring componentsArray=new ArrayOfstring();

    ArrayOfstring publicationTarget=new ArrayOfstring();

    PublishInstructionData publishInstructionData = new PublishInstructionData();
    ResolveInstructionData resolveInstructionData = new ResolveInstructionData();

    JAXBElement<ResolvePurpose> resolvePurpose =    new JAXBElement<ResolvePurpose>(new QName("http://www.sdltridion.com/ContentManager/R6","Purpose"), ResolvePurpose.class, ResolvePurpose.PUBLISH);

    JAXBElement<ResolveInstructionData> jaxbElement =    new JAXBElement<ResolveInstructionData>(new QName("http://www.sdltridion.com/ContentManager/CoreService/2011","com.sdltridion.contentmanager.coreservice._2011.Publish"), ResolveInstructionData.class, resolveInstructionData);

     RenderInstructionData renderInstructionData = new RenderInstructionData();

      JAXBElement<RenderMode> renderMode =    new JAXBElement<RenderMode>(new QName("http://www.sdltridion.com/ContentManager/R6","RenderMode"), RenderMode.class, RenderMode.PUBLISH);

    JAXBElement<RenderInstructionData> renderInstruction =    new JAXBElement<RenderInstructionData>(new QName("http://www.sdltridion.com/ContentManager/CoreService/2011","com.sdltridion.contentmanager.coreservice._2011.Publish"), RenderInstructionData.class, renderInstructionData);


      ArrayOfPublishTransactionData ad= endpoint.publish(componentsArray, publishInstructionData, publicationTarget, PublishPriority.LOW, readOptions);

Looking at your implementation, publishinstructiondata has two main objects: ResolveInstructionData and RenderInstruction.

In your implementation, you have created object for ResolveInstructionData however you are missing RenderInstruction object. That could be reason the publishing is not working.

  • I have already tried adding the RenderInstruction but it did'nt work as I always get the same exception which I have pointed above. – Ankur Dec 16 '16 at 9:14
  • RenderInstructionData renderInstructionData = new RenderInstructionData(); @SuppressWarnings("unchecked") JAXBElement<RenderInstructionData> jaxbElement1 = new JAXBElement<RenderInstructionData>(new QName("sdltridion.com/ContentManager/CoreService/…), RenderInstructionData.class, renderInstructionData); publishInstructionData.setRenderInstruction(jaxbElement1); – Ankur Dec 16 '16 at 9:20
  • 1
    For ResolveInstructionData you also need to setPurpose, probably to ResolvePurpose.PUBLISH; and for the RenderInstructionData you need to set a RenderMode, again, probably to RenderMode.PUBLISH. You may also find yatb.mitza.net/2012/12/a-core-service-java-client.html useful if you want to unwrap the JAXB elements. – Dave Forber Dec 16 '16 at 21:40
  • Thanks for your answer Dave, but the recommendation by you doesn't seems to work. I have updated my code and still getting the same error as I have mentioned above. – Ankur Dec 19 '16 at 7:34

I think this is mainly a question on how to construct a proper SOAP request in general in Java (using JAXB?)

I recommend to enable WCF Tracing in the Core Service (there are comments in webservices/web.config on how to do that). This allows you to see the SOAP request sent to the Core Service to check what's in there and what's not.

  • Well I have already made many SOAP request using JAXB to get the data from the CMS using core-services. I want to know here, if there's something I am missing or the way of doing this is not correct ?? – Ankur Dec 16 '16 at 12:17
  • 1
    The answer to that question is most probably "yes", but I can't tell you what the issue is exactly. I just hope that the WCF Trace helps you analyzing the problem. – Rick Pannekoek Dec 16 '16 at 12:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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