2

I am creating a Schema using core Service Following is My code I am using java client

    SchemaData schemas=new SchemaData();

    SchemaFieldsData schemaFieldsData=new SchemaFieldsData();
    ArrayOfItemFieldDefinitionData arrayOfItemFieldDefinitionData=new ArrayOfItemFieldDefinitionData();
    List<ItemFieldDefinitionData> lFieldsData=arrayOfItemFieldDefinitionData.getItemFieldDefinitionData();

    SingleLineTextFieldDefinitionData name=new SingleLineTextFieldDefinitionData();
     name.setName("Name");
     name.setDescription("This is name");
       name.setDefaultValue("This is Text");
     name.setPattern("This is Text");


     lFieldsData.add(name);
   schemaFieldsData.setRootElementName("Content");


        schemaFieldsData.setFields(arrayOfItemFieldDefinitionData);
        schemas.setTitle("coreserviceSchema");
        schemas.setDescription("coreservicesScheam");

       schemas.setIsTridionWebSchema(true);
       schemas.setRootElementName("Content");


        schemas.setId("tcm:0-0-0");
        LocationInfo l=new LocationInfo();
        LinkToOrganizationalItemData ltd=new LinkToOrganizationalItemData();
        ltd.setIdRef("tcm:87-5621-2");
        l.setOrganizationalItem(ltd);
        schemas.setLocationInfo(l);
    schemas.setXsd(client.convertSchemaFieldsToXsd   (schemaFieldsData).toString());

        schemas=(SchemaData)client.create(schemas, new ReadOptions());

when I run my code I am getting following error

Exception in thread "main" javax.xml.ws.soap.SOAPFaultException: The formatter threw an exception while trying to deserialize the message: There was an error while trying to deserialize parameter http://www.sdltridion.com/ContentManager/CoreService/2012:data. The InnerException message was 'There was an error deserializing the object of type Tridion.ContentManager.Data.IdentifiableObjectData. Data at the root level is invalid. Line 1, position 1.'. Please see InnerException for more details.

at com.sun.xml.internal.ws.fault.SOAP11Fault.getProtocolException(Unknown Source)
at com.sun.xml.internal.ws.fault.SOAPFaultBuilder.createException(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SyncMethodHandler.invoke(Unknown Source)
at com.sun.xml.internal.ws.client.sei.SEIStub.invoke(Unknown Source)
at com.sun.proxy.$Proxy39.create(Unknown Source)

This Error is coming due to line

schemas.setXsd(client.convertSchemaFieldsToXsd (schemaFieldsData).toString());

when I comment this line my code is sucessfully run and create a schema on sdl tridion but this schema dosen't have any field and I want to create a schema with a name field How can I do this?

2
  • Check your XSD is really what is should be. Also I see you do not specify namespace URI of your schema fields. In case nothing helps - turn on CoreService tracing and investigate trace. It will show you the exact exception. Apr 23, 2014 at 10:52
  • Instead of doing a SchemaData schemas=new SchemaData(); , try to do SchemaData schemas = (SchemaData)client.GetDefaultData( ItemType.Schema, containerId, new ReadOptions());
    – Raimond
    Apr 23, 2014 at 10:57

0

Your Answer

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

Browse other questions tagged or ask your own question.