17

axis/rampart を使用して Web サービスに接続していますが、許可されていない prefixList が "" であるため、InclusiveNamespaces を削除するように指示されました。それ、どうやったら出来るの?

部分は次のようになります

<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>

空の場合に包含名前空間を出力しないように軸/城壁を構成することは可能ですか?

axis/rampart 1.6.2 を使用し、.NET サービスに接続しています

これをアーカイブする方法はありますか?または、空でない prefixList をレンダリングするにはどうすればよいですか?

4

1 に答える 1

1

不要な xml タグをフィルター処理するには、カスタム ハンドラーを追加する必要があります。

カスタム ハンドラ:

    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;
        }

axis2.xml を編集し、ハンドラーを宣言します。

 <phase name="PostSecurity">
      <handler name="FilterHandler" class="com.perre.InclusiveNamespacesFilter"/> 
 </phase>
  • あなたは行く準備ができているはずです。カスタム ハンドラの詳細については、こちらを参照してください。
于 2014-02-17T23:01:47.043 に答える