Wednesday, January 11, 2012

JAXB

old pieces of code:

public static com.harrods.hrc.ws.client.mapping.getDetails.Member parseGetDetailsResult(String resultFromWS)
throws JAXBException
{
if ( resultFromWS == null ) return null;
resultFromWS = "" + resultFromWS + "";
JAXBContext jaxbContext = JAXBContext.newInstance( "com.harrods.hrc.ws.client.mapping.getDetails" );
ByteArrayInputStream input = new ByteArrayInputStream (resultFromWS.getBytes());
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
com.harrods.hrc.ws.client.mapping.getDetails.Member getDetailsResult =
(com.harrods.hrc.ws.client.mapping.getDetails.Member)
unmarshaller.unmarshal(input);
return getDetailsResult;
}

//another impl
if ( memberAsString == null ) throw new Exception("member is null");
memberAsString = "" + memberAsString + "";

JAXBContext jaxbContext = JAXBContext.newInstance( com.harrods.hrc.ws.client.mapping.enrol.response.Member.class );

Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();
StringReader stringReader = new StringReader(memberAsString);
return
(com.harrods.hrc.ws.client.mapping.enrol.response.Member)
unmarshaller.unmarshal(stringReader);


//
JAXBContext jaxbContext = JAXBContext.newInstance(
com.harrods.hrc.ws.client.mapping.enrol.request.RequestData.class
);

Marshaller marshaller = jaxbContext.createMarshaller();
marshaller.setProperty(Marshaller.JAXB_FORMATTED_OUTPUT, true);
marshaller.setProperty(Marshaller.JAXB_ENCODING , "UTF-8");
//setProperty(Marshaller.JAXB_FRAGMENT, Boolean.TRUE);

StringWriter stringWriter = new StringWriter();
marshaller.marshal(enrolRequestData, stringWriter);
return stringWriter.toString();


//
EndpointReference targetEPR = new EndpointReference(
wsEndpoint
);

Options options = new Options();
//GRIPS MX Web Service endpoint
options.setTo(targetEPR);
// Increase the time out when sending large attachments
options.setTimeOutInMilliSeconds(timeout);
options.setTo(targetEPR);
//GRIPS MX Web Service IssueCheque operation
options.setAction("http://jetsystems.com/GRIPSMX/IssueCheque");

ServiceClient sender = new ServiceClient(); //default context
sender.setOptions(options);
OperationClient mepClient = sender
.createClient(ServiceClient.ANON_OUT_IN_OP);

MessageContext messageContext = new MessageContext();

SOAPFactory soapFactory = OMAbstractFactory.getSOAP11Factory();
SOAPEnvelope soapEnvelope = soapFactory.getDefaultEnvelope();

SAXOMBuilder saxomBuilder = new SAXOMBuilder();
JAXBContext jaxbContext =
JAXBContext.newInstance("com.jetsystems.gripsmx.ws");
Marshaller marshaller = jaxbContext.createMarshaller();

marshaller.setProperty("com.sun.xml.bind.namespacePrefixMapper",
new NamespacePrefixMapperImpl());

com.jetsystems.gripsmx.ws.ChequeRequest chequeRequest =
generateChequeRequest(
country,
shop,
tillId,
operatorId,
posBasket,
dataEntry,
basketWsProperties
);
marshaller.marshal(chequeRequest, saxomBuilder);
OMElement issueChequeRequest = saxomBuilder.getRootElement();
issueChequeRequest.setLocalName("issueChequeRequest");

soapEnvelope.getBody().addChild(issueChequeRequest);

messageContext.setEnvelope(soapEnvelope);

mepClient.addMessageContext(messageContext);
mepClient.execute(true);
MessageContext response = mepClient
.getMessageContext(WSDLConstants.MESSAGE_LABEL_IN_VALUE);
SOAPBody soapBody = response.getEnvelope().getBody();

//try to unmarshal the response
Unmarshaller unmarshaller = jaxbContext.createUnmarshaller();

JAXBElement jaxbElement =
(JAXBElement)unmarshaller.unmarshal(
soapBody.getFirstElement().getXMLStreamReader());
com.jetsystems.gripsmx.ws.Cheque cheque =
(com.jetsystems.gripsmx.ws.Cheque)
jaxbElement.getValue();

logger.debug("issued cheque = " + cheque);
return cheque;

//

Monday, January 9, 2012

BPEL

http://www.theserverside.com/news/1364554/BPEL-and-Java

Saturday, January 7, 2012

Java Networking and Cryptography

books:
1)

Beginning Cryptography with Java

David Hook
Wiley Publishing, Inc.
recommended by bouncycastle
2) Esmond Pitt - Fundamental Networking in Java, Springer 2006 - great book

Qarbon ViewletBuilder

http://www.qarbon.com/presentation-software/viewletbuilder/

maverick plugin

"a Model-View-Controller (aka "Model 2") framework for web publishing using Java and J2EE" :
http://mav.sourceforge.net/

Sunday, January 1, 2012

GUI design guidelines from Year 2000

Constantine & Lockwood, Ltd
http://foruse.com

From Abstraction to Realization:
Canonical Abstract Prototypes for User Interface Design

http://www.foruse.com/articles/canonical.pdf