Uploaded image for project: 'Axis2'
  1. Axis2
  2. AXIS2-5645

Error calling web service via GET/POST with a request type extending another type

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Open
    • Priority: Major
    • Resolution: Unresolved
    • Affects Version/s: 1.6.2
    • Fix Version/s: None
    • Component/s: adb, codegen
    • Labels:
      None
    • Environment:
      Tomcat 6.0 running on Windows 8 x64

      Description

      I've written a web service with a request that extends another type. I've written it by generating Java code from a .wsdl with org.apache.axis2.tool.ant.AntCodegenTask, and I'm running it in Tomcat 6.0. I can call it without a problem if I send the requests from SoapUI or similar, but if I send the same request via GET or POST from a browser or using CURL, I get this error:

      <faultstring>org.apache.axis2.databinding.ADBException: Unexpected subelement {http://domain.company.com/product}requestName</faultstring>

      It's saying there's an unexpected element of a type that is actually the correct request type, even though in a GET/POST request that request object is implicit. If I stop it extending the request's base type, it works fine in both the browser and SoapUI.

      I need the request to extend a type so that I can have multiple web services sending a large common subset of their request parameters to the same function in my Java code. This would allow the function to take a parameter of the base request type, and have each web service just pass its request into that function without any conversion or worring about the individual parameters at that point.

      Here's the setup from my .wsdl:

      webservices.wsdl:

      <definitions targetNamespace="http://domain.company.com/product"
          xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://domain.company.com/product"
          xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/"
          xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
          xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:cm="http://domain.company.com/product"
          xmlns:http="http://schemas.xmlsoap.org/wsdl/http/">
      
          <types>
              <schema elementFormDefault="qualified" targetNamespace="http://domain.company.com/product"
                  xmlns="http://www.w3.org/2001/XMLSchema" xmlns:apachesoap="http://xml.apache.org/xml-soap"
                  xmlns:tns="http://domain.company.com/product" xmlns:intf="http://domain.company.com/product"
                  xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:cm="http://domain.company.com/product">
      
                  <include schemaLocation="webServiceXsdName.xsd" />
      
                  ...
      
              </schema>
          </types>
      
          ... (web service set up here, along with other working services that are callable by both SoapUI and GET/POST)
      
      </definitions>

      webServiceXsdName.xsd:

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns="http://domain.company.com/product" targetNamespace="http://domain.company.com/product"
          elementFormDefault="qualified">
      
          <xsd:include schemaLocation="baseTypesXsdName.xsd" />
         
          <xsd:element name="requestName">
              <xsd:complexType>
                  <xsd:complexContent>
                      <xsd:extension base="requestBaseType">
                          <xsd:sequence>
                              <xsd:element name="param1" type="xsd:int" minOccurs="0" maxOccurs="1" />
                          </xsd:sequence>
                      </xsd:extension>
                  </xsd:complexContent>
              </xsd:complexType>
          </xsd:element>
      
          ...
      
      </xsd:schema>

      baseTypesXsdName.xsd:

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://domain.company.com/product" targetNamespace="http://domain.company.com/product" elementFormDefault="qualified">
      
          <xsd:complexType name="requestBaseType">
              <xsd:sequence>
                  <xsd:element name="baseParam1" type="xsd:int" minOccurs="1" maxOccurs="1" />
                  <xsd:element name="baseParam2" type="xsd:string" minOccurs="1" maxOccurs="1" />
                  <xsd:element name="baseParam3" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true" />
                  <xsd:element name="baseParam4" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false" />
                  <xsd:element name="baseParam5" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false" />
              </xsd:sequence>
          </xsd:complexType>
      
          ...
      
      </xsd:schema>

      Here's the code for webServiceXsdName.xsd without the type extension. This code works just fine:

      <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema"
          xmlns="http://domain.company.com/product" targetNamespace="http://domain.company.com/product"
          elementFormDefault="qualified">
         
          <xsd:element name="requestName">
              <xsd:complexType>
                  <xsd:sequence>
                      <xsd:element name="baseParam1" type="xsd:int" minOccurs="1" maxOccurs="1" />
                      <xsd:element name="baseParam2" type="xsd:string" minOccurs="1" maxOccurs="1" />
                      <xsd:element name="baseParam3" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="true" />
                      <xsd:element name="baseParam4" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false" />
                      <xsd:element name="baseParam5" type="xsd:boolean" minOccurs="0" maxOccurs="1" default="false" />
                      <xsd:element name="param1" type="xsd:int" minOccurs="0" maxOccurs="1" />
                  </xsd:sequence>
              </xsd:complexType>
          </xsd:element>
      
          ...
      
      </xsd:schema>

        Attachments

          Activity

            People

            • Assignee:
              Unassigned
              Reporter:
              mikeombiel Michael Hawes
            • Votes:
              0 Vote for this issue
              Watchers:
              1 Start watching this issue

              Dates

              • Created:
                Updated: