You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@axis.apache.org by Brett Walker <br...@geometryit.com> on 2011/12/01 01:58:04 UTC

IllegalArgumentException: ProtectionToken is not a element.

Hi,

I have been struggling with a problem for a few hours that I have with Axis2 and
Rampart. I have googled quite extensively and have yet to found a solution. I
have even looked at the source code and stepped through it. Though this has
enlightened me about the error and its cause it has not brought me closer to a
solution.

The error that is occurring is

  java.lang.IllegalArgumentException: {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}ProtectionToken is not a <wsp:Policy> element.

For the full stacktrace see attached stacktrace.txt file.

While I have used Axis2 before, I'm no expert with it and even less so with Rampart.
I have an existing Web App that needs to be extended to introduce a client for a
Web Service interaction. I have installed Axis2 v1.6.1 and Rampart v1.6.1 as
instructed, i.e. set AXIS2_HOME and copied Rampart's libs and modules to the
appropriate places under the Axis2 installation. I built the client-side Java classes
using the WSDL2Java script and bundled the generated classes into a jar
(WebServiceClient.jar). The WSDL and XSD are in the attached wsdl.zip file. I then
added the appropriate jars and modules to the existing Web App; see the
following diagram for more information.

  \WebApp
  |
  |-\ ( other directories )
  |
  |-\WEB-INF
    |
    |-\( other directories )
    |
    |-\lib includes AXIS2 and Rampart jars and WebServiceClient.jar
    |
    |-\repository
      |
      |-\modules includes AXIS2 and Rampart modules
      |
      |-\services ( empty )

The section of code that initialises the Web Services is as follows:

  try
  {
    ConfigurationContext context = ConfigurationContextFactory.createConfigurationContextFromFileSystem( this.getWebInfPath() + "repository" );

**  ablisContentManagementService = new ContentManagementServiceStub( context, "http://services.ablis.uat.business.gov.au/ContentManagement.svc" );

    ServiceClient ablisContentManagementServiceClient = ablisContentManagementService._getServiceClient();

    ablisContentManagementServiceClient.engageModule( "addressing" );
    ablisContentManagementServiceClient.engageModule( "rampart" );

    ablisAxisFault = null;
  }
  catch ( AxisFault af )
  {
    ablisContentManagementService = null;
    ablisAxisFault = af;
    af.printStackTrace();
  }
  catch ( Throwable t )
  {
    t.printStackTrace();
  }

I know that Rampart is not configured properly but the error is being thrown
at the highlighted line; even before the Rampart configuration, if done.

In debugging, I noticed that the XML, as an OMElement instance, being passed
to the SymmetricBindingBuilder.build(see stacktrace) is the following:

  <wsp:Policy>
    <sp:ProtectionToken>
      <wsp:Policy>
        <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
          <wsp:Policy>
            <sp:RequireDerivedKeys/>
            <sp:RequireThumbprintReference/>
            <sp:WssX509V3Token10/>
          </wsp:Policy>
        </sp:X509Token>
      </wsp:Policy>
    </sp:ProtectionToken>
    <sp:AlgorithmSuite>
      <wsp:Policy>
        <sp:Basic256Sha256/>
      </wsp:Policy>
    </sp:AlgorithmSuite>
    <sp:Layout>
      <wsp:Policy>
        <sp:Strict/>
      </wsp:Policy>
    </sp:Layout>
    <sp:IncludeTimestamp/>
    <sp:EncryptSignature/>
    <sp:OnlySignEntireHeadersAndBody/>
  </wsp:Policy>

>From the code in SymmetricBindingBuilder.build(), I think the XML should be:

  <sp:SymmetricBinding xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
    <wsp:Policy>
      <sp:ProtectionToken>
        <wsp:Policy>
          <sp:X509Token sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
            <wsp:Policy>
              <sp:RequireDerivedKeys/>
              <sp:RequireThumbprintReference/>
              <sp:WssX509V3Token10/>
            </wsp:Policy>
          </sp:X509Token>
        </wsp:Policy>
      </sp:ProtectionToken>
      <sp:AlgorithmSuite>
        <wsp:Policy>
          <sp:Basic256Sha256/>
        </wsp:Policy>
      </sp:AlgorithmSuite>
      <sp:Layout>
        <wsp:Policy>
          <sp:Strict/>
        </wsp:Policy>
      </sp:Layout>
      <sp:IncludeTimestamp/>
      <sp:EncryptSignature/>
      <sp:OnlySignEntireHeadersAndBody/>
    </wsp:Policy>
  </sp:SymmetricBinding>

This would fix the error but how to accomplish this.

I may have made errors or omissions in what I have said or done, if so please highlight
these. I'm familiar with Axis2 and not at all with Rampart so any help is appreciated. I
am happy to answer questions. Any help is greatly appreciated.

Thanks in kind,
Brett


Re: IllegalArgumentException: ProtectionToken is not a element.

Posted by Andreas Veithen <an...@gmail.com>.
This should work as expected with Axis2 1.6.2-SNAPSHOT and Rampart
1.6.2-SNAPSHOT.

Andreas

On Thu, Dec 1, 2011 at 01:58, Brett Walker <br...@geometryit.com> wrote:
> Hi,
>
>
>
> I have been struggling with a problem for a few hours that I have with Axis2
> and
>
> Rampart. I have googled quite extensively and have yet to found a solution.
> I
>
> have even looked at the source code and stepped through it. Though this has
>
> enlightened me about the error and its cause it has not brought me closer to
> a
>
> solution.
>
>
>
> The error that is occurring is
>
>
>
>   java.lang.IllegalArgumentException:
> {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}ProtectionToken is not
> a <wsp:Policy> element.
>
>
>
> For the full stacktrace see attached stacktrace.txt file.
>
>
>
> While I have used Axis2 before, I'm no expert with it and even less so with
> Rampart.
>
> I have an existing Web App that needs to be extended to introduce a client
> for a
>
> Web Service interaction. I have installed Axis2 v1.6.1 and Rampart v1.6.1 as
>
> instructed, i.e. set AXIS2_HOME and copied Rampart's libs and modules to the
>
> appropriate places under the Axis2 installation. I built the client-side
> Java classes
>
> using the WSDL2Java script and bundled the generated classes into a jar
>
> (WebServiceClient.jar). The WSDL and XSD are in the attached wsdl.zip file.
> I then
>
> added the appropriate jars and modules to the existing Web App; see the
>
> following diagram for more information.
>
>
>
>   \WebApp
>
>   |
>
>   |-\ ( other directories )
>
>   |
>
>   |-\WEB-INF
>
>     |
>
>     |-\( other directories )
>
>     |
>
>     |-\lib includes AXIS2 and Rampart jars and WebServiceClient.jar
>
>     |
>
>     |-\repository
>
>       |
>
>       |-\modules includes AXIS2 and Rampart modules
>
>       |
>
>       |-\services ( empty )
>
>
>
> The section of code that initialises the Web Services is as follows:
>
>
>
>   try
>
>   {
>
>     ConfigurationContext context =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(
> this.getWebInfPath() + "repository" );
>
>
>
> **  ablisContentManagementService = new ContentManagementServiceStub(
> context, "http://services.ablis.uat.business.gov.au/ContentManagement.svc"
> );
>
>
>
>     ServiceClient ablisContentManagementServiceClient =
> ablisContentManagementService._getServiceClient();
>
>
>
>     ablisContentManagementServiceClient.engageModule( "addressing" );
>
>     ablisContentManagementServiceClient.engageModule( "rampart" );
>
>
>
>     ablisAxisFault = null;
>
>   }
>
>   catch ( AxisFault af )
>
>   {
>
>     ablisContentManagementService = null;
>
>     ablisAxisFault = af;
>
>     af.printStackTrace();
>
>   }
>
>   catch ( Throwable t )
>
>   {
>
>     t.printStackTrace();
>
>   }
>
>
>
> I know that Rampart is not configured properly but the error is being thrown
>
> at the highlighted line; even before the Rampart configuration, if done.
>
>
>
> In debugging, I noticed that the XML, as an OMElement instance, being passed
>
> to the SymmetricBindingBuilder.build(see stacktrace) is the following:
>
>
>
>   <wsp:Policy>
>
>     <sp:ProtectionToken>
>
>       <wsp:Policy>
>
>         <sp:X509Token
> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
>
>           <wsp:Policy>
>
>             <sp:RequireDerivedKeys/>
>
>             <sp:RequireThumbprintReference/>
>
>             <sp:WssX509V3Token10/>
>
>           </wsp:Policy>
>
>         </sp:X509Token>
>
>       </wsp:Policy>
>
>     </sp:ProtectionToken>
>
>     <sp:AlgorithmSuite>
>
>       <wsp:Policy>
>
>         <sp:Basic256Sha256/>
>
>       </wsp:Policy>
>
>     </sp:AlgorithmSuite>
>
>     <sp:Layout>
>
>       <wsp:Policy>
>
>         <sp:Strict/>
>
>       </wsp:Policy>
>
>     </sp:Layout>
>
>     <sp:IncludeTimestamp/>
>
>     <sp:EncryptSignature/>
>
>     <sp:OnlySignEntireHeadersAndBody/>
>
>   </wsp:Policy>
>
>
>
> From the code in SymmetricBindingBuilder.build(), I think the XML should be:
>
>
>
>   <sp:SymmetricBinding
> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>
>     <wsp:Policy>
>
>       <sp:ProtectionToken>
>
>         <wsp:Policy>
>
>           <sp:X509Token
> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
>
>             <wsp:Policy>
>
>               <sp:RequireDerivedKeys/>
>
>               <sp:RequireThumbprintReference/>
>
>               <sp:WssX509V3Token10/>
>
>             </wsp:Policy>
>
>           </sp:X509Token>
>
>         </wsp:Policy>
>
>       </sp:ProtectionToken>
>
>       <sp:AlgorithmSuite>
>
>         <wsp:Policy>
>
>           <sp:Basic256Sha256/>
>
>         </wsp:Policy>
>
>       </sp:AlgorithmSuite>
>
>       <sp:Layout>
>
>         <wsp:Policy>
>
>           <sp:Strict/>
>
>         </wsp:Policy>
>
>       </sp:Layout>
>
>       <sp:IncludeTimestamp/>
>
>       <sp:EncryptSignature/>
>
>       <sp:OnlySignEntireHeadersAndBody/>
>
>     </wsp:Policy>
>
>   </sp:SymmetricBinding>
>
>
>
> This would fix the error but how to accomplish this.
>
>
>
> I may have made errors or omissions in what I have said or done, if so
> please highlight
>
> these. I'm familiar with Axis2 and not at all with Rampart so any help is
> appreciated. I
>
> am happy to answer questions. Any help is greatly appreciated.
>
>
>
> Thanks in kind,
>
> Brett
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: IllegalArgumentException: ProtectionToken is not a element.

Posted by Ruchith Fernando <ru...@gmail.com>.
Hi Brett,

FYI: When I used the latest axiom jars (1.2.3-SNAPSHOT) I was able to
use the original getPolicy() method.

Thanks,
Ruchith

On Sun, Dec 4, 2011 at 9:05 PM, Brett Walker
<br...@geometryit.com> wrote:
> Thanks Ruchith,
>
>  This has indeed fixed my problem. Good work
>
> Brett
>
> -----Original Message-----
> From: Ruchith Fernando [mailto:ruchith.fernando@gmail.com]
> Sent: Monday, 5 December 2011 9:41 AM
> To: java-user@axis.apache.org
> Subject: Re: IllegalArgumentException: ProtectionToken is not a <wsp:Policy> element.
>
> Hi Brett,
>
> I was able to reproduce the problem. And I was able to get past loading policy with the following fixes:
>
> 1.) There are some <sp:Policy> elements in the generated ContentManagementServiceStub.java Please change these to <wsp:Policy> (and </wsp:Policy> respectively).
> You will find 4 such instances. I checked the original wsdl and I couldn't find such <sp:Policy> elements, so I guess this is a bug in
> axis2 code generation.
>
> 2.) Update the getPolicy method in ContentManagementServiceStub.java
>
> Please change the getPolicy method to the following:
>
>    private static org.apache.neethi.Policy getPolicy (java.lang.String policyString) {
>        java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(policyString.getBytes());
>                try {
>                        StAXOMBuilder builder = new StAXOMBuilder(bais);
>                        OMElement documentElement = builder.getDocumentElement();
>                return org.apache.neethi.PolicyEngine.getPolicy(documentElement);
>                } catch (XMLStreamException e) {
>                        e.printStackTrace();
>                }
>                return null;
>    }
>
> With the original code that is generated the XMLStreamReader instance created in org.apache.neethi.PolicyBuilder seems to behave incorrectly.
>
>
> Hope this helps!
>
> Thanks,
> Ruchith
>
>
> On Wed, Nov 30, 2011 at 7:58 PM, Brett Walker <br...@geometryit.com> wrote:
>> Hi,
>>
>>
>>
>> I have been struggling with a problem for a few hours that I have with
>> Axis2 and
>>
>> Rampart. I have googled quite extensively and have yet to found a solution.
>> I
>>
>> have even looked at the source code and stepped through it. Though
>> this has
>>
>> enlightened me about the error and its cause it has not brought me
>> closer to a
>>
>> solution.
>>
>>
>>
>> The error that is occurring is
>>
>>
>>
>>   java.lang.IllegalArgumentException:
>> {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}ProtectionToken
>> is not a <wsp:Policy> element.
>>
>>
>>
>> For the full stacktrace see attached stacktrace.txt file.
>>
>>
>>
>> While I have used Axis2 before, I'm no expert with it and even less so
>> with Rampart.
>>
>> I have an existing Web App that needs to be extended to introduce a
>> client for a
>>
>> Web Service interaction. I have installed Axis2 v1.6.1 and Rampart
>> v1.6.1 as
>>
>> instructed, i.e. set AXIS2_HOME and copied Rampart's libs and modules
>> to the
>>
>> appropriate places under the Axis2 installation. I built the
>> client-side Java classes
>>
>> using the WSDL2Java script and bundled the generated classes into a
>> jar
>>
>> (WebServiceClient.jar). The WSDL and XSD are in the attached wsdl.zip file.
>> I then
>>
>> added the appropriate jars and modules to the existing Web App; see
>> the
>>
>> following diagram for more information.
>>
>>
>>
>>   \WebApp
>>
>>   |
>>
>>   |-\ ( other directories )
>>
>>   |
>>
>>   |-\WEB-INF
>>
>>     |
>>
>>     |-\( other directories )
>>
>>     |
>>
>>     |-\lib includes AXIS2 and Rampart jars and WebServiceClient.jar
>>
>>     |
>>
>>     |-\repository
>>
>>       |
>>
>>       |-\modules includes AXIS2 and Rampart modules
>>
>>       |
>>
>>       |-\services ( empty )
>>
>>
>>
>> The section of code that initialises the Web Services is as follows:
>>
>>
>>
>>   try
>>
>>   {
>>
>>     ConfigurationContext context =
>> ConfigurationContextFactory.createConfigurationContextFromFileSystem(
>> this.getWebInfPath() + "repository" );
>>
>>
>>
>> **  ablisContentManagementService = new ContentManagementServiceStub(
>> context, "http://services.ablis.uat.business.gov.au/ContentManagement.svc"
>> );
>>
>>
>>
>>     ServiceClient ablisContentManagementServiceClient =
>> ablisContentManagementService._getServiceClient();
>>
>>
>>
>>     ablisContentManagementServiceClient.engageModule( "addressing" );
>>
>>     ablisContentManagementServiceClient.engageModule( "rampart" );
>>
>>
>>
>>     ablisAxisFault = null;
>>
>>   }
>>
>>   catch ( AxisFault af )
>>
>>   {
>>
>>     ablisContentManagementService = null;
>>
>>     ablisAxisFault = af;
>>
>>     af.printStackTrace();
>>
>>   }
>>
>>   catch ( Throwable t )
>>
>>   {
>>
>>     t.printStackTrace();
>>
>>   }
>>
>>
>>
>> I know that Rampart is not configured properly but the error is being
>> thrown
>>
>> at the highlighted line; even before the Rampart configuration, if done.
>>
>>
>>
>> In debugging, I noticed that the XML, as an OMElement instance, being
>> passed
>>
>> to the SymmetricBindingBuilder.build(see stacktrace) is the following:
>>
>>
>>
>>   <wsp:Policy>
>>
>>     <sp:ProtectionToken>
>>
>>       <wsp:Policy>
>>
>>         <sp:X509Token
>> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/
>> IncludeToken/Never">
>>
>>           <wsp:Policy>
>>
>>             <sp:RequireDerivedKeys/>
>>
>>             <sp:RequireThumbprintReference/>
>>
>>             <sp:WssX509V3Token10/>
>>
>>           </wsp:Policy>
>>
>>         </sp:X509Token>
>>
>>       </wsp:Policy>
>>
>>     </sp:ProtectionToken>
>>
>>     <sp:AlgorithmSuite>
>>
>>       <wsp:Policy>
>>
>>         <sp:Basic256Sha256/>
>>
>>       </wsp:Policy>
>>
>>     </sp:AlgorithmSuite>
>>
>>     <sp:Layout>
>>
>>       <wsp:Policy>
>>
>>         <sp:Strict/>
>>
>>       </wsp:Policy>
>>
>>     </sp:Layout>
>>
>>     <sp:IncludeTimestamp/>
>>
>>     <sp:EncryptSignature/>
>>
>>     <sp:OnlySignEntireHeadersAndBody/>
>>
>>   </wsp:Policy>
>>
>>
>>
>> From the code in SymmetricBindingBuilder.build(), I think the XML should be:
>>
>>
>>
>>   <sp:SymmetricBinding
>> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>>
>>     <wsp:Policy>
>>
>>       <sp:ProtectionToken>
>>
>>         <wsp:Policy>
>>
>>           <sp:X509Token
>> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/
>> IncludeToken/Never">
>>
>>             <wsp:Policy>
>>
>>               <sp:RequireDerivedKeys/>
>>
>>               <sp:RequireThumbprintReference/>
>>
>>               <sp:WssX509V3Token10/>
>>
>>             </wsp:Policy>
>>
>>           </sp:X509Token>
>>
>>         </wsp:Policy>
>>
>>       </sp:ProtectionToken>
>>
>>       <sp:AlgorithmSuite>
>>
>>         <wsp:Policy>
>>
>>           <sp:Basic256Sha256/>
>>
>>         </wsp:Policy>
>>
>>       </sp:AlgorithmSuite>
>>
>>       <sp:Layout>
>>
>>         <wsp:Policy>
>>
>>           <sp:Strict/>
>>
>>         </wsp:Policy>
>>
>>       </sp:Layout>
>>
>>       <sp:IncludeTimestamp/>
>>
>>       <sp:EncryptSignature/>
>>
>>       <sp:OnlySignEntireHeadersAndBody/>
>>
>>     </wsp:Policy>
>>
>>   </sp:SymmetricBinding>
>>
>>
>>
>> This would fix the error but how to accomplish this.
>>
>>
>>
>> I may have made errors or omissions in what I have said or done, if so
>> please highlight
>>
>> these. I'm familiar with Axis2 and not at all with Rampart so any help
>> is appreciated. I
>>
>> am happy to answer questions. Any help is greatly appreciated.
>>
>>
>>
>> Thanks in kind,
>>
>> Brett
>>
>>
>>
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
>> For additional commands, e-mail: java-user-help@axis.apache.org
>
>
>
> --
> http://ruchith.org
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org
>



-- 
http://ruchith.org

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


RE: IllegalArgumentException: ProtectionToken is not a element.

Posted by Brett Walker <br...@geometryit.com>.
Thanks Ruchith,

 This has indeed fixed my problem. Good work

Brett

-----Original Message-----
From: Ruchith Fernando [mailto:ruchith.fernando@gmail.com] 
Sent: Monday, 5 December 2011 9:41 AM
To: java-user@axis.apache.org
Subject: Re: IllegalArgumentException: ProtectionToken is not a <wsp:Policy> element.

Hi Brett,

I was able to reproduce the problem. And I was able to get past loading policy with the following fixes:

1.) There are some <sp:Policy> elements in the generated ContentManagementServiceStub.java Please change these to <wsp:Policy> (and </wsp:Policy> respectively).
You will find 4 such instances. I checked the original wsdl and I couldn't find such <sp:Policy> elements, so I guess this is a bug in
axis2 code generation.

2.) Update the getPolicy method in ContentManagementServiceStub.java

Please change the getPolicy method to the following:

    private static org.apache.neethi.Policy getPolicy (java.lang.String policyString) {
    	java.io.ByteArrayInputStream bais = new java.io.ByteArrayInputStream(policyString.getBytes());
		try {
			StAXOMBuilder builder = new StAXOMBuilder(bais);
			OMElement documentElement = builder.getDocumentElement();
	    	return org.apache.neethi.PolicyEngine.getPolicy(documentElement);
		} catch (XMLStreamException e) {
			e.printStackTrace();
		}
		return null;
    }

With the original code that is generated the XMLStreamReader instance created in org.apache.neethi.PolicyBuilder seems to behave incorrectly.


Hope this helps!

Thanks,
Ruchith


On Wed, Nov 30, 2011 at 7:58 PM, Brett Walker <br...@geometryit.com> wrote:
> Hi,
>
>
>
> I have been struggling with a problem for a few hours that I have with 
> Axis2 and
>
> Rampart. I have googled quite extensively and have yet to found a solution.
> I
>
> have even looked at the source code and stepped through it. Though 
> this has
>
> enlightened me about the error and its cause it has not brought me 
> closer to a
>
> solution.
>
>
>
> The error that is occurring is
>
>
>
>   java.lang.IllegalArgumentException:
> {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}ProtectionToken 
> is not a <wsp:Policy> element.
>
>
>
> For the full stacktrace see attached stacktrace.txt file.
>
>
>
> While I have used Axis2 before, I'm no expert with it and even less so 
> with Rampart.
>
> I have an existing Web App that needs to be extended to introduce a 
> client for a
>
> Web Service interaction. I have installed Axis2 v1.6.1 and Rampart 
> v1.6.1 as
>
> instructed, i.e. set AXIS2_HOME and copied Rampart's libs and modules 
> to the
>
> appropriate places under the Axis2 installation. I built the 
> client-side Java classes
>
> using the WSDL2Java script and bundled the generated classes into a 
> jar
>
> (WebServiceClient.jar). The WSDL and XSD are in the attached wsdl.zip file.
> I then
>
> added the appropriate jars and modules to the existing Web App; see 
> the
>
> following diagram for more information.
>
>
>
>   \WebApp
>
>   |
>
>   |-\ ( other directories )
>
>   |
>
>   |-\WEB-INF
>
>     |
>
>     |-\( other directories )
>
>     |
>
>     |-\lib includes AXIS2 and Rampart jars and WebServiceClient.jar
>
>     |
>
>     |-\repository
>
>       |
>
>       |-\modules includes AXIS2 and Rampart modules
>
>       |
>
>       |-\services ( empty )
>
>
>
> The section of code that initialises the Web Services is as follows:
>
>
>
>   try
>
>   {
>
>     ConfigurationContext context =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(
> this.getWebInfPath() + "repository" );
>
>
>
> **  ablisContentManagementService = new ContentManagementServiceStub( 
> context, "http://services.ablis.uat.business.gov.au/ContentManagement.svc"
> );
>
>
>
>     ServiceClient ablisContentManagementServiceClient = 
> ablisContentManagementService._getServiceClient();
>
>
>
>     ablisContentManagementServiceClient.engageModule( "addressing" );
>
>     ablisContentManagementServiceClient.engageModule( "rampart" );
>
>
>
>     ablisAxisFault = null;
>
>   }
>
>   catch ( AxisFault af )
>
>   {
>
>     ablisContentManagementService = null;
>
>     ablisAxisFault = af;
>
>     af.printStackTrace();
>
>   }
>
>   catch ( Throwable t )
>
>   {
>
>     t.printStackTrace();
>
>   }
>
>
>
> I know that Rampart is not configured properly but the error is being 
> thrown
>
> at the highlighted line; even before the Rampart configuration, if done.
>
>
>
> In debugging, I noticed that the XML, as an OMElement instance, being 
> passed
>
> to the SymmetricBindingBuilder.build(see stacktrace) is the following:
>
>
>
>   <wsp:Policy>
>
>     <sp:ProtectionToken>
>
>       <wsp:Policy>
>
>         <sp:X509Token
> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/
> IncludeToken/Never">
>
>           <wsp:Policy>
>
>             <sp:RequireDerivedKeys/>
>
>             <sp:RequireThumbprintReference/>
>
>             <sp:WssX509V3Token10/>
>
>           </wsp:Policy>
>
>         </sp:X509Token>
>
>       </wsp:Policy>
>
>     </sp:ProtectionToken>
>
>     <sp:AlgorithmSuite>
>
>       <wsp:Policy>
>
>         <sp:Basic256Sha256/>
>
>       </wsp:Policy>
>
>     </sp:AlgorithmSuite>
>
>     <sp:Layout>
>
>       <wsp:Policy>
>
>         <sp:Strict/>
>
>       </wsp:Policy>
>
>     </sp:Layout>
>
>     <sp:IncludeTimestamp/>
>
>     <sp:EncryptSignature/>
>
>     <sp:OnlySignEntireHeadersAndBody/>
>
>   </wsp:Policy>
>
>
>
> From the code in SymmetricBindingBuilder.build(), I think the XML should be:
>
>
>
>   <sp:SymmetricBinding
> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>
>     <wsp:Policy>
>
>       <sp:ProtectionToken>
>
>         <wsp:Policy>
>
>           <sp:X509Token
> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/
> IncludeToken/Never">
>
>             <wsp:Policy>
>
>               <sp:RequireDerivedKeys/>
>
>               <sp:RequireThumbprintReference/>
>
>               <sp:WssX509V3Token10/>
>
>             </wsp:Policy>
>
>           </sp:X509Token>
>
>         </wsp:Policy>
>
>       </sp:ProtectionToken>
>
>       <sp:AlgorithmSuite>
>
>         <wsp:Policy>
>
>           <sp:Basic256Sha256/>
>
>         </wsp:Policy>
>
>       </sp:AlgorithmSuite>
>
>       <sp:Layout>
>
>         <wsp:Policy>
>
>           <sp:Strict/>
>
>         </wsp:Policy>
>
>       </sp:Layout>
>
>       <sp:IncludeTimestamp/>
>
>       <sp:EncryptSignature/>
>
>       <sp:OnlySignEntireHeadersAndBody/>
>
>     </wsp:Policy>
>
>   </sp:SymmetricBinding>
>
>
>
> This would fix the error but how to accomplish this.
>
>
>
> I may have made errors or omissions in what I have said or done, if so 
> please highlight
>
> these. I'm familiar with Axis2 and not at all with Rampart so any help 
> is appreciated. I
>
> am happy to answer questions. Any help is greatly appreciated.
>
>
>
> Thanks in kind,
>
> Brett
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org



--
http://ruchith.org

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org


Re: IllegalArgumentException: ProtectionToken is not a element.

Posted by Ruchith Fernando <ru...@gmail.com>.
Hi Brett,

I was able to reproduce the problem. And I was able to get past
loading policy with the following fixes:

1.) There are some <sp:Policy> elements in the generated
ContentManagementServiceStub.java
Please change these to <wsp:Policy> (and </wsp:Policy> respectively).
You will find 4 such instances. I checked the original wsdl and I
couldn't find such <sp:Policy> elements, so I guess this is a bug in
axis2 code generation.

2.) Update the getPolicy method in ContentManagementServiceStub.java

Please change the getPolicy method to the following:

    private static org.apache.neethi.Policy getPolicy
(java.lang.String policyString) {
    	java.io.ByteArrayInputStream bais = new
java.io.ByteArrayInputStream(policyString.getBytes());
		try {
			StAXOMBuilder builder = new StAXOMBuilder(bais);
			OMElement documentElement = builder.getDocumentElement();
	    	return org.apache.neethi.PolicyEngine.getPolicy(documentElement);
		} catch (XMLStreamException e) {
			e.printStackTrace();
		}
		return null;
    }

With the original code that is generated the XMLStreamReader instance
created in org.apache.neethi.PolicyBuilder seems to behave
incorrectly.


Hope this helps!

Thanks,
Ruchith


On Wed, Nov 30, 2011 at 7:58 PM, Brett Walker
<br...@geometryit.com> wrote:
> Hi,
>
>
>
> I have been struggling with a problem for a few hours that I have with Axis2
> and
>
> Rampart. I have googled quite extensively and have yet to found a solution.
> I
>
> have even looked at the source code and stepped through it. Though this has
>
> enlightened me about the error and its cause it has not brought me closer to
> a
>
> solution.
>
>
>
> The error that is occurring is
>
>
>
>   java.lang.IllegalArgumentException:
> {http://schemas.xmlsoap.org/ws/2005/07/securitypolicy}ProtectionToken is not
> a <wsp:Policy> element.
>
>
>
> For the full stacktrace see attached stacktrace.txt file.
>
>
>
> While I have used Axis2 before, I'm no expert with it and even less so with
> Rampart.
>
> I have an existing Web App that needs to be extended to introduce a client
> for a
>
> Web Service interaction. I have installed Axis2 v1.6.1 and Rampart v1.6.1 as
>
> instructed, i.e. set AXIS2_HOME and copied Rampart's libs and modules to the
>
> appropriate places under the Axis2 installation. I built the client-side
> Java classes
>
> using the WSDL2Java script and bundled the generated classes into a jar
>
> (WebServiceClient.jar). The WSDL and XSD are in the attached wsdl.zip file.
> I then
>
> added the appropriate jars and modules to the existing Web App; see the
>
> following diagram for more information.
>
>
>
>   \WebApp
>
>   |
>
>   |-\ ( other directories )
>
>   |
>
>   |-\WEB-INF
>
>     |
>
>     |-\( other directories )
>
>     |
>
>     |-\lib includes AXIS2 and Rampart jars and WebServiceClient.jar
>
>     |
>
>     |-\repository
>
>       |
>
>       |-\modules includes AXIS2 and Rampart modules
>
>       |
>
>       |-\services ( empty )
>
>
>
> The section of code that initialises the Web Services is as follows:
>
>
>
>   try
>
>   {
>
>     ConfigurationContext context =
> ConfigurationContextFactory.createConfigurationContextFromFileSystem(
> this.getWebInfPath() + "repository" );
>
>
>
> **  ablisContentManagementService = new ContentManagementServiceStub(
> context, "http://services.ablis.uat.business.gov.au/ContentManagement.svc"
> );
>
>
>
>     ServiceClient ablisContentManagementServiceClient =
> ablisContentManagementService._getServiceClient();
>
>
>
>     ablisContentManagementServiceClient.engageModule( "addressing" );
>
>     ablisContentManagementServiceClient.engageModule( "rampart" );
>
>
>
>     ablisAxisFault = null;
>
>   }
>
>   catch ( AxisFault af )
>
>   {
>
>     ablisContentManagementService = null;
>
>     ablisAxisFault = af;
>
>     af.printStackTrace();
>
>   }
>
>   catch ( Throwable t )
>
>   {
>
>     t.printStackTrace();
>
>   }
>
>
>
> I know that Rampart is not configured properly but the error is being thrown
>
> at the highlighted line; even before the Rampart configuration, if done.
>
>
>
> In debugging, I noticed that the XML, as an OMElement instance, being passed
>
> to the SymmetricBindingBuilder.build(see stacktrace) is the following:
>
>
>
>   <wsp:Policy>
>
>     <sp:ProtectionToken>
>
>       <wsp:Policy>
>
>         <sp:X509Token
> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
>
>           <wsp:Policy>
>
>             <sp:RequireDerivedKeys/>
>
>             <sp:RequireThumbprintReference/>
>
>             <sp:WssX509V3Token10/>
>
>           </wsp:Policy>
>
>         </sp:X509Token>
>
>       </wsp:Policy>
>
>     </sp:ProtectionToken>
>
>     <sp:AlgorithmSuite>
>
>       <wsp:Policy>
>
>         <sp:Basic256Sha256/>
>
>       </wsp:Policy>
>
>     </sp:AlgorithmSuite>
>
>     <sp:Layout>
>
>       <wsp:Policy>
>
>         <sp:Strict/>
>
>       </wsp:Policy>
>
>     </sp:Layout>
>
>     <sp:IncludeTimestamp/>
>
>     <sp:EncryptSignature/>
>
>     <sp:OnlySignEntireHeadersAndBody/>
>
>   </wsp:Policy>
>
>
>
> From the code in SymmetricBindingBuilder.build(), I think the XML should be:
>
>
>
>   <sp:SymmetricBinding
> xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
>
>     <wsp:Policy>
>
>       <sp:ProtectionToken>
>
>         <wsp:Policy>
>
>           <sp:X509Token
> sp:IncludeToken="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy/IncludeToken/Never">
>
>             <wsp:Policy>
>
>               <sp:RequireDerivedKeys/>
>
>               <sp:RequireThumbprintReference/>
>
>               <sp:WssX509V3Token10/>
>
>             </wsp:Policy>
>
>           </sp:X509Token>
>
>         </wsp:Policy>
>
>       </sp:ProtectionToken>
>
>       <sp:AlgorithmSuite>
>
>         <wsp:Policy>
>
>           <sp:Basic256Sha256/>
>
>         </wsp:Policy>
>
>       </sp:AlgorithmSuite>
>
>       <sp:Layout>
>
>         <wsp:Policy>
>
>           <sp:Strict/>
>
>         </wsp:Policy>
>
>       </sp:Layout>
>
>       <sp:IncludeTimestamp/>
>
>       <sp:EncryptSignature/>
>
>       <sp:OnlySignEntireHeadersAndBody/>
>
>     </wsp:Policy>
>
>   </sp:SymmetricBinding>
>
>
>
> This would fix the error but how to accomplish this.
>
>
>
> I may have made errors or omissions in what I have said or done, if so
> please highlight
>
> these. I'm familiar with Axis2 and not at all with Rampart so any help is
> appreciated. I
>
> am happy to answer questions. Any help is greatly appreciated.
>
>
>
> Thanks in kind,
>
> Brett
>
>
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
> For additional commands, e-mail: java-user-help@axis.apache.org



-- 
http://ruchith.org

---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@axis.apache.org
For additional commands, e-mail: java-user-help@axis.apache.org