Page 1 of 1

web service java client code

PostPosted:Sat Jan 30, 2010 10:44 am
by wangmj
D:\jdk1.6.0\bin>wsimport -d client -s client http://localhost:8080/OpenKM/OKMTest?wsdl
generate webservice client code .

test code.
Code: Select all

package es.git.openkm.ws.endpoint.okmtestclient;

public class OKMTestClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		OKMTestService tservice = new OKMTestService();

		OKMTest t = tservice.getOKMTestPort();

		t.simple("-----333333-------wangmj-----222222-------");
	}

}
Code: Select all
package es.git.openkm.ws.endpoint.client;


/**
 * @author wangmingjie
 *
 */
public class OKMAuthJavaClient {

	/**
	 * @param args
	 */
	public static void main(String[] args) throws Exception{
		
		OKMAuthService tservice = new OKMAuthService();

		OKMAuth t = tservice.getOKMAuthPort();
		String token = t.login("okmAdmin", "admin");
		System.out.println("token="+token);
//		String token="113401797164588045429421368826942 ";

		
		OKMDocumentService documentService = new OKMDocumentService();

		OKMDocument document = documentService.getOKMDocumentPort();

		Document d = document.getProperties(token, "/okm:root/gwt架构图.jpg");
		
		System.out.println(d.getAuthor()+"\n"+d.getPath()+"\n"+d.getUuid());

		OKMFolderService folderService = new OKMFolderService();

		OKMFolder folder = folderService.getOKMFolderPort();

		Folder f = folder.getProperties(token, "/okm:root/1市场研究");
		
		System.out.println(f.getAuthor()+"\n"+f.getPath()+"\n"+f.getUuid());
		
		
		OKMNotificationService notificationservice = new OKMNotificationService();

		OKMNotification n = notificationservice.getOKMNotificationPort();
		n.subscribe(token, "/okm:root/1市场研究");		
		n.unsubscribe(token, "/okm:root/1市场研究");
		
		OKMPropertyGroupService pgservice = new OKMPropertyGroupService();

		OKMPropertyGroup pg = pgservice.getOKMPropertyGroupPort();
		System.out.println(pg.getGroups(token, "/okm:root/1市场研究"));
		
		OKMSearchService searchservice = new OKMSearchService();

		OKMSearch s = searchservice.getOKMSearchPort();
		System.out.println(s.findByKeywords(token, "合同").value.size());		
		
		t.logout(token);
	}

}


Re: web service java client code

PostPosted:Sat Jan 30, 2010 1:46 pm
by jllort
Thanks for your post. It's interesting.

If you're interested in colaborate with us in some way, documentation, etc... please tell us using our contact form. We're finishing wiki, this weeks we'll publish, but we'd like to get colaboration from community.

Re: web service java client code

PostPosted:Sat Jan 30, 2010 1:54 pm
by wangmj
thanks for your advice.
I'am insteresting. But I'am afraid Ihave no enough free time.
I'am glad to share code and doucment.

Re: web service java client code

PostPosted:Sat Jan 30, 2010 2:52 pm
by jllort
Thanks for your support. Hope this week we'll finally share wiki.

Re: web service java client code

PostPosted:Sun Jan 31, 2010 12:58 am
by wangmj
That's great! I hopeit will be better and better in the future.

Re: web service java client code

PostPosted:Tue May 04, 2010 4:52 pm
by massifr
USEFUL TIP FOR LINUX USERS

I had some problems running the java client code on linux (debian testing): I was getting a "no route to host", even with OKMTestService.

Java on linux (or at least on Debian, the distro I'm using) has a bug related to IPv4-IPv6.
You can find a good description here:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=560142

To make the client code by wangmj work, the solution was adding
-Djava.net.preferIPv4Stack=true
to JAVA_OPTS variable in "bin/run.sh" in my OpenKM installation.

I'm posting this to save time for others using OpenKM on (GNU/Debian) linux.

Re: web service java client code

PostPosted:Thu May 06, 2010 11:18 am
by pavila
I think this is a bug in OpenJDK Java implementation, not for SunJDK.

Re: web service java client code

PostPosted:Thu May 06, 2010 2:40 pm
by massifr
Unfortunately no, I don't think so (as long as we're talking about java in debian testing).

Please read message #25 at the link I've posted in the previous message:
Not sure which JRE you use, but it affects both OpenJDK and Sun.
The package I've installed is "sun-java6-jre" and not "openjdk-6-jre".
The problem is related to IPv6 being the default for Debian, and Java not being able to cope with that.

Message #35 explains why:
it [is] not possible to use the ::ffff::ip style mapped addresses anymore [and] this is the default of the java virtual machine
The same message prompts to put
Code: Select all
net.ipv6.bindv6only = 1
in "/etc/sysctl.d/bindv6only.conf".

That was enough to make the eclipse debugger work, but the same did not work for the java ws client for OpenKM.
And the solution was to add "-Djava.net.preferIPv4Stack=true" to JAVA_OPTS in "bin/run.sh", in my OpenKM(jboss) installation.