cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
Showing results for 
Search instead for 
Did you mean: 

Community Tip - Want the oppurtunity to discuss enhancements to PTC products? Join a working group! X

Thingworx user context to pull windchill xml data

ag-2
2-Explorer

Thingworx user context to pull windchill xml data

Hello All,

Our requirement is to fetch from Windchill, the dropdown values of ThingWorx UI for certain attributes, (Enumeration data)

The idea  ...

1. write a Infoengine task (webject) in windchill (getObjectAttributes.xml), that returns all attributes for a given object type.

2. And then in ThingWorx, "load" the XML in a javascript service, parse XML and show attribute values in UI


But when I "load" the XML in my javascript service using LoadXML snippet, it expects username/password. Is it possible to use the user-context or user-session to LoadXML, because the user will be already logged-in to the system and also its not right approach to pass user credentials through code.

Thanks

Avinash


3 REPLIES 3
smainente
16-Pearl
(To:ag-2)

Hi Avinash,

You can use the Windchill Connector to invoke an I*E task and get back an Infotable.

WindchillConnector exposes the Generic Windchill SOAP Web Service (com.ptc.windchill.ws) and more :

ApplyService, CancelCheckOut, CheckIn, CheckOut, CompleteWorkItems, Create, CreateContentHolder, DelegateAction, DelegateWorkItems, Delete, DeleteContent, DescribeTypes, ExecuteTask, Fetch, GetDownloadHandles, GetIterationHistory, GetLifecycleHistory, GetUploadHandles, GetVersionHistory, GetWorkList, Link, ListContent, ListTypes, Move, Navigate, Query, Revise, StartWorkflow, SubscribeToEvent, UnsubscribeObjectEvents, Update

Note that you need to install a patch on the Windchill server to enable the ThingWorx integration (in WNC 11.0 M010 and later, it may work without if you just use the I*E base services listed above).

The Windchill Connector is part of the PTC Windchill Extension available in the Marketplace

ag-2
2-Explorer
(To:ag-2)

Hello Stephane,

Thanks for the quick response.

I tried Windchillconnector.ExecuteTask() that gives output as STRING to a datashape.

Challenge is if an attribute tag has multiple values, the string can hold only the last value. Perhaps if I can set a datashape field with BaseType as Array, the ExecuteTask() might store all the values of the particular attribute, but arrays are not allowed I guess.

Eg. <severity><value>high</value><value>medium</value><value>low</value></severity>. For the attribute "severity", if there are 3 enumerated values, then ExecuteTask is able to hold only the last value "low", because of overwriting the same datashape field "severity". Please advise.

smainente
16-Pearl
(To:ag-2)

I suspect that ExecuteTask() does not handled multi-values attribute.

As alternative, you can maybe concatenate all the attribute values into a single string (csv or other) in the I*E task directly

For example :

smaMVString is the source multi value attribute

smaMVStrings contains the resulting comma separated values

<%@page language="java" access="http|soap|internal"%>

<%@taglib uri="http://www.ptc.com/infoengine/taglib/core" prefix="ie"%>

<ie:webject name="Get-Properties" type="MGT">

    <ie:param name="ATTRIBUTE" data="wt.federation.ie.VMName"/>

    <ie:param name="GROUP_OUT" data="properties"/>

</ie:webject>

<ie:webject name="Query-Objects" type="OBJ">

    <ie:param name="INSTANCE" data="$(properties[0]wt.federation.ie.VMName[0])"/>

    <ie:param name="TYPE" data="wt.doc.WTDocument"/>

    <ie:param name="WHERE" data="name=MVDoc"/>

    <ie:param name="ATTRIBUTE" data="name,smaMVString" delim=","/>

    <ie:param name="GROUP_OUT" data="output"/>

</ie:webject>

<%

    Group g = getGroup("output");

    int hits = g.getElementCount();

   

    String mystrs="";

    Enumeration items = g.getElements();        

    while (items.hasMoreElements())

    {

       Element theItem = (Element)items.nextElement();

       Enumeration tempstrs = theItem.getAtt("smaMVString").getValues();

       while( tempstrs.hasMoreElements() ) {

            mystrs += tempstrs.nextElement();

            if( tempstrs.hasMoreElements() ) mystrs += ",";

       }

       theItem.addAtt( new Att( "smaMVStrings", mystrs));                                                             

    }

%>

Announcements


Top Tags