I have implemented a WebService in Java (RMI). In Excel I have two Makros, the one reads Data from the database via the webservice. the other writes to the database.
Reading the data from the database over the webservice is no problem (function: MyData[] getData() {...})
but when i try to call the method, which should write data to the database I have the problem, that the given Data from the VBA-Code is null then in the Java-Code.
Function: public void setData(final MyData[]) {...}
I debugged and found out, that the parameter isn't null in the VBA Code. It's only null in the Java Code.
So does anybody know, where the data may be lost?
I thought maybe I have a problem with the XML or the like, but I really don't know where to look for the mistake.
Of course: here is the code - I shortened it a little bit, but the main functionality is given
Btw, I changed the type of the data now to long and now I get an IllegalArgumentException
Java:
#WebMethod(operationName = "setData", action = "setData")
public void setData(final long k)
{
myValue = k;
}
VBA
in Sheet1 I call e.g.:
Call dataService.wsm_setData(5)
and in the serviceFile (generated with Web Service Toolkit):
Private sc_DataServic As SoapClient30
Private Const c_WSDL_URL As String = "http://pcname:8010/myurl/data?wsdl"
Private Const c_SERVICE As String = "DataServiceService"
Private Const c_PORT As String = "DataServicePort"
Private Const c_SERVICE_NAMESPACE As String = "http://myurl"
Private Sub Class_Initialize()
Set sc_DataServic = New SoapClient30
sc_DataServic.MSSoapInit2 c_WSDL_URL, str_WSML, c_SERVICE, c_PORT, c_SERVICE_NAMESPACE
sc_DataServic.ConnectorProperty("ProxyServer") = "<CURRENT_USER>"
sc_DataServic.ConnectorProperty("EnableAutoProxy") = True
Set sc_DataServic.ClientProperty("GCTMObjectFactory") = New clsof_Factory_Data
End Sub
Public Function wsm_setData(ByVal dcml_arg0 As Double)
On Error GoTo wsm_setDataTrap
sc_DataServic.setData dcml_arg0
Set sc_DataServic = Nothing
Exit Function
wsm_setDataTrap:
DataServicErrorHandler "wsm_setData"
End Function
Related
I am working on a project, where users can write other users mails. The mail-class looks currently like this:
public class Mail
{
/*
* Fields
*/
private final String _content;
private final String _sender;
private final String _date;
private final String _topic;
/**
* Constructor of the Mail-class.
*
* #param mail The mail as a string representation.
*/
public Mail(String mail)
{
_content = ...;
_sender = ...;
_date = ...;
_topic = ...;
}
// And all the getters.
#Override
public String toString()
{
// Make the reperentation as a String
}
Now, the problem is, that I need to save all the mails into a .yml userdata file. For me, the simplest way to do this is to firstly convert every mail to a String and then save all mails into a List<String> mails which will be written directly into the .yml where I can access and read the list of String with ease. Now, once I start the server, all mails should be converted back into the object-representation. The question is, how can I save the mail-Object as a String and load it, that I can operate using those mail objects.
My first ideas were something like this sender#date#topic#content and then splitting the String via String.split("#");. But when I do this, I need to ban the # character for the content and the topic. The date and the username will never contain #. I don't want to ban any character. Unfortunately I have nothing found on my researches so far on how to solve this task.
The best thing to do is use XML or JSON to markup the object and convert it to a string for you. There are tons of libraries you can use to do that. They all operate in roughly the same manner: add an annotations to your fields and class.
I'm very new to the FHIR standard and I could use some help figuring out how to evaluate a ruleExpression against an object.
Here is my object:
#ResourceDef(name = "TestObj", profile = "http://hl7.org/fhir/StructureDefinition/TestObj")
#Data
public class TestObj extends DomainResource {
private static final long serialVersionUID = 1L;
#Child(name = "numMarbles")
#Extension(url = "http://hl7.org/fhir/CustomExtension/numMarbles", definedLocally = true, isModifier = false)
#Description(shortDefinition = "The number of marbles I have in my pocket")
private IntegerType numMarbles;
}
I'm trying to figure out how to run a rule evaluation on it. For example:
String ruleExp = "%numMarbles > 3"
In order to try options.. I've setup the following integration test:
#Test
void doRuleEval() throws Exception {
TestObj t = new TestObj();
t.setNumMarbles(4);
String ruleExp = "%numMarbles > '3'";
FhirPathR4 path = new FhirPathR4(fhirContext);
// ?????
Object something = path.evaluate(t, ruleExp, null);
// Line above always fails: "unknown fixed constant %numMarbles"
log.info("something: " + something.toString());
}
I've scoured the FHIR documentation and can't find java examples for how to evaluate dynamic rules against FHIR models. In the Javascript library we used the "compile" method but I can't find the equivalent Java method.
I feel like I'm missing something fundamental here.
The "evaluate" method is not documented - it takes in an "IBase" object which is any FHIR object from what I can tell, and returns some sort of list... who knows.
The FhirPathR4 object also contains a "parse" method that returns nothing and is also un-documented.
Thanks for any help or tips to point me in the right direction for evaluating a "ruleExpression" against an object's fields.
I would go onto the HAPI FHIR Google group as ask about the evaluate method there.
https://groups.google.com/g/hapi-fhir?pli=1
I am prototyping an interface to our application to allow other people to use python, our application is written in java. I would like to pass some of our data from the java app to the python code but I am unsure how to pass an object to python. I have done a simple java->python function call using simple parameters using Jython and found it very useful for what I am trying to do. Given the class below, how can I then use it in Python/Jython as an input to a function/class:
public class TestObject
{
private double[] values;
private int length;
private int anotherVariable;
//getters, setters
}
One solution. You could use some sort of message system, queue, or broker of some sort to serialize/deserialize, or pass messages between python and java. Then create some sort workers/producer/consumers to put work on the queues to be processed in python, or java.
Also consider checking out for inspiration: https://www.py4j.org/
py4j is used heavily by/for pyspark and hadoop type stuff.
To answer your question more immediately.
Example using json-simple.:
import org.apache.commons.io.FileUtils;
import org.json.simple.JSONObject;
//import org.json.simple.JSONObject;
public class TestObject
{
private double[] values;
private int length;
private int anotherVariable;
private boolean someBool;
private String someString;
//getters, setters
public String toJSON() {
JSONObject obj=new JSONObject();
obj.put("values",new Double(this.values));
obj.put("length",new Integer(this.length));
obj.put("bool_val",new Boolean(this.SomeBool));
obj.put("string_key",this.someString);
StringWriter out = new StringWriter();
obj.writeJSONString(out);
return out.toString();
}
public void writeObject(){
Writer writer = new BufferedWriter(
new OutputStreamWriter(
new FileOutputStream("anObject.json"), "utf-8")
)
)
writer.write(this.toJSON());
}
public static void setObject(){
values = 100.134;
length = 12;
anotherVariable = 15;
someString = "spam";
}
}
And in python:
class DoStuffWithObject(object):
def __init__(self,obj):
self.obj = obj
self.changeObj()
self.writeObj()
def changeObj(self):
self.obj['values'] = 100.134;
self.obj['length'] = 12;
self.obj['anotherVariable'] = 15;
self.obj['someString'] = "spam";
def writeObj(self):
''' write back to file '''
with open('anObject.json', 'w') as f:
json.dump(self.obj, f)
def someOtherMethod(self, s):
''' do something else '''
print('hello {}'.format(s))
import json
with open('anObject.json','r') as f:
obj = json.loads(f.read())
# print out obj['values'] obj['someBool'] ...
for key in obj:
print(key, obj[key])
aThing = DoStuffWithObject(obj)
aThing.someOtherMethod('there')
And then in java read back the object. There are solutions that exist implementing this idea (JSON-RPC, XML-RPC, and variants). Depending, you may may also want to consider using something like ( http://docs.mongodb.org/ecosystem/drivers/java/ ) the benefit being that mongo does json.
See:
https://spring.io/guides/gs/messaging-reactor/
http://spring.io/guides/gs/messaging-rabbitmq/
http://spring.io/guides/gs/scheduling-tasks/
Celery like Java projects
Jedis
RabbitMQ
ZeroMQ
A more comprehensive list of queues:
http://queues.io/
Resources referenced:
http://www.oracle.com/technetwork/articles/java/json-1973242.html
How do I create a file and write to it in Java?
https://code.google.com/p/json-simple/wiki/EncodingExamples
Agree with the answer below. I think that the bottom line is that "Python and Java are separate interpreter-environments." You therefore shouldn't expect to transfer "an object" from one to the other. You shouldn't expect to "call methods." But it is reasonable to pass data from one to another, by serializing and de-serializing it through some intermediate data format (e.g. JSON) as you would do with any other program.
In some environments, such as Microsoft Windows, it's possible that a technology like OLE (dot-Net) might be usable to allow environments to be linked-together "actively," where the various systems implement and provide OLE-objects. But I don't have any personal experience with whether, nor how, this might be done.
Therefore, the safest thing to do is to treat them as "records," and to use serialization techniques on both sides. (Or, if you got very adventurous, run (say) Java in a child-thread.) An "adventurous" design could get out-of-hand very quickly, with little return on investment.
You need to make the python file to exe using py2exe , Refer the link : https://www.youtube.com/watch?v=kyoGfnLm4LA. Then use the program in java and pass arguements:
Please refer this link it will be having the details:
Calling fortran90 exe program from java is not executing
I am having problem passing String to a Java method in my GWT project:
public final native String waveIt()/*-{
var instance = this;
var data = $wnd.Waverecorder.data();
var strData = data.toString();
var arr = strData.split(',');
for (var i = 0; i < arr.length; i++) {
var data = arr[i];
console.log(data);
instance.#com.mycode.wave.showcase.client.Showcase::updateWave(Ljava/lang/String;)(data.toString());
}
}-*/;
Looking from the console log of Chrome/Firefox I can see that I get the right data (this is the exact log I get):
-0.00006103515625
-0.00006103515625
-0.00006103515625
-0.05072021484375
-0.553833007812
(more data omitted)
When the GWT java method received the data it is empty. What could be the reason?
This method should be void, because you do not return a string - you call a Java method from it.
Looking at your code, you don't need var instance = this; and you can remove instance. before #com.
You declare var data twice: before the loop and inside the loop. Instead of calling your Java method with data.toString(), you can call it with arr[i].
What do you mean by:
When the GWT java method received the data it is empty.
Are you talking about the string that waveIt() should return?
The bug may be that there is no return statement in waveIt().
I have this property in a visual basic class. NET 2008, the property in addition to the get and set has a parameter called "pParam. "
Public Property UpdateField(ByVal pParam As String) As String
Get
Return Me.idField
End Get
Set(ByVal value As String)
Me.idField = value
If pParam = "NEW" Then
// some code here
End If
End Set
End Property
which is the equivalent of this in java code?
to use I do the following:
oClass.UpdateField("NEW") = 1850
I have this code in java
public void setUpdateField(String idField) {
this.idField = idField;
}
public String getUpdateField() {
return idField;
}
but I need to put the parameter "pParam"
Thanks in advance.
What you've got in the .NET code is an indexer in C# terms. There's no equivalent in Java - you'll just need to take two parameters:
public void setUpdateField(String idField, String pParam) {
...
}
Frankly I think it's a little odd that the "getter" in .NET doesn't seem to use the index...