Skip to main content
Jun 23, 2020 7:58 AM UTC
Solved

How do I upload a file to WTDocument via code?

Hello everyone, please tell me how to upload a file to WTDocument using Info*Engine?
Or how to use java to create a document and upload a file to it?

 

CassieAnswer
Jun 23, 2020 8:04 AM UTC

Hello, 

 

Here is a existing article https://www.ptc.com/en/support/article/CS18364.

Please check if it is works for you.

 

Thanks

Cassie

10 replies

CassieAnswer
Jun 23, 2020 8:04 AM UTC

Hello, 

 

Here is a existing article https://www.ptc.com/en/support/article/CS18364.

Please check if it is works for you.

 

Thanks

Cassie

VladiSlavAuthor
Jun 23, 2020 8:56 AM UTC

@Cassiethank you very much for your response, this is what you need.

Please tell me, do You have an example of how to get files from WTDocument, which is located in Windchill?

Jun 23, 2020 9:08 AM UTC

HI Vadsilav,

 

Please take a look in this article :

https://www.ptc.com/en/support/article?n=CS18364

Where you will be to create a document a upload a primary content.

Note that you may have to upload first content into server. 

Note also that it is a server side API. it is only working by invoking methodServer like described in this article :

 

https://www.ptc.com/en/support/article/CS18364

 

Hope this will help

 

Hicham

 

 

 

Using SOAP you 

VladiSlavAuthor
Jun 23, 2020 9:11 AM UTC

@hlafkir,thank you very much for your help, I had a problem, the document is being created, but the file is not attached, an error is issued:

(wt.pom.pomResource/0) wt.pom.POMInitException: A persistence error occurred. System message follows:
Nested exception is: wt.method.MethodServerException: No active method context
at wt.method.MethodContext.getContext(MethodContext.java:1835)
at wt.pom.PersistentObjectManager.getPom(PersistentObjectManager.java:268)
at wt.pom.Transaction._start(Transaction.java:690)
at wt.pom.Transaction.start(Transaction.java:654)
at com.acme.test.excel.TxtToExcel.createAndUpload(TxtToExcel.java:65)
at com.acme.test.excel.TxtToExcel.main(TxtToExcel.java:43)

Process finished with exit code 0

Jun 23, 2020 9:41 AM UTC

Hi Vadislav,

 

Did you implement the rmi invocation ? How did you do that ? and where is located your primary content ?

 

something like this : 

 

public class CreateDoc implements RemoteAccess {

public static void main(String[] args)
{
// Retrieve a MethodServer remote reference
// from the ServerManager
RemoteMethodServer rms = RemoteMethodServer.getDefault();

// Authenticate using the default
// HTTPLogin Authenticator
rms.setUserName("wcadmin");
rms.setPassword("ts");

try
{
rms.invoke("CreateDocument",
"ext.CreateDoc", null, null, null);
System.out.println("Should have worked, check the MS log");
}
catch (Exception e)
{
e.printStackTrace();
}
}


public static void CreateDocument() throws WTException, SQLException, PropertyVetoException, IOException {

....

....

 

Hicham