Return-Path: Delivered-To: apmail-ws-axis-user-archive@www.apache.org Received: (qmail 26141 invoked from network); 4 Dec 2003 11:51:02 -0000 Received: from daedalus.apache.org (HELO mail.apache.org) (208.185.179.12) by minotaur-2.apache.org with SMTP; 4 Dec 2003 11:51:02 -0000 Received: (qmail 85518 invoked by uid 500); 4 Dec 2003 11:50:46 -0000 Delivered-To: apmail-ws-axis-user-archive@ws.apache.org Received: (qmail 85486 invoked by uid 500); 4 Dec 2003 11:50:46 -0000 Mailing-List: contact axis-user-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-user@ws.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-user@ws.apache.org Delivered-To: moderator for axis-user@ws.apache.org Received: (qmail 38139 invoked from network); 4 Dec 2003 07:01:16 -0000 Message-ID: From: "GANDHIRAJAN,AYYAPPAN (HP-India,ex2)" To: "'axis-user@ws.apache.org'" Cc: "Ayyappan (SES-India) (E-mail)" Subject: Problem with attachment Date: Thu, 4 Dec 2003 12:31:16 +0530 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2657.72) Content-Type: text/plain; charset="iso-8859-1" X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N X-Spam-Rating: minotaur-2.apache.org 1.6.2 0/1000/N Hi folks, I have been facing a problem while using soap RPC attachment. Let me summarize as follows: 1) Create a header 2) Create a body that contains information about an operation. The operation or method takes javax.activation.DataHandler as an input 3) Create envelope by combining header and body 4) Create a document from the envelope [Later, I will sign this document and send the signed XML for invoking secured webservices] I am able to succeed until step3. While I try to create the document object at step 4, I am getting DataHandler serializer error. The error description is as follows: Exception in thread "main" java.lang.NullPointerException at org.apache.axis.encoding.ser.JAFDataHandlerSerializer.serialize(JAFDa taHandlerSerializer.java:96) at org.apache.axis.encoding.SerializationContextImpl.serializeActual(Ser ializationContextImpl.java:1247) at org.apache.axis.encoding.SerializationContextImpl.serialize(Serializa tionContextImpl.java:787) at org.apache.axis.message.RPCParam.serialize(RPCParam.java:225) at tests.java.com.hp.mesac.security.client.Test.serialize(Unknown Source ) at tests.java.com.hp.mesac.security.client.Test.getEnvelopeAsDocument(Un known Source) at tests.java.com.hp.mesac.security.client.Test.main(Unknown Source) The java source code is also given below. can some one help how I can resolve it? Thanks in advance. Regards, Ayyappan Gandhirajan ---------------------------------------------------------------------------- ------------------------------------------------------------- public class Test1{ private static String SOAPSECNS = "http://schemas.xmlsoap.org/soap/security/2000-12"; private static String SOAPSECprefix = "SOAP-SEC"; public static void main(String[] args) throws Exception{ Test1 test = new Test1(); String namespace = "http://tempuri.org"; String methodName = "echo"; System.out.println("File exists - "+new File("test.txt").exists()); DataHandler dh = new DataHandler(new File("test.txt").toURL()); System.out.println("File Name - "+dh.getName()); Object[] paramValues = {dh}; Document doc = test.getEnvelopeAsDocument(namespace, methodName, paramValues); System.out.println("Document - "+doc); } public Document getEnvelopeAsDocument(String namespace, String methodName, Object[] paramValues) throws Exception{ System.out.println("Creating envelope...."); //envelope SOAPEnvelope env = new SOAPEnvelope(); env.addMapping(new Mapping(SOAPSECNS, SOAPSECprefix)); env.addAttribute(Constants.URI_SOAP11_ENV, "actor", "http://tempuri.org"); env.addAttribute(Constants.URI_SOAP11_ENV, "mustUnderstand", "1"); System.out.println("Creating envelope.header...."); //Header SOAPHeaderElement header = new SOAPHeaderElement(XMLUtils.StringToElement(SOAPSECNS, "Signature", "")); env.addHeader(header); System.out.println("Creating envelope.body...."); RPCElement bodyInfo = new RPCElement(namespace, methodName, paramValues); env.addBodyElement(bodyInfo); System.out.println(""); System.out.println("Envelope is ready. ---ENVELOPE STARTS----"); System.out.println("Is envelope NULL? - "+(env == null)); System.out.println(env); System.out.println("Envelope is ready. ---ENVELOPE ENDS----"); System.out.println(""); //Get as doc System.out.println("Trying to create document...."); Document doc = getSOAPEnvelopeAsDocument(env); System.out.println("Document creation success"); return doc; } private Document getSOAPEnvelopeAsDocument(SOAPEnvelope env) throws Exception{ MessageContext msgContext = null; StringWriter writer = new StringWriter(); SerializationContext serializeContext = new SerializationContextImpl(writer, msgContext); env.output(serializeContext); writer.close(); Reader reader = new StringReader(writer.getBuffer().toString()); Document doc = XMLUtils.newDocument(new InputSource(reader)); if (doc == null){ throw new Exception(Messages.getMessage("noDoc00", writer.getBuffer().toString())); } return doc; } }