Skip to main content
1-Visitor
Aug 16, 2011 9:20 PM UTC
Question

how to use ApplyService in com.ptc.windchill.ws

I use the SOAP api with Windchill 10.0 to create a custom interface and do some automated stuff.

I can do queries now and a navigation through the folders. But now I want to do changes to the lifecycle state of an object. My understanding is that I need to use ApplyService for that. But if I try that, it only gives me an Internal Server Error which is a NullPointer exception in the shell on the Windchill server.

If someone could give me a working example of ApplyService or, even better, something to set a new lifecycle state, that would be really helpfull for me.

Thanks in advance,

martin

7 replies

1-Visitor
Aug 19, 2011 7:17 PM UTC

something like this...

<ie:webject name="Apply-Service" type="OBJ">
<ie:param name="instance" data="${@FORM[]supporting-adapter[*]}" valueSeparator=";" delim=";" default="windchill" />
<ie:param name="SERVICE" data="wt.lifecycle.LifeCycleHelper"/>
<ie:param name="METHOD" data="setLifeCycleState"/>
<ie:param name="STATIC" data="false"/>
<ie:param name="GROUP_IN" data="args"/>
<ie:param name="ARG" data="wt.lifecycle.LifeCycleManaged='${@FORM[]dca_object_ref[]}'"/>
<ie:param name="ARG" data="wt.lifecycle.State=STATE"/>
<ie:param name="ARG" data="boolean='false'"/>
<ie:param name="group_out" data="${@FORM[]group_out[]}" default="output"/>
</ie:webject>
Translate
1-Visitor
Sep 13, 2011 8:51 AM UTC

After a few tries and modifications I get now only an error message:

java.lang.NoSuchMethodException: wt.lifecycle.State.(java.lang.String)

How can I get a state value in there?

Translate
1-Visitor
Sep 13, 2011 5:20 PM UTC

Can you send me the modifed webject. Looks like some type cast issue. I would look at api and try to match the argument appropriately.

Look at Windchill/wt/clients/library/api/index.html - wt.lifecycle

State, LifeCycleHelper

WTList setLIfeCycleState (WTList, State, boolean /*terminateAssocProcesses*/)

  • This API allows you to set the state on all objects in the list to the specified state. If the boolean is set to true, all associated workflow processes will be terminated. It is the responsibility of the calling API to ensure all objects in the list have the specified state in their life cycle template.


Code Example: You want to reassign a group of objects to a particular template to a particular state. In this example, you have a query result of the life cycle managed objects you want to reassign.

WTList list = new WTArrayList(results.size()/.75+1);

while (results.hasMoreElements()) {

list.add((LifeCycleManaged)results.nextElement())

}

LifeCycleTemplateReference lctr=LifeCycleHelper.service. getLifeCycleTemplateReference( name, container );

State released=State.toState(“RELEASED”);

LifeCycleHelper.service.reassign(list, lctr, container, released);

Translate