Tuesday, November 09, 2010
Very nice SOAP client (java)
I've implement also LS2J approach
here is my example. There are some enhancements need to do, but anywhere this also works fine.
Java library
import java.io.*;
import java.net.*;
public class ECWebservice {
String cResponse;
String wsurl;
String msg;
String contentType;
public ECWebservice(String init_url) throws IOException {
wsurl = init_url;
msg = "";
contentType = "text/xml; charset=utf-8";
cResponse = "";
}
public String GetResponce() {
return cResponse;
}
public void SetContentType(String init_contenttype) {
contentType = init_contenttype;
}
public boolean Send(String init_msg) {
boolean result = true;
try {
msg = init_msg;
// Create the connection where we're going to send the file.
URL url = new URL(wsurl);
URLConnection connection = url.openConnection();
HttpURLConnection httpConn = (HttpURLConnection) connection;
String SOAPAction = msg;
byte[] b = SOAPAction.getBytes();
// Set the appropriate HTTP parameters.
httpConn.setRequestProperty( "Content-Length", String.valueOf(SOAPAction.length()));
httpConn.setRequestProperty("Content-Type", contentType);
httpConn.setRequestProperty("SOAPAction", SOAPAction);
httpConn.setRequestMethod("POST");
httpConn.setDoOutput(true);
httpConn.setDoInput(true);
// Everything's set up; send the XML that was read in to b.
OutputStream out = httpConn.getOutputStream();
out.write(b);
out.close();
// Read the response and write it to standard out.
InputStreamReader isr = new InputStreamReader(httpConn.getInputStream(), "utf-8");
BufferedReader in = new BufferedReader(isr);
String inputLine;
while ((inputLine = in.readLine()) != null) {
cResponse += inputLine;
}
in.close();
} catch(Exception e) {
e.printStackTrace();
cResponse = "Main: Exception occured - check Java Debug Console";
result = false;
}
return result;
}
}
LS2J library
Option Public
Option Declare
Use "webservice.core"
UseLSX "*javacon"
Class ECWebservice
responce As string
connection As string
contentType As string
Sub New(connection_url As string)
connection = connection_url
contentType = "text/xml; charset=utf-8"
End Sub
Public Property Get GetResponce As string
GetResponce = responce
End Property
public Property Set SetConnection
connection = SetConnection
End Property
Public Property Set SetContentType
contentType = SetContentType
End Property
Function SendXMLRequest(xmldata) As Boolean
On Error Goto errorproc
'** everything we'll need to access our Java classes
Dim jSession As New JavaSession
Dim jClass As JavaClass
Dim jObject As JavaObject
'** get the IGWebservice class and instantiate an instance of it
Set jClass = jSession.GetClass("ECWebservice")
'** version of CreateObject and init with path to WSDL)
Set jObject = jClass.CreateObject("(Ljava/lang/String;)V", connection)
jObject.SetContentType(contentType)
'** send message and get result: true/false, if true then we got result
If jObject.send(xmldata) Then
me.responce = jObject.GetResponce()
End If
SendXMLRequest = True
endofsub:
Exit Function
errorproc:
MsgBox "Error #" & Err & " on line " & Erl & " in function " & Lsi_info(2) & " : " & Error, 48, "Runtime error"
Resume endofsub
End Function
End Class
Thursday, November 04, 2010
Lotus Notes got SVN: Can't believe we get that :)
Thursday, October 28, 2010
xPage: Could not load 'imb.xsp.widget.layout.TypeAhead'
Monday, October 11, 2010
xPage: date picker does not work in IE8
Workaround
http://www-10.lotus.com/ldd/nd85forum.nsf/0/579744cf7198e21785257731006c9cea?OpenDocument
Thursday, September 16, 2010
Change encoding attribute after XLST
I've done some transformation my DXL using XSLT. The funny thing was that after transformation using
// Transform
var str = docxml.transformNode(xsl);
I always got 'encoding' as UTF-16, that's not correct, so after some time I found nice solution
here is code I used: http://dotnet.itags.org/dotnet-tech/66097/
var doc = new ActiveXObject("Microsoft.XMLDOM");
doc.load("test.xml");
// Print initial encoding
var pi = doc.firstChild;
var eattr = pi.attributes.getNamedItem("encoding");
var encoding = eattr.value;
// Convert to string and reload (this loses the encoding)
var xml = doc.xml;
doc.loadXML(xml);
// Reset the encoding to "ISO-8859-1"
pi = doc.firstChild;
var eattr = pi.attributes.getNamedItem("encoding");
if (eattr == null) {
eattr = doc.createAttribute("encoding");
pi.attributes.setNamedItem(eattr);
}
eattr.value = "ISO-8859-1";
// And save document with new encoding.
doc.save("test2.xml");
It works fine for me (and not, output option in XSL did not help)