Disable InclusiveNamespaces in axis/rampart client
Asked Answered
C

1

17

I'm connecting to a webservice with axis/rampart and was told to remove the InclusiveNamespaces as the prefixList was "" which is not allowed. How do I do that?

The part looks like

<ds:SignedInfo>
    <ds:CanonicalizationMethod Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">
        <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="wsa soapenv" />
    </ds:CanonicalizationMethod>
    <ds:SignatureMethod Algorithm="http://www.w3.org/2000/09/xmldsig#rsa-sha1" />
    <ds:Reference URI="#Id-289005241">
        <ds:Transforms>
            <ds:Transform Algorithm="http://www.w3.org/2001/10/xml-exc-c14n#">              
                <ec:InclusiveNamespaces xmlns:ec="http://www.w3.org/2001/10/xml-exc-c14n#" PrefixList="" />
            </ds:Transform>
        </ds:Transforms>
        <ds:DigestMethod Algorithm="http://www.w3.org/2000/09/xmldsig#sha1" />                          
        <ds:DigestValue>bla bla bla=</ds:DigestValue>
    </ds:Reference>
</ds:SignedInfo>

Is it possible to configure axis/rampart to not print the inclusivenamespace when it's empty?

I'm using axis/rampart 1.6.2 and connecting to a .NET service

Any ideas how to archive this? Or how do I make it render a non empty prefixList ?

Crafty answered 2/9, 2013 at 23:13 Comment(0)
F
1

You have to add a custom handler to filter the unwanted xml tag.

custom handler:

    package com.perre;

        public class InclusiveNamespacesFilter extends AbstractHandler {

        public InvocationResponse invoke(MessageContext ctx) throws AxisFault {

            SOAPEnvelope msgEnvelope = ctx.getEnvelope();
            SOAPHeader msgHeader = msgEnvelope.getHeader();

            Iterator theDescendants = msgHeader.getDescendants(true);
            while(theDescendants.hasNext()){

                Object o = theDescendants.next();

                 //here, add your code to traverse DOM and get the node to filter 
                 //...
                 Node aNode = ele.getElementsByTagName("ec:InclusiveNamespacesFilter").item(0);
                 if(aNode != null){
                            ele.removeChild(aNode);
                 }
            }
            return InvocationResponse.CONTINUE;
        }

edit your axis2.xml and declare the handler:

 <phase name="PostSecurity">
      <handler name="FilterHandler" class="com.perre.InclusiveNamespacesFilter"/> 
 </phase>
  • You should be ready to go. Find more reading about custom handlers here.
Faretheewell answered 17/2, 2014 at 23:1 Comment(1)
Thanks, I solved it by using non WSI complaint mode. I will give this a try when I have time. Thank youCrafty

© 2022 - 2024 — McMap. All rights reserved.