简体   繁体   中英

How to call .NET method of DocuWare API with Nullable arguments from Java

When I try to invoke the .NET method – 'Create' from Java using Javonet I get a message the method does not exist because I am not passing the correct parameters –

DocuWare.Platform.ServerClient.ServiceConnection 
Create(System.Uri, 
                   System.String, 
                   System.String, 
                   System.String, 
                   System.Nullable`1[DocuWare.Platform.ServerClient.DWProductTypes], 
                   System.Net.Http.HttpMessageHandler, 
                   System.Net.Http.Headers.ProductInfoHeaderValue[]
                   )

My code is –

NObject objUri = Javonet.New("Uri","http://<IP-address>/DocuWare/Platform");

NType serviceConnectionClass = Javonet.getType("DocuWare.Platform.ServerClient.ServiceConnection");  

NObject objProductInfoHeaderValue = Javonet.New("System.Net.Http.Headers.ProductInfoHeaderValue","DocuWare+.NET+API+Test+Client", "1.0"); 
NObject[] objProductInfoHeaderValueArray = new NObject[] {objProductInfoHeaderValue};  

NType typeHttpMessageHandler = Javonet.getType("System.Net.Http.HttpMessageHandler");

NType typeNullable = Javonet.getType("System.Nullable");

serviceConnectionClass.invoke("Create",objUri,"admin","admin","<company-name>",typeNullable,typeHttpMessageHandler,objProductInfoHeaderValueArray); 

My main problem is not knowing how to generate 'Nullable' objects for –

DocuWare.Platform.ServerClient.DWProductTypes
System.Net.Http.HttpMessageHandler
System.Net.Http.Headers.ProductInfoHeaderValue[]

I don't think this is a problem with JavONet, but I need to get past this problem before I can perform a Proof-of-concept

Here is the link to the Docuware Platform –

http://help.docuware.com/sdk/platform-eagle/html/66b2ed1e-2aef-452a-97cd-5014bbf0242b.htm

I am running the Test using Tomcat app server and JSP. I know the .NET .dll are being found and the Javonet library is being correctly activated.

Thanks in advance for any help.

Normally for nullable arguments you can pass either the regular target type in your case some enum value of " DWProductTypes " or if you want to pass null just pass the "null";

So you should make the call:

serviceConnectionClass.invoke("Create",objUri,"admin", "admin","Intermodal Tank",new NEnum("DWProductTypes","DocuWareClient"),typeHttpMessageHandler,objProductInfoHeaderValueArray); 

All possible values for DWProductTypes you can find here: http://help.docuware.com/sdk/platform/html/T_DocuWare_Platform_ServerClient_DWProductTypes.htm

Here you find more about using enumerations: https://www.javonet.com/quick-start-guide/#Enums_How_To_Work_With_Enums

or pass null:

serviceConnectionClass.invoke("Create",objUri,"admin", "admin","Intermodal Tank",null,typeHttpMessageHandler,objProductInfoHeaderValueArray);

For argument HttpMessageHandler just create the instance:
NObject typeHttpMessageHandler = Javonet.New("SomeConcreteTypeInheritingFromHttpMessageHandler");

For ProductInfoHeaderValue array you should create Java array of NObjects and pass it as argument:

NObject[] objProductInfoHeaderValueArray = new NObject[1];
objProductInfoHeaderValueArray[0] = Javonet.New("ProductInfoHeaderValue","productName","version");

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM