没有任何数据可供显示
开源项目社区 | 当前位置 : |
|
www.trustie.net/open_source_projects | 主页 > 开源项目社区 > netflexity-amazonws-simpledb |
netflexity-amazonws-simpledb
|
0 | 0 | 6 |
贡献者 | 讨论 | 代码提交 |
Another Amazon AWS SimpleDB wrapper?Yes, this is yet another wrapper for Amazon SimpleDB. First of all, despite the REST hype, I still see SOAP + WS standards as a much more mature platform for enterprise development. Second, there needs to be an authority that keeps APIs in synch with latest Amazon AWS WSDLs. I would like to utilize my development team to help become such an authority, hopefully with your help. And by help I mean user community. Please use this API if you like it or not ;)
Since all the projects we are involved in make use of Spring framework, we decided to make heavy use of it here as well. We are actively using Apache ServiceMix and Progress Fuse OSGi-containers, that is why the project is using Maven with PAX to create OSGi bundles. If you are not using OSGi, you can treat this library as a regular jar. We love Apache CXF (untill we ran into issues with EC2 WSDL and wsdl2java :)) and use it as to help out with SOAP stuff.
UsageAt first, check out our unit tests to get the best idea about SimpleDB client. The API is very simple to use once you configure everything.
// Get all domains.
SimpleDB simpledb = (SimpleDB) context.getBean("simpleDB");
Iterator> domainsIterator;
try {
domainsIterator = simpledb.getDomains();
while (domainsIterator.hasNext()) {
List domains = (List) domainsIterator.next();
for (Domain domain : domains) {
System.out.println(domain.getName());
}
}
} catch (SimpleDBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
// Issue select.
Iterator> itemIterator;
try {
itemIterator = simpledb.select("select * from Domain where LN='Party' and city like 'Buck%'");
while (itemIterator.hasNext()) {
List items = (List) itemIterator.next();
for (Item item : items) {
System.out.print(item.getIdentifier());
List attributes = item.getAttributes();
for (ItemAttribute attribute : attributes) {
System.out.print(attribute.getName() + "=" + attribute.getValue() + " , ");
System.out.println();
}
}
}
} catch (SimpleDBException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}Spring Context
aws.propertiesamazonaws.simpledb.url=https\://sdb.amazonaws.com
keystore.alias=REPLACEME
signaturePropFile=clientKeystore.properties
encryptionPropFile=clientKeystore.properties
signatureParts={Element}{http\://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd}Timestamp;{Element}{http\://schemas.xmlsoap.org/soap/envelope/}BodyclientKeystore.propertiesorg.apache.ws.security.crypto.provider=org.apache.ws.security.components.crypto.Merlin
org.apache.ws.security.crypto.merlin.keystore.type=jks
org.apache.ws.security.crypto.merlin.keystore.password=REPLACEME
org.apache.ws.security.crypto.merlin.keystore.alias=REPLACEME
org.apache.ws.security.crypto.merlin.file=awskeystore.jksawskeystore.jksThis is your java keystore file. Obviously, you can rename it, just make sure you update clientKeystore.properties accordingly. This is the most complex step of the entire setup. Unlike REST, SOAP needs a keystore file, composed of a pair: your Amazon x509 certificate (xxx.pem) and your Amazon private key. Unfortunatelly, java keygen utility cannot create a keystore using exising certificate + private key. To create, the keystore, please follow these instructions. In couple of days we will provide a utility that will simplify things.
http://www.agentbob.info/agentbob/79-AB.html Contains Instructions http://www.slproweb.com/products/Win32OpenSSL.html Contains Windows OpenSSL install instructions.
Here is what had to do:
openssl pkcs8 -topk8 -nocrypt -in pk-YOURPRIVATEKEY.pem -inform PEM -out C:\Users\netflexity\Documents\pk-YOURPRIVATEKEY.der -outform DER openssl x509 -in cert-YOURX509.pem -inform PEM -out cert-YOURX509.der -outform DER java ImportKey C:\\Users\\xx\\xx\\projects\\workspace-fuse\\netflexitysolutions.amazonws.sdb\\src\\test\\resources\\pk-YOURPRIVATEKEY.der C:\\Users\\netflexity\\development\\projects\\workspace-fuse\\netflexitysolutions.amazonws.sdb\\src\\test\\resources\\cert-YOURX509.cer YOUR-KEYSTORE-ALIAS