I'm wondering what the best method is to call a standard service from custom Java code?

In a specific situation iDoc script is extended with custom functions with a custom component. There's Java code mapping to these functions that is executing these functions. The iDoc script functions are called from a workflow entry script.

In the Java code that runs when the custom iDoc functions are called, I want to call a standard Content Server service. I don't think that the m_service variable is available, so filling the binder and using m_service.executeService() probably isn't possible.

Also, if it were possible (that is, if I want to call a standard service from my own custom service Java code), what would then be the best method to do so?

Hey Stijn,
If you want to call a standard service then you would need to write a Service Handler.(a service can only call another subservice, It cannot call another service). You may user executeServiceEx method there.

I'm an UCM consultant trying to solve a problem that occured at a client when they installed the CS10gR35CoreUpdateBundle.

Content items are entered into a Workflow when they are checked in. Part of one of the entry scripts of the a workflow step is that related content to the content item in the workflow is (re)submitted for conversion.

To achive this, a custom component provides an iDoc script extension. This iDoc function (resubmitForConversion) is implemented in Java (the class extends ScriptExtensionsAdaptor).
In this Java method, first the related content items are fetched. Then the service RESUBMIT_FOR_CONVERSION should be called for all dID's in of the related content.

Thus, at a certain point in the custom Java code, a native Content Server service must be called. Of course the class of this Java code does not extend the Service class, so the m_service object isn't available.

The thing is: before installed the 10gR35CoreUpdateBundle everything worked OK. This code was used to execute the service:

This solved the transaction problem but introduces another problem: !csUnableToResubmitItem,(null)!csIllegalScriptAccess,RESUBMIT_FOR_CONVERSION

The Service Reference Guide says that the access level for RESUBMIT_FOR_CONVERION is 33 (Read, Scriptable). However, in shared/config/resources/std_services.htm the access level is specified as 2 (write).

Thus, my question still is:

What is the best method to call a standard Content Server service from any Java code (so without extending the Service class, or having the m_service object available)?

Hey StijnR,
looking at all this there are two things that are coming to my mind.
1) change access permission of the RESUBMIT_FOR_CONVERSION service.
2) calling your RESUBMIT_FOR_CONVERSION service from within another handler. This way context of your execution might change.

No matter what code I used, the !csIllegalScriptAccess never disappeared (sometimes it was replaced with the transaction-in-a-transaction error).

What is the book you're mentioning? Is it only somewhere?
//edit: Ah, Bex Huff, I do have that book. Do you know the pagenumber of chapter?

Yeah, I know by now that calling a service from ordinary Java code isn't straight forward. I wish there was a good API documentation of the source code available.
Something like the RIDC API should also exist to be called from withing the Content Server.

I managed to create a (temporary) workaround by creating my own service: RESUBMIT_FOR_CONVERSION_NO_TRANSACTION.
I copied the complete service definition from RESUBMIT_FOR_CONVERSION and changed the Access Level to 34, and removed the transaction start and end control flags from the actions. This action can be called from within the Java code using the original calling construction.

I'm not really happy with this, as messing with transactions is bound to give you problems at some point. But hey, it's better than nothing.

I'm still curious to see how other people are solving the problem of trying to call (standard or custom) services from Java code. If anybody has any useful code, please post it in this thread.

I don't have access to this code anymore, so I cannot give you the details, but basically I created a copy of the service definition and made it scriptable, as mentioned in my previous post:

"I managed to create a (temporary) workaround by creating my own service: >RESUBMIT_FOR_CONVERSION_NO_TRANSACTION.
I copied the complete service definition from RESUBMIT_FOR_CONVERSION and changed the Access Level to 34, and removed the transaction start and end control flags from the actions. This action can be called from within the Java code using the original calling construction."

Thank you, it worked, Now I can call the Service once I removed the tranaction flags (i missed that before) and made the service Scriptable.
I was trying to UPDATE_DOCINFO of another content item that is not in workflow on approval of the work flowed item and also i needed to replicate that item. I was able to acheive that, but on Approval the original Content item is not moving forward in work flow. Any thoughts.....