Trouble adding SOAP Header elements when faults occur

2007-05-17 Thread Desmond Whewell \(CV/ETL\)
I am trying to build my first web-service using Axis2 (vers 1.2) and I
am having trouble with the SOAP Header when faults occur. I have:

@ generated the Java code from the WSDL, with xmlbeans bindings, 

@ implemented the business logic in the generated
MyServiceMessageReceiverInOut, shown in outline below

@ successfully invoked the no-fault case for the service.

If MySkeleton throws a MyFaultException, it is caught and wrapped in an
AxisFault. As a result, the client gets a SOAP Body with an embedded
SOAP Fault, so that's good.

The bit I can't figure out is what I need to do when I have a problem
with one of the SOAP headers and I want to put a particular SOAP header
in the SOAP envelope carrying the SOAP Fault back to the client. I have
searched the list and the Axis2 documentation with no luck.



Cheers, Des

The generated MyServiceMessageReceiverInOut looks roughly like this
structure
-
public void
invokeBusinessLogic(org.apache.axis2.context.MessageContext msgContext,
 
org.apache.axis2.context.MessageContext newMsgContext)
throws org.apache.axis2.AxisFault {

try {

// get the implementation class for the Web Service
...
// prepare the out Envelop
org.apache.axiom.soap.SOAPEnvelope envelope = null;
// Find the axisOperation that has been set by the Dispatch
phase.
...
if (op.getName() != null
 (methodName =
org.apache.axis2.util.JavaUtils.xmlNameToJava(op.getName().getLocalPart(
))) != null) {

if (MyOperation.equals(methodName)) {

// Unwrap header
SOAPHeader sOAPHeader = .
// Check the header and possibley throw
MyServiceFaultException 
...
// Unwrap body
...
// Invoke the logic
result = skel.MySkeleton(body, header); // This can
throw MyServiceFaultException 
// Create new envelope
envelope =
getSOAPFactory(msgContext).getDefaultEnvelope();
// Add the body
envelope.getBody().addChild(toOM(result, false));
// Replace the header
envelope.getHeader().detach();
envelope.getBody().insertSiblingBefore(sOAPHeader);
}
   
newMsgContext.setEnvelope(envelope);
}
} catch (MyFaultException e) {
// HOW DO I GET SOME HEADERS IN THE SOAP response???
org.apache.axis2.AxisFault f = createAxisFault(e);
f.setDetail(toOM(e.getFaultMessage(), false));
throw f;
}

catch (Exception e) {
throw org.apache.axis2.AxisFault.makeFault(e);
}
}
-


-
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]



Re: intermediary adding soap header element breaking signature verification

2006-08-31 Thread Xinjun Chen

Hi akkachotu,

This is very weird. Have you managed to solve the problem?
Since your signed info does not contain the whole header, it seems to be ok.
Have you tried to append the intermediary header after the
wsse:Security header?


Regards,

Xinjun

On 8/13/06, akkachotu [EMAIL PROTECTED] wrote:

Here is the soap message after it is signed using AXIS 1.4, WSS4J 1.5:

?xml version=1.0 encoding=UTF-8?
soapenv:Envelope
   xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/;
   
xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;
   
xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd;
   xmlns:xsd=http://www.w3.org/2001/XMLSchema;
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   soapenv:Header
   wsse:Security
   
xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;
   wsse:BinarySecurityToken
   
ValueType=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3;
   
elementEncoding=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary;
   wsu:Id=binarytoken
   
123MIIB5jCCAU8CBEQyyzkwDQYJKoZIhvcNAQEFBQAwOjELMAkGA1UEBhMCVVMxDTALBgNVBAoTBEFN
   /wsse:BinarySecurityToken
   ds:Signature 
xmlns:ds=http://www.w3.org/2000/09/xmldsig#;
   ds:SignedInfo
   ds:CanonicalizationMethod
Algorithm=http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments/
   ds:SignatureMethod
Algorithm=http://www.w3.org/2000/09/xmldsig#rsa-sha1/
   ds:Reference URI=#Body
   ds:Transforms
   ds:Transform
Algorithm=http://www.w3.org/TR/2001/REC-xml-c14n-20010315/
   /ds:Transforms
   ds:DigestMethod 
Algorithm=http://www.w3.org/2000/09/xmldsig#sha1/
   
ds:DigestValueEwE9/d/aFPCf7CpqoKdbHSrhNN0=/ds:DigestValue
   /ds:Reference
   /ds:SignedInfo
   ds:SignatureValue
   
lCIbgyn1nzA/7Y2tAVQ+WuVTX/WoOKE0Xv1dOTDBJ+BIY1w6ulg17apQ2taLmfDHGEFtLOCO
   
TKdvhev5CMNCvmsbZQVv5Mli+ttFSpumNf8yOkf0BwDCcSyTVbuiotJJXOFVGRTXB5oxIv8q
   UqY5QO3lZkO790OmUyBlpgWaWAE=
   /ds:SignatureValue
   ds:KeyInfo
   wsse:SecurityTokenReference
   wsse:Reference
   URI=#binarytoken
   
ValueType=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3/
   /wsse:SecurityTokenReference
   /ds:KeyInfo
   /ds:Signature
   /wsse:Security
   /soapenv:Header
   soapenv:Body Id=Body
   getHolidays xmlns=http://transfer.as.com;
   request
   ns3:regionID xmlns:ns3=http://shr.ws.com; 
xsi:nil=true/
   cardNumber/cardNumber
   /request
   /getHolidays
   /soapenv:Body
/soapenv:Envelope





Say if I use AXIS + WSS4J on bother sender side and receiver side and
say if an intermediary adds an element

intermediary:ProxyID
wsu:Id=67670d88d3e0-0e2c-489d-a682-da14b8fec3d7/intermediary:ProxyID


to the soap header and after adding this element the complete soap
message looks like below:

?xml version=1.0 encoding=UTF-8?
soapenv:Envelope
   xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/;
   
xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;
   
xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd;
   xmlns:xsd=http://www.w3.org/2001/XMLSchema;
   xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
   
xmlns:intermediary=http://www.intermediary.com/proxy/2424.2424s;
   soapenv:Header
   intermediary:ProxyID
wsu:Id=67670d88d3e0-0e2c-489d-a682-da14b8fec3d7/intermediary:ProxyID
   wsse:Security
   

intermediary adding soap header element breaking signature verification

2006-08-12 Thread akkachotu

Here is the soap message after it is signed using AXIS 1.4, WSS4J 1.5:

?xml version=1.0 encoding=UTF-8?
soapenv:Envelope
xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/;

xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;

xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd;
xmlns:xsd=http://www.w3.org/2001/XMLSchema;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;
soapenv:Header
wsse:Security

xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;
wsse:BinarySecurityToken

ValueType=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3;

elementEncoding=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary;
wsu:Id=binarytoken

123MIIB5jCCAU8CBEQyyzkwDQYJKoZIhvcNAQEFBQAwOjELMAkGA1UEBhMCVVMxDTALBgNVBAoTBEFN
/wsse:BinarySecurityToken
ds:Signature 
xmlns:ds=http://www.w3.org/2000/09/xmldsig#;
ds:SignedInfo
ds:CanonicalizationMethod
Algorithm=http://www.w3.org/TR/2001/REC-xml-c14n-20010315#WithComments/
ds:SignatureMethod
Algorithm=http://www.w3.org/2000/09/xmldsig#rsa-sha1/
ds:Reference URI=#Body
ds:Transforms
ds:Transform
Algorithm=http://www.w3.org/TR/2001/REC-xml-c14n-20010315/
/ds:Transforms
ds:DigestMethod 
Algorithm=http://www.w3.org/2000/09/xmldsig#sha1/

ds:DigestValueEwE9/d/aFPCf7CpqoKdbHSrhNN0=/ds:DigestValue
/ds:Reference
/ds:SignedInfo
ds:SignatureValue

lCIbgyn1nzA/7Y2tAVQ+WuVTX/WoOKE0Xv1dOTDBJ+BIY1w6ulg17apQ2taLmfDHGEFtLOCO

TKdvhev5CMNCvmsbZQVv5Mli+ttFSpumNf8yOkf0BwDCcSyTVbuiotJJXOFVGRTXB5oxIv8q
UqY5QO3lZkO790OmUyBlpgWaWAE=
/ds:SignatureValue
ds:KeyInfo
wsse:SecurityTokenReference
wsse:Reference
URI=#binarytoken

ValueType=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-x509-token-profile-1.0#X509v3/
/wsse:SecurityTokenReference
/ds:KeyInfo
/ds:Signature
/wsse:Security
/soapenv:Header
soapenv:Body Id=Body
getHolidays xmlns=http://transfer.as.com;
request
ns3:regionID xmlns:ns3=http://shr.ws.com; 
xsi:nil=true/
cardNumber/cardNumber
/request
/getHolidays
/soapenv:Body
/soapenv:Envelope





Say if I use AXIS + WSS4J on bother sender side and receiver side and
say if an intermediary adds an element

intermediary:ProxyID
wsu:Id=67670d88d3e0-0e2c-489d-a682-da14b8fec3d7/intermediary:ProxyID


to the soap header and after adding this element the complete soap
message looks like below:

?xml version=1.0 encoding=UTF-8?
soapenv:Envelope
xmlns:soapenv=http://schemas.xmlsoap.org/soap/envelope/;

xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;

xmlns:wsu=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-utility-1.0.xsd;
xmlns:xsd=http://www.w3.org/2001/XMLSchema;
xmlns:xsi=http://www.w3.org/2001/XMLSchema-instance;

xmlns:intermediary=http://www.intermediary.com/proxy/2424.2424s;
soapenv:Header
intermediary:ProxyID
wsu:Id=67670d88d3e0-0e2c-489d-a682-da14b8fec3d7/intermediary:ProxyID
wsse:Security

xmlns:wsse=http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-wssecurity-secext-1.0.xsd;
wsse:BinarySecurityToken


adding soap header

2005-05-05 Thread Plorks mail

Hi all
I've created a method that adds a soap header
I'm not sure what to put here - new SOAPHeaderElement (http://)
Also i'm testing this using eclipse and the wtp tool.  But can't see the
header being created
Can anyone suggest how i test this to see the header?
Do i have to use something like MessageContext messagecontext =
MessageContext.getCurrentContext(); ???
Thanks for any help
  public static String addSOAPHeader(String token) throws Exception
   {
 Service service = new Service();
 Call call = (Call)service.createCall();
 SOAPHeaderElement tokenHeader = new
SOAPHeaderElement(http://taxservice,TokenHeader;);
 tokenHeader.setObjectValue(token);
 call.addHeader(tokenHeader);
   return token;
   }
_
Be the first to hear what's new at MSN - sign up to our free newsletters! 
http://www.msn.co.uk/newsletters