[
https://issues.apache.org/jira/browse/AXIS2-5162?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
Sagara Gunathunga updated AXIS2-5162:
--------------------------------------
Priority: Critical (was: Blocker)
> Bad parser code is generated from wsdl in certain cases
> -------------------------------------------------------
>
> Key: AXIS2-5162
> URL: https://issues.apache.org/jira/browse/AXIS2-5162
> Project: Axis2
> Issue Type: Bug
> Components: codegen
> Affects Versions: 1.6.1
> Environment: Windows7x64 (don't think to be relevant)
> Reporter: ilab
> Priority: Critical
>
> For the wsdl example you can find below, axis2 v1.6.1 (v.1.5.1 and possibly
> older versions also) generates bad parse code as the resulted service doesn't
> accept a valid message (also see below).
> If you send the message with empty Data1 tag, it is parsed successfully. With
> content, which is also valid, the parser results
> "org.apache.axis2.databinding.ADBException: Unexpected subelement Data1".
> The actual problem is that the generated parse code does not deal with the
> content of Data1 tag, therefore, if it is not empty, after parsing Data1, the
> parse pointer will be at the end element of Data1, instead of being after it.
> I have also copy-pasted the buggy code below, ElementType$Factory.parse().
> Rejected message
> ==============
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:test="http://test">
> <soapenv:Header/>
> <soapenv:Body>
> <test:QueryTestEBM>
> <test:Data1>x</test:Data1>
> <test:Data2></test:Data2>
> </test:QueryTestEBM>
> </soapenv:Body>
> </soapenv:Envelope>
> Accepted message
> ==============
> <soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/"
> xmlns:test="http://test">
> <soapenv:Header/>
> <soapenv:Body>
> <test:QueryTestEBM>
> <test:Data1></test:Data1>
> <test:Data2></test:Data2>
> </test:QueryTestEBM>
> </soapenv:Body>
> </soapenv:Envelope>
> WSDL example
> ============
> <?xml version="1.0" encoding="UTF-8"?>
> <definitions xmlns="http://schemas.xmlsoap.org/wsdl/"
> xmlns:xsd="http://www.w3.org/2001/XMLSchema"
> xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
> targetNamespace="http://test"
> xmlns:ns="http://test">
> <types>
> <xsd:schema targetNamespace="http://test"
> elementFormDefault="qualified">
> <xsd:complexType name="CodeType">
> <xsd:simpleContent>
> <xsd:extension
> base="xsd:normalizedString"/>
> </xsd:simpleContent>
> </xsd:complexType>
> <xsd:complexType name="ElementType">
> <xsd:simpleContent>
> <xsd:extension base="ns:CodeType"/>
> </xsd:simpleContent>
> </xsd:complexType>
> <xsd:complexType name="QueryTestEBMType">
> <xsd:sequence>
> <xsd:element name="Data1"
> type="ns:ElementType" maxOccurs="1"/>
> <xsd:element name="Data2"
> type="ns:ElementType" maxOccurs="1"/>
> </xsd:sequence>
> </xsd:complexType>
> <xsd:element name="QueryTestEBM"
> type="ns:QueryTestEBMType"/>
> </xsd:schema>
> </types>
> <message name="QueryTestReqMsg">
> <part name="QueryTestEBM" element="ns:QueryTestEBM"/>
> </message>
> <message name="QueryTestRespMsg">
> </message>
> <portType name="TestBindingPort">
> <operation name="QueryTest">
> <input message="ns:QueryTestReqMsg"/>
> <output message="ns:QueryTestRespMsg"/>
> </operation>
> </portType>
> <binding name="TestBinding" type="ns:TestBindingPort">
> <soap:binding style="document"
> transport="http://schemas.xmlsoap.org/soap/http" />
> <operation name="QueryTest">
> <soap:operation soapAction="QueryTest" />
> <input>
> <soap:body use="literal" />
> </input>
> <output>
> <soap:body use="literal" />
> </output>
> </operation>
> </binding>
> <service name="TestService">
> <port name="TestService" binding="ns:TestBinding">
> <soap:address
>
> location="http://localhost:8080/WebServiceTest2/services/TestService" />
> </port>
> </service>
>
> </definitions>
> Buggy code: ElementType$Factory.parse()
> ===============================
> public static ElementType parse(javax.xml.stream.XMLStreamReader
> reader) throws java.lang.Exception{
> ElementType object =
> new ElementType();
> 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 (!"ElementType".equals(type)){
> //find namespace for the prefix
> java.lang.String nsUri =
> reader.getNamespaceContext().getNamespaceURI(nsPrefix);
> return
> (ElementType)test.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();
>
>
>
> reader.next();
>
> } catch (javax.xml.stream.XMLStreamException e) {
> throw new java.lang.Exception(e);
> }
> return object;
> }
--
This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators:
https://issues.apache.org/jira/secure/ContactAdministrators!default.jspa
For more information on JIRA, see: http://www.atlassian.com/software/jira
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]