Google Answers Logo
View Question
Q: URGENT - trying to use wss4j to produce simple XML Signature in a SOAP Message ( No Answer,   0 Comments )
Subject: URGENT - trying to use wss4j to produce simple XML Signature in a SOAP Message
Category: Computers > Programming
Asked by: caixazh-ga
List Price: $50.00
Posted: 11 Oct 2006 17:36 PDT
Expires: 27 Oct 2006 05:10 PDT
Question ID: 772796
I have downloaded WSS4J version 1.5.0, I have examined the API
of class, and I have
tried to run the sample "". Try as I might,
I'm unable to produce a very simple signed XML (SOAP) document.

My question is, what is the bare minimum code and bare minimum files
that I need to extract out of the wss4j distribution in order to get
this working. I would like as an answer: the list of files; the code in 
simple class ready to compile, and the output from your test run.

Below is an example of the output I'm trying to coerce out of wss4j,
or something fairly close to it. The certificate will be in .crt or .jks

<?xml version="1.0" encoding="UTF-8"?>
            <wsse:Security SOAP-ENV:mustUnderstand="1"





                  <dsig:Signature Id="aSU1DKqecQST3NMW3cY6NmQ22"
                        <dsig:SignedInfo Id="theSignedInfo">
Algorithm="" />
Algorithm="" />
                              <dsig:Reference URI="#Body">
Algorithm="" />
Algorithm="" />

                        <dsig:SignatureValue Id="theSigId">






      <SOAP-ENV:Body wsu:Id="Body"

            <proprietary xmnls="urn:proprietary">
                    [ ... some proprietary data goes here ... ]

Clarification of Question by caixazh-ga on 11 Oct 2006 22:08 PDT
I'm going to temporarily reduce the price of this question as I am going
to post it on a competing site to see if I can get a quicker answer there.
If you are ready to answer it here, please post a comment and I'll increase
the price back to $75... thanks.

Request for Question Clarification by hummer-ga on 12 Oct 2006 05:59 PDT
Hi caixazh,

Try switching to Axis, here is the latest version.

1.4  April 22, 2006  Final Version 1.4

# Apache SOAP (note that Apache SOAP is considered obsolete; use Axis instead)
# Apache Axis is open source implementation of the JAX-RPC and SAAJ
specifications for sending and receiving SOAP messages. Always use the
latest version, as the Axis team very active is solving bugs.
# Apache SOAP was the first SOAP implementation. It is now obsolete.
Apache Axis surpassed Apache SOAP. It's better to use Apache Axis to
avail oneself of the latest features.

Are there any real web services available for testing?
Yes, check

How do I get started building a web service with Axis ? Show me some code!
 * Introduction to SOAP and Apache SOAP -
 * Article on JavaWorld -
 * Another article on JavaWorld -
 * Article on OnJava-
 * Many questions are answered in the Axis Wiki -
 * Enabling SOAPMonitor with Axis -

Please let me know if that helps!

Clarification of Question by caixazh-ga on 12 Oct 2006 06:15 PDT
hummer-ga: Sorry, that's not the same thing. Axis is only basic Web Services,
while WSS4J is for WS-Security.

Request for Question Clarification by hummer-ga on 12 Oct 2006 07:55 PDT
Oops, sorry caixazh, you are correct ofcourse. Perhaps this link will
help (particularly the "sample code")?

"Although the process may initially seem complex, a method such as the
main method shown above simplifies the process considerably, breaking
it down neatly into just a few steps: creating a SOAP envelope, and
then signing, encrypting, and adding username tokens to it. I urge you
to [download the sample code] for this article and experiment with the
process. The WSS4J framework provides the core methods you need to
meet the WS-Security specifications."

Good luck!

Clarification of Question by caixazh-ga on 12 Oct 2006 09:43 PDT
hi hummer-ga:
The sample code has a reference to a class ("AxisUtil") which does not
exist! I have searched everywhere and can't find it. It's not part of
Axis (despite what the package name implies), and it's not part of wss4j.

Request for Question Clarification by hummer-ga on 12 Oct 2006 09:56 PDT
How's this?


Clarification of Question by caixazh-ga on 12 Oct 2006 14:44 PDT
hummer-ga: Pretty close, but not quite there. You managed somehow to find
the source code for the project that AxisUtil is part of. But, it won't
compile, because it depends on the rest of the project. Please see if you
can find the official download site of the project that owns this piece of
code. Thanks for your help so far.

Request for Question Clarification by hummer-ga on 12 Oct 2006 15:59 PDT
Hi caixazh,

I'm glad to hear that you think that we've made some progress but I'm not so sure. 

Clicking on the little box, top-right, doesn't help?

Project Info

I'll work on this some more for you as soon as possible and get back
to you one way or the other -

Clarification of Question by caixazh-ga on 12 Oct 2006 20:17 PDT
hummer-ga: is some kind of repository and/or search engine;
it is an unofficial copy of code. An official project site would be something
like I did notice I can navigate to other files on
But that means I'll be hand-assembling my own unofficial version of an open-source
project, source file by source file. This is really undesireable and I would do
only as a last resort. This file must be part of some release of Axis. If
possible please find out which one. Thanks!

Request for Question Clarification by hummer-ga on 13 Oct 2006 05:57 PDT
Good morning, caixazh,

Three thoughts - 

1. Have you seen this post?

"I couldn't find AxisUtil in the package Is
there any other work around to convert the 'Documen' object to a 'Message'
object? I mean anything that replaces 'toSOAPMessage()' method of AxisUtil?"
Try this,
	public SOAPMessage toSOAPMessage(Document doc) throws Exception {
		Canonicalizer c14n =
		byte[] canonicalMessage = c14n.canonicalizeSubtree(doc);
		ByteArrayInputStream in = new ByteArrayInputStream(canonicalMessage);
		MessageFactory factory = MessageFactory.newInstance();
		return factory.createMessage(null, in);

2. AxisUtil is in axis.jar
   Axis.jar is in the lib/axis directory

"...this was my own class but you are right that there is also an AxisUtil
class in the axis.jar. The two classes are independent, so just give it
another name."

AXIS has several jars. The one I was after turned out to be:

3. Are you using Axis2?  

Securing SOAP Messages with WSS4J
-For Axis2 Version 1.0

Still trying,

Clarification of Question by caixazh-ga on 13 Oct 2006 06:34 PDT
hi hummer-ga: Item 1 on your last clarification looks promising, and I'll try
out that recommendation shortly. Item 2 is tantalizing but the "axis.jar" that
they keep talking about is nowhere to be found (at least, not one that contains
the class). Item 3 (using Axis2) is a possible 'Plan B' which I may try after #1,
however, it is undesireable because Axis2 is not supposed to be a requirement of
using wss4j, in fact, axis1.4 is included in the official download of wss4j.

Just so you know, I have reduced the price of the question, because of the amount
of work that I am having to do, and the time it is taking, has decreased the value
of the answer to me. When I offered the higer price, it was in the hopes of
getting something right on target, right away.

Request for Question Clarification by hummer-ga on 13 Oct 2006 06:59 PDT
Hi caixazh,

I understand that you were hoping for an easy and quick fix, that is
why I kept your question open (not locked) in the hopes that another
researcher could help you. Since noone has come forward, I've
continued to work on it but have already put in more hours than I care
to admit. To be fair, I did so with the knowledge that if I were able
to come up with a solution for you, I would would earn $90.00
(researchers get 75% of the posted price).

I'm sorry it didn't work out but hopefully someone will be able to help you.

Clarification of Question by caixazh-ga on 27 Oct 2006 05:10 PDT
Finally I was able to resolve this. Part of the answer lies in just getting rid
of the call to toSOAPMessage(). It apparently doesn't do anything useful, and it's
called only after the encryption anyway. The other thing to get the expected 
output was to set the 'DIRECT_BST' option.
There is no answer at this time.

There are no comments at this time.

Important Disclaimer: Answers and comments provided on Google Answers are general information, and are not intended to substitute for informed professional medical, psychiatric, psychological, tax, legal, investment, accounting, or other professional advice. Google does not endorse, and expressly disclaims liability for any product, manufacturer, distributor, service or service provider mentioned or any opinion expressed in answers or comments. Please read carefully the Google Answers Terms of Service.

If you feel that you have found inappropriate content, please let us know by emailing us at with the question ID listed above. Thank you.
Search Google Answers for
Google Answers  

Google Home - Answers FAQ - Terms of Service - Privacy Policy