• web service java client code

  • Do you want to create a native client or integrate with third party applications: webservices are the solution.
Do you want to create a native client or integrate with third party applications: webservices are the solution.
Forum rules: Please, before asking something see the documentation wiki or use the search feature of the forum. And remember we don't have a crystal ball or mental readers, so if you post about an issue tell us which OpenKM are you using and also the browser and operating system version. For more info read How to Report Bugs Effectively.
 #3939  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);
	}

}

Attachments
(48.86 KiB) Downloaded 637 times
Last edited by wangmj on Sat Jan 30, 2010 1:46 pm, edited 1 time in total.
 #3942  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.
 #3943  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.
Last edited by wangmj on Sun Jan 31, 2010 12:56 am, edited 1 time in total.
 #3944  by jllort
 
Thanks for your support. Hope this week we'll finally share wiki.
 #4850  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.
 #4891  by pavila
 
I think this is a bug in OpenJDK Java implementation, not for SunJDK.
 #4896  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.

About Us

OpenKM is part of the management software. A management software is a program that facilitates the accomplishment of administrative tasks. OpenKM is a document management system that allows you to manage business content and workflow in a more efficient way. Document managers guarantee data protection by establishing information security for business content.