Skip to main content
17-Peridot
June 23, 2020
Solved

How do I upload a file to WTDocument via code?

  • June 23, 2020
  • 2 replies
  • 5743 views

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?

 

Best answer by Cassie

Hello, 

 

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

Please check if it is works for you.

 

Thanks

Cassie

2 replies

Cassie15-MoonstoneAnswer
15-Moonstone
June 23, 2020

Hello, 

 

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

Please check if it is works for you.

 

Thanks

Cassie

VladiSlav17-PeridotAuthor
17-Peridot
June 23, 2020

@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?

5-Regular Member
June 23, 2020

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 

VladiSlav17-PeridotAuthor
17-Peridot
June 23, 2020

@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

5-Regular Member
June 23, 2020

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