40 likes | 194 Views
SAAJ 1.2. Send and receive binary Web services content using SAAJ 1.2 In his latest Web Services column, Frank Sommers shows how the SOAP with Attachments API for Java (SAAJ) 1.2 supports creating, parsing, and sending SOAP messages with binary content .
E N D
SAAJ 1.2 • Send and receive binary Web services content using SAAJ 1.2 • In his latest Web Services column, Frank Sommers shows how the SOAP with Attachments API for Java (SAAJ) 1.2 supports creating, parsing, and sending SOAP messages with binary content. • http://www.javaworld.com/javaworld/jw-09-2003/jw-0912-webservices.html • Create and send a SOAP message with attachments SAAJ lets you create and edit any part of a SOAP message, including attachments. Most of SAAJ is based on abstract classes and interfaces such that each provider can implement SAAJ in its own products. Sun Microsystems' reference implementation comes with the Java Web Services Developer Pack (JWSDP). • http://www.javaworld.com/javaworld/jw-09-2003/jw-0912-webservices-p2.html ACS WG - Data transport with SOAP message
SAAJ References • SOAP with Attachments API for Java (SAAJ) 1.2 • The SAAJ API 1.2 conforms to the SOAP 1.1 specification and the SOAP with Attachments specification. This means that you can use SAAJ to create and send SOAP message with or without attachments. • http://java.sun.com/developer/technicalArticles/WebServices/soa2/JavaTechs.html#saajdesc • SAAJ Documentation http://java.sun.com/webservices/saaj/docs.html ACS WG - Data transport with SOAP message
import javax.xml.soap.*; // Get a connection SOAPConnection conn; SOAPConnectionFactory scf = SOAPConnectionFactory.newInstance(); conn = scf.createConnection(); // Create a message MessageFactory mf = MessageFactory.newInstance(); SOAPMessage msg = mf.createMessage(); // Add content to the message SOAPPart sp = msg.getSOAPPart() ; SOAPEnvelope envelope = sp.getEnvelope(); SOAPHeader hdr = envelope.getHeader(); SOAPBody bdy = envelope.getBody(); SOAPBodyElement sbe = bdy.addBodyElement (envelope.createName("GetBookDetails", "bp", "http://www.bookprovider.com")); sbe.addChildElement( envelope.createName( "searchCriteria", "bp", "http://www.bookprovider.com" )).addTextNode("author"); sbe.addChildElement( envelope.createName( "searchValue", "bp", "http://www.bookprovider.com" )).addTextNode("Hemingway"); // Add attachment AttachmentPart ap = msg.createAttachmentPart(); byte[] jpegData = "..." ap.setContent(new ByteArrayInputStream(jpegData), "image/jpeg") msg.addAttachmentPart(ap); // Close the connection connection.close(); SOAP with Attachments API for Java (SAAJ) 1.2 http://java.sun.com/developer/technicalArticles/WebServices/soa2/JavaTechs.html#saajdesc ACS WG - Data transport with SOAP message
Java WSDP • Java Web Services Developer Pack 1.6 (Java WSDP 1.6) supports SwA API • Tutorial ( http://java.sun.com/webservices/docs/1.6/tutorial/doc/index.html ) • Adding Attachment ( http://java.sun.com/webservices/docs/1.1/tutorial/doc/JAXM5.html#wp64131 ) • Soap With Attachments Sample Application • The SwA Interop Scenarios • SwA Sample Configuration Files • Running the SwA Sample Application ACS WG - Data transport with SOAP message