Thursday, February 16, 2012

Fixing ADB databinding issue when web service method returning OMElement


When I try to call a web service which return an OMElement, I faced above issue (My Axis2 version is 1.6.1). Following I have shown the steps that I did for fixing the issue.

This is the part of the stack trace.


org.apache.axis2.AxisFault: org.apache.axis2.databinding.ADBException: Any type  element type has not been given
    at org.apache.axis2.AxisFault.makeFault(AxisFault.java:430)
    at org.wso2.carbon.bam.presentation.stub.QueryServiceStub.fromOM(QueryServiceStub.java:8908)
    at org.wso2.carbon.bam.presentation.stub.QueryServiceStub.queryColumnFamily(QueryServiceStub.java:800)
    at org.wso2.carbon.bam.clustermonitor.ui.ClusterAdminClient.getClusterStatistics(ClusterAdminClient.java:148)


If you check the schema of the response element in your generated wsdl(by axis2) it should similar to this.


<xs:element name="queryColumnFamilyResponse">
      <xs:complexType>
         <xs:sequence>
                <xs:element minOccurs="0" name="return" nillable="true" type="xs:anyType" />
         </xs:sequence>
      </xs:complexType>
</xs:element>

In order to fix the ADB databinding issue you need to change the above schema as follows and regenerate the stub code.


<xs:element name="queryColumnFamilyResponse">
     <xs:complexType>
          <xs:sequence>
              <xs:any processContents="skip"/>
          </xs:sequence>
     </xs:complexType>
</xs:element>

Then ADB will generate code that represents the content of OriginalMessage as an OMElement and this will fix your problem.