Ich denke das hier ist so ziemlich das was Du suchst:
http://www-10.lotus.com/ldd/ddwiki.nsf/dx/reuse_web_services_xpage.htm
Using existing Web Services in an Xpage
Web Service
So far, we have discussed two methods to reference existing business logic in XPages. Web services is a third option and it will leverage the same technique described in the Java section: the ability of Server Side JavaScript to call Java. Instead of calling your business logic, we will use JavaScript to access JAR files distributed with the IBM Lotus Domino 8.5 server. These JAR files provide the Web Services client framework providing access to web services. In this article we will use Apache Axis and the extensible type mapping framework (javax.xml.rpc.encoding). Web services can not be used by XPages to access business logic running on the same Lotus Domino server because a deadlock condition might occur in the HTTP server. This restriction prevents XPages from using Web services to call an applications business logic, but we include this technique here because Web services can be used to access business logic running in another application on a different server.
In the LotusScript section a "Credit Rating" scenario is discussed. A new label was added, with a computed value using Server Side JavaScript to call an agent. The return value from this formula is displayed as the label contents. Web services would be a viable alternative, if the "Credit Rating" business logic was in another application on another server. A new label would be added, with a computed value using Server Side JavaScript to call the Web service. Lets walk through that code
JavaScript code to call a Web service to operate on parameters, and return a value.
var service = new org.apache.axis.client.Service;
var call = service.createCall();
call.setTargetEndpointAddress("http://myServer.myCompany.com/WebServicesDemo.nsf/DemoWebService?WSDL");
call.setOperationName( "CalcCreditRating" );
var xmlType = new javax.xml.rpc.encoding.XMLType();
call.addParameter("INPUT1", xmlType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.addParameter("INPUT2", xmlType.XSD_STRING, javax.xml.rpc.ParameterMode.IN);
call.setReturnType(xmlType.XSD_STRING);
var a = new java.lang.Object[2];
a[0] = "CompanyA";
a[1] = "2008";
var rating = call.invoke(a);
print ("return value from web service = "+rating);
return rating;
We will only describe the Web service client code. A Web service provider must also be implemented for the sample above to access. In this case, the author used another Lotus Domino 8.5 server as the Web Service provider. This Web service accepted two strings as input arguments and returned a string for the credit rating. Any Web Services provider is acceptable, but some of the sample code might require minor modifications.
On line (1) and (2) we create the Service and Call object to access the Web service. We then associate the Call object to the WSDL (3) which defines the available operations. We must specify the operation we plan to call (4) because a Web Service can contain multiple operations. The next lines (5 - 8) define the arguments, the input argument (6) and (7), and the return (8). The string arguments are passed as an array (9 -11), and then the call is invoked (12). The "Credit Rating" is returned (14) to the computed value and displayed as the label.
The example above was written in JavaScript and calls the Apache Axis and the extensible type mapping framework (javax.xml.rpc.encoding) JAR files. Any Web Services client framework can be used. Apache Axis was selected because it is distributed with the Lotus Domino 8.5 server. If you prefer to develop your solutions in Java instead of JavaScript then develop your code in Java, package the JAR file as described above in the Java section and call your routines from JavaScript. With Java, you can test your logic using JUnit and debug any problems before calling it from XPages.
For other techniques for reusing business logic from XPages please see this article here.
Hi,
ich hab mal die JavaScript Variante aus dem angegeben Artikel ausprobiert.
"Using existing Web Services in an Xpage".
Ich arbeite mit einem Domino 8.5.2.
Das war die erste Fehlermeldung die ich bekommen habe.
Exception
Error while executing JavaScript computed expression
Script interpreter error, line=3, col=48: [ReferenceError] 'org' not found
JavaScript code
1: var service = new org.apache.axis.client.Service;
2:
3: var call = service.createCall();
4:
Dann hab ich mir mal den neuen package name gesucht.
Habe dann diesen "lotus.domino.axis.client.Service" package Name gefunden.
Nur leider kommt jetzt der Fehler der unten steht.
Wie kann ich denn dann ein Service Object erzeugen. Wenn es keinen öffentlichen
Kontruktor gibt ?
Error while executing JavaScript computed expression
Script interpreter error, line=3, col=50: Cannot find java public constructor 'lotus.domino.axis.client.Service()'
JavaScript code
1: var service = new lotus.domino.axis.client.Service;
2: //var service = new org.apache.axis.client.Service;
3:
4: var call = service.createCall();
5:
Vielen Danke für Hilfe eure Hilfe im vorraus.
Hallo Markus!
Du hast gar nichts falsch gemacht,
var service = new org.apache.axis.client.Service;
wäre schon richtig gewesen.
Leider wurde in Domino 8.5.2 die Art und Weise geändert, wie org.apache.axis.client.Service in Domino eingebunden wurde. Stand es früher über den Classpath zur Verfügung, wurde es ab 8.5.2. als OSGI Plugin eingebunden und steht daher nicht mehr für eine wie oben beschriebene Einbindung zur Verfügung.
Du musst Dir also die Axis libraries von der Axis Homepage (http://axis.apache.org/axis/) herunterladen und wie in Using existing Java in an Xpage (http://www-10.lotus.com/ldd/ddwiki.nsf/dx/reuse_java_xpage.htm) beschrieben einbinden.
Anschließend noch die Security gemäß Xpages Jar file Access Denied (http://www-10.lotus.com/ldd/nd85forum.nsf/DateAllThreadedWeb/ddcb22a45e4ae452852577b400621a5a?OpenDocument) im java.policy (http://www-10.lotus.com/ldd/ddwiki.nsf/dx/XPages_in_the_Notes_Client-Security#java.policy) File umsetzten:
Support suggested adding to the java.policy file (in ..\Lotus\Domino\jvm\lib\security folder).
Add this to the grant section:
permission java.lang.RuntimePermission "getClassLoader";
Dann sollte es funktionieren.
P.S.: Wenn das wer "gefixed" haben will, sodass es wieder so wie früher funktioniert, möge einen enstprechenden PMR aufmachen.
Hi,
ich habe inzwischen mal ein bisschen mit den Webservices gearbeitet.
Folgende Situation:
Ich habe im Java Project die nötigen Axis Jars importiert. Dort gibt es nun auch eine Klasse von mir, mit einer static Methode die den Webservice Call übernimmt ( in der Methode steht etwas sowas ).
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName( method );
call.addParameter("op1", XMLType.XSD_INT, ParameterMode.PARAM_MODE_IN);
call.addParameter("op2", XMLType.XSD_INT, ParameterMode.PARAM_MODE_IN);
call.setReturnType(XMLType.XSD_INT);
call.invoke( new Object [] { i1, i2 });
In der XPage wird dann diese Methode gerufen:
importPackage(myPackage)
var ws = new Webservice();
var result = ws.callWebserivce(param1,param2 .... )
Das ganze funktioniert ganz gut.
Jetzt will ich aber die Performance des Ganzen etwas verbessern:
Ich habe mal gemessen wo die meiste Zeit verloren geht.
Beim ersten Aufruf der Methode ws.callWebserivce(param1,param2 .... ) auf einer XPage kann es zwischen 2 - 4 s dauern bis zu der Stelle im Java Code bevor der eigentliche Webservice gerufen (call.invoke(...)) wird.
Der eigentliche Webservice ist also noch ausgeschlossen und es dauert schon zwischen 2-4 s.
Und das ganze bei jedem Neuladen wieder :(.
Ich schätze mal das es daran liegt das die importieren packages im java, jedes mal frisch aus den jars geladen werden müssen.
So jetzt meine eigentliche Frage was kann ich machen ?
Meine Optionen:
1. Man kann in die notes.ini bei den javauserclasses jars laden, die beim Starten des Domino automatisch mitgeladen werden. Diese sind dann in Agenten und Java Librays verfügbar. Soweit ich weiß läuft mein Code aber in der HTTP JVM des Domino und somit sind die javauserclasses auch nicht erreichbar? Stimmt das soweit? (Nebenbei laufen da zwei verschiedene JVMs ?)
2.Kann ich irgendwo die HTTP JVM dazu bringen die jars beim starten zu laden über irgendein Konfiguration oder so ?
3.Ich könnte mir auch ein echtes Control (wie in der Extension Libray) entwickeln. Hab ich auch schon versucht doch ich bin daran gescheitert das die jars die ich für den axis webservice call hinzugefügt habe. Dabei konnte ich festellen das ein Großteil der jars sowieso schon in einem solchen Control verfügbar sind.
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
call.setOperationName( method );
call.addParameter("op1", XMLType.XSD_INT, ParameterMode.PARAM_MODE_IN);
call.addParameter("op2", XMLType.XSD_INT, ParameterMode.PARAM_MODE_IN);
call.setReturnType(XMLType.XSD_INT);
sowas steht für den Webservice Call in dem Control prinzipell ist das alles kein Problem.
Aber:
XMLType.XSD_INT
ParameterMode.PARAM_MODE_IN
Kann ich leider nicht nutzen, im Eclipse wird mir angezeigt " Access restriction: ParameterMode is not accessible due to restriction on required library"
Hat jemand dazu eine Idee ?
Oder hat jemand noch einen anderen Vorschlage was ich machen könnte ?
Danke im Vorraus
Mit freundlichen Grüßen
Markus