简体   繁体   English

如何使用Java中的Nullable参数调用DocuWare API的.NET方法

[英]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 – 当我尝试调用.NET方法–使用Javonet从Java中“创建”时,收到一条消息,指出该方法不存在,因为我没有传递正确的参数–

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 我认为这不是JavONet的问题,但是我需要克服这个问题,然后才能执行概念验证

Here is the link to the Docuware Platform – 这是Docuware平台的链接–

http://help.docuware.com/sdk/platform-eagle/html/66b2ed1e-2aef-452a-97cd-5014bbf0242b.htm 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. 我正在使用Tomcat应用程序服务器和JSP运行测试。 I know the .NET .dll are being found and the Javonet library is being correctly activated. 我知道正在找到.NET .dll,并且Javonet库已正确激活。

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"; 通常,对于可为空的参数,您可以传递常规的目标类型(在您的情况下为“ DWProductTypes ”的枚举值),或者如果您想传递null,则只需传递“ 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 您可以在这里找到DWProductTypes的所有可能值: 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 在这里,您可以找到有关使用枚举的更多信息: https : //www.javonet.com/quick-start-guide/#Enums_How_To_Work_With_Enums

or pass null: 或传递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: 对于ProductInfoHeaderValue数组,您应该创建NObjects的 Java数组并将其作为参数传递:

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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