Hi Werner,

I am using Axis 1.1 and the sample programs coming with Axis are working
fine for me. In fact, I am able to send and receive attachements in case of
anonymous and simple authentication (username and password).

I got stuck only when I try to sign the attachments. I have both axis.jar
and activation.jar in my classpath.

Please do suggest me any possible solution.

Regards,
Ayyappan Gandhirajan

-----Original Message-----
From: Dittmann Werner [mailto:[EMAIL PROTECTED]
Sent: Friday, December 05, 2003 12:27 PM
To: '[EMAIL PROTECTED]'
Subject: AW: signing soap attachment


Hi,

seems that your program didn't use Axis with attachment
enabled and it looks like you were using an older
version of Axis - newver Versions throw an IOException
if attachements are not supported in Axis.

You need to build Axis in the proper way to support
attachements (activation.jar, mail.ja must be available).

Also note that it is quite tricky to sign  Axis message
that has attachements because Axis modifes the content
of the request just before it puts it on the wire.

pls refer to the WSS4J project at Sourceforge, there
we solved that problem already.

Regards,
Werner

> -----Urspr�ngliche Nachricht-----
> Von: GANDHIRAJAN,AYYAPPAN (HP-India,ex2) 
> [mailto:[EMAIL PROTECTED] 
> Gesendet: Donnerstag, 4. Dezember 2003 09:23
> An: '[EMAIL PROTECTED]'
> Betreff: signing soap attachment
> 
> 
> Hi folks,
> 
> I have been facing a problem while using signed 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;
>       }
> }
> 

Reply via email to