axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Eugen <eugen.w...@googlemail.com>
Subject ADB parsing ws-Policy Problem
Date Wed, 16 Nov 2011 22:38:26 GMT

I try to create ws-Policy Object with ADB Databinding from Axiom Policy

I use: Axis2 1.6.1

Problem: all inner xml tags in policy just as another Policy parsed and
therefore unexpected exception.

<wsp:Policy xmlns:wsp="http://schemas.xmlsoap.org/ws/2004/09/policy">
<wsp:ExactlyOne>
<wsp:All>
<sp:EncryptedParts
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
</sp:EncryptedParts>
<sp:SignedParts
xmlns:sp="http://schemas.xmlsoap.org/ws/2005/07/securitypolicy">
</sp:SignedParts>
</wsp:All>
</wsp:ExactlyOne>
</wsp:Policy>

-------------------------------------------------------
Policy.java:
/**
      * Factory class that keeps the parse method
      */
     public static class Factory {

         /**
          * static method to create the object
          * Precondition:
          *    - If this object is an element, the current or next start
element starts this object and any intervening reader events are ignorable
          *    - If this object is not an element, it is a complex type
and the reader is at the event just after the outer start element
          *
          * Postcondition:
          *    - If this object is an element, the reader is positioned
at its end element
          *   -  If this object is a complex type, the reader is
positioned at the end element of its outer element
          */
         public static Policy parse(javax.xml.stream.XMLStreamReader reader)
                 throws java.lang.Exception {
             Policy object = new Policy();

             int event;
             java.lang.String nillableValue = null;
             java.lang.String prefix = "";
             java.lang.String namespaceuri = "";
             try {

                 while (!reader.isStartElement()&&  !reader.isEndElement())
                     reader.next();

                 // Note all attributes that were handled. Used to
differ normal
                 // attributes
                 // from anyAttributes.
                 java.util.Vector handledAttributes = new
java.util.Vector();

                 while (!reader.isEndElement()) {
                     if (reader.isStartElement()) {

                         if (reader.isStartElement()
&&  new javax.xml.namespace.QName(

"http://schemas.xmlsoap.org/ws/2004/09/policy",

"Policy").equals(reader.getName())) {


object.setPolicy(org.xmlsoap.schemas.ws._2004._09.policy.Policy_type0.Factory
                                     .parse(reader));

                         } // End of if for expected property start element

                         else {
                             // A start element we are not expecting
indicates an
                             // invalid parameter was passed
                             throw new
org.apache.axis2.databinding.ADBException(
                                     "Unexpected subelement " +
reader.getName());
                         }

                     } else {
                         reader.next();
                     }
                 } // end of while loop

             } catch (javax.xml.stream.XMLStreamException e) {
                 throw new java.lang.Exception(e);
             }

             return object;
         }

     }// end of factory class
-------------------------------------------------
PolicyReference_type0.java :

   /**
       *  Factory class that keeps the parse method
       */
     public static class Factory{




         /**
         * static method to create the object
         * Precondition:  If this object is an element, the current or
next start element starts this object and any intervening reader events
are ignorable
         *                If this object is not an element, it is a
complex type and the reader is at the event just after the outer start
element
         * Postcondition: If this object is an element, the reader is
positioned at its end element
         *                If this object is a complex type, the reader
is positioned at the end element of its outer element
         */
         public static PolicyReference_type0
parse(javax.xml.stream.XMLStreamReader reader) throws java.lang.Exception{
             PolicyReference_type0 object =
                 new PolicyReference_type0();

             int event;
             java.lang.String nillableValue = null;
             java.lang.String prefix ="";
             java.lang.String namespaceuri ="";
             try {

                 while (!reader.isStartElement()&&  !reader.isEndElement())
                     reader.next();


                 if
(reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance","type")!=null){
                   java.lang.String fullTypeName =
reader.getAttributeValue("http://www.w3.org/2001/XMLSchema-instance",
                         "type");
                   if (fullTypeName!=null){
                     java.lang.String nsPrefix = null;
                     if (fullTypeName.indexOf(":")>  -1){
                         nsPrefix =
fullTypeName.substring(0,fullTypeName.indexOf(":"));
                     }
                     nsPrefix = nsPrefix==null?"":nsPrefix;

                     java.lang.String type =
fullTypeName.substring(fullTypeName.indexOf(":")+1);

                             if (!"PolicyReference_type0".equals(type)){
                                 //find namespace for the prefix
                                 java.lang.String nsUri =
reader.getNamespaceContext().getNamespaceURI(nsPrefix);
                                 return
(PolicyReference_type0)samples.quickstart.xsd.ExtensionMapper.getTypeObject(
                                      nsUri,type,reader);
                               }


                   }


                 }




                 // Note all attributes that were handled. Used to
differ normal attributes
                 // from anyAttributes.
                 java.util.Vector handledAttributes = new
java.util.Vector();



                     // handle attribute "URI"
                     java.lang.String tempAttribURI =

                                 reader.getAttributeValue(null,"URI");

                    if (tempAttribURI!=null){
                          java.lang.String content = tempAttribURI;

                                                  object.setURI(

org.apache.axis2.databinding.utils.ConverterUtil.convertToAnyURI(tempAttribURI));

                     } else {

                                throw new
org.apache.axis2.databinding.ADBException("Required attribute URI is
missing");

                     }
                     handledAttributes.add("URI");

                     // handle attribute "Digest"
                     java.lang.String tempAttribDigest =

                                 reader.getAttributeValue(null,"Digest");

                    if (tempAttribDigest!=null){
                          java.lang.String content = tempAttribDigest;

                                                  object.setDigest(

org.apache.axis2.databinding.utils.ConverterUtil.convertToBase64Binary(tempAttribDigest));

                     } else {

                     }
                     handledAttributes.add("Digest");

                     // handle attribute "DigestAlgorithm"
                     java.lang.String tempAttribDigestAlgorithm =


reader.getAttributeValue(null,"DigestAlgorithm");

                    if (tempAttribDigestAlgorithm!=null){
                          java.lang.String content =
tempAttribDigestAlgorithm;

                                                  object.setDigestAlgorithm(

org.apache.axis2.databinding.utils.ConverterUtil.convertToAnyURI(tempAttribDigestAlgorithm));

                     } else {

                     }
                     handledAttributes.add("DigestAlgorithm");

                         // now run through all any or extra attributes
                         // which were not reflected until now
                         for (int i=0; i<  reader.getAttributeCount();
i++) {
                             if
(!handledAttributes.contains(reader.getAttributeLocalName(i))) {
                                 // this is an anyAttribute and we create
                                 // an OMAttribute for this
                                 org.apache.axiom.om.OMFactory factory =
org.apache.axiom.om.OMAbstractFactory.getOMFactory();
                                 org.apache.axiom.om.OMAttribute attr =
                                     factory.createOMAttribute(

reader.getAttributeLocalName(i),
                                             factory.createOMNamespace(

reader.getAttributeNamespace(i), reader.getAttributePrefix(i)),
                                             reader.getAttributeValue(i));

                                 // and add it to the extra attributes

                                          object.addExtraAttributes(attr);


                             }
                         }


                     reader.next();




             } catch (javax.xml.stream.XMLStreamException e) {
                 throw new java.lang.Exception(e);
             }

             return object;
         }

         }//end of factory class


------------

java.lang.Exception: org.apache.axis2.databinding.ADBException:
Unexpected subelement
{http://schemas.xmlsoap.org/ws/2004/09/policy}ExactlyOne
     at
org.xmlsoap.schemas.ws._2004._09.policy.Policy$Factory.parse(Policy.java:349)
     at
policyUtils.MyPolicyUtils.convertNeethiToPolicy(MyPolicyUtils.java:78)
     at
test1.test1.PolicyServiceTest.testnormalizePolicy(PolicyServiceTest.java:55)
     at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
     at
sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
     at
sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
     at java.lang.reflect.Method.invoke(Method.java:597)
     at junit.framework.TestCase.runTest(TestCase.java:154)
     at junit.framework.TestCase.runBare(TestCase.java:127)
     at junit.framework.TestResult$1.protect(TestResult.java:106)
     at junit.framework.TestResult.runProtected(TestResult.java:124)
     at junit.framework.TestResult.run(TestResult.java:109)
     at junit.framework.TestCase.run(TestCase.java:118)
     at junit.framework.TestSuite.runTest(TestSuite.java:208)
     at junit.framework.TestSuite.run(TestSuite.java:203)
     at
org.eclipse.jdt.internal.junit.runner.junit3.JUnit3TestReference.run(JUnit3TestReference.java:130)
     at
org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
     at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
     at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
     at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
     at
org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: org.apache.axis2.databinding.ADBException: Unexpected
subelement {http://schemas.xmlsoap.org/ws/2004/09/policy}ExactlyOne
     at
org.xmlsoap.schemas.ws._2004._09.policy.Policy$Factory.parse(Policy.java:339)
     ... 20 more

thanks



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


Mime
View raw message