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

Community Tip - Need to share some code when posting a question or reply? Make sure to use the "Insert code sample" menu option. Learn more! X

Newbie JSP / Web Service coding

tgall
1-Newbie

Newbie JSP / Web Service coding

I am new to the whole WIndchill environment and would like to create web services to integrate with some internal home-grown applications. I am able to create a web service by creating a .xml. file and placing it in the tasks/com/company folder. It does the authentication and pulls the requested data returning the xml formatted results:



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



<ie:param name="AUTHORIZATION" data="&lt;a" href="mailto:${@SERVER[]authorization[]}">${@SERVER[]authorization[]}"/>
<ie:param name="ATTRIBUTE" data="wt.federation.ie.VMName"/">
<ie:param name="GROUP_OUT" data="properties"/">
</ie:webject>



<ie:param name="instance" data="${properties[0]wt.federation.ie.VMName[0]}"/">
<ie:param name="type" data="wt.part.WTPart"/">
<ie:param name="where" data="number=FH50130"/">
<ie:param name="attribute" data="name,obid" delim=","/">
<ie:param name="group_out" data="lcTemplate"/">
</ie:webject>


I would like to use this code as a basis for a jsp (in the codebase/com/company) folder to allow me to pull the data and process it in the JSP to return re-formatted data to the external application. When I execute the following JSP file I get an AuthorizationException.



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



<h3> Query for Model's Pallet Diagram <h3>


<ie:webject name="Get-Properties" type="MGT">
<ie:param name="AUTHORIZATION" data="$(@SERVER[]authorization[])"/">
<ie:param name="ATTRIBUTE" data="wt.federation.ie.VMName"/">
<ie:param name="GROUP_OUT" data="properties"/">
</ie:webject>



<ie:param name="instance" data="$(properties[0]wt.federation.ie.VMName[0])"/">
<ie:param name="type" data="wt.part.WTPart"/">
<ie:param name="where" data="number=FH50130"/">
<ie:param name="attribute" data="name,obid" delim=","/">
<ie:param name="group_out" data="lcTemplate"/">
</ie:webject>


3 REPLIES 3

Thomas,

It looks like the only reason you have the Get-Properties webject is to
get the value of wt.federation.ie.VMName

try this:

remove the Get-Properties webject
add this Java code
String instance =
wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");
pass instance to the Query-Objects webject
<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="instance" data="&lt;%=" instance%=">"/>
<ie:param name="type" data="wt.part.WTPart"/">
<ie:param name="where" data="number=FH50130"/">
<ie:param name="attribute" data="name,obid" delim=","/">
<ie:param name="group_out" data="lcTemplate"/">
</ie:webject>
Should work.

David Graham
Windchill Developer/Administrator
CAx Administrator


Emhart Glass Manufacturing Inc.
Emhart Glass Research Center
123 Great Pond Drive | Windsor, CT 06095 | USA
Telephone +1 (203) 376-3144 | Telefax +1 (860) 298 7397
Mobile +1 (203) 376-3144 |
tgall
1-Newbie
(To:tgall)

Thanks for the suggestion but it didn't work. It doesn't resolve the variable "instance".

The updated code:
<%@page language="java" session="false" errorPage="IEError.jsp"%>

<%@ taglib uri=" prefix="ie" %>

<html>
<head>
<title>JSP DIsplay-Table</title>
</head>


<h3> Query for Model's Pallet Diagram <h3>

String instance = wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");

<ie:webject name="Query-Objects" type="OBJ">
<ie:param name="instance" data="&lt;%=instance%">"/>
<ie:param name="type" data="wt.part.WTPart"/">
<ie:param name="where" data="number=FH50130"/">
<ie:param name="attribute" data="name,obid" delim=","/">
<ie:param name="group_out" data="lcTemplate"/">
</ie:webject>
The error message:
Windchill Error
Contact your administrator for assistance. Information for their reference follows.

Thomas,

The issue is a compiling error. Not a runtime error.

The variable instance did not get resolved because the code to get the
instance was not told that is Java code.

In JSP you need to surround all Java code with

<%

%>

Notice when I call instance in the webject it is surround by <% %> why
you ask because it is a Java input.

You did not surround the code therefore it was not recognized as code and
as such it never ran.

You need
<%
String instance =
wt.util.WTProperties.getLocalProperties().getProperty("wt.federation.ie.VMName");
%>

David Graham
Windchill Developer/Administrator
CAx Administrator


Emhart Glass Manufacturing Inc.
Emhart Glass Research Center
123 Great Pond Drive | Windsor, CT 06095 | USA
Telephone +1 (203) 376-3144 | Telefax +1 (860) 298 7397
Mobile +1 (203) 376-3144 |
Top Tags