Hello,

I am having an issue on a stub generated with axis2 version 1.5.3.

Somehow the stub generates the XML containing an element badly causing the 
XML to be invalid.

This is how it comes out (notice bad content inside ExecuteRequest):

<?xml version='1.0' encoding='utf-8'?>
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
">
   <soapenv:Body>
    <ns1:ExecuteRequest xmlns:ns1="http://services.bkr.nl/servicesv2/";>
      <ns1:http://services.bkr.nl/servicesv2/>
           <!-- here comes our message --> 
      </ns1:http://services.bkr.nl/servicesv2/>
    </ns1:ExecuteRequest>
   </soapenv:Body>
</soapenv:Envelope>

This is how it is supposed to come out (notice the xmlMessage element as 
it should be outputted):

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/
">

   <soapenv:Body>

      <ns1:ExecuteRequest xmlns:ns1="http://services.bkr.nl/servicesv2/";>

         <xmlMessage>

           <!-- here comes our message -->

         </xmlMessage>

      </ns1:ExecuteRequest>

   </soapenv:Body>

</soapenv:Envelope>


We generate the stub with this command:
wsdl2java.bat -uri ../mywsdl/BKRService2.wsdl -o ../myoutput -s -uw -p 
be.sofico.nl.iface.bkr.verification -or

We invoke the 'ExecuteRequest' operation

This is the wsdl:

<?xml version="1.0" encoding="utf-8"?>

<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"; 
xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/"; xmlns:soapenc="
http://schemas.xmlsoap.org/soap/encoding/"; xmlns:mime="
http://schemas.xmlsoap.org/wsdl/mime/"; xmlns:tns="
http://services.bkr.nl/servicesv2/"; xmlns:s="
http://www.w3.org/2001/XMLSchema"; xmlns:soap12="
http://schemas.xmlsoap.org/wsdl/soap12/"; xmlns:http="
http://schemas.xmlsoap.org/wsdl/http/"; targetNamespace="
http://services.bkr.nl/servicesv2/"; xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/";>

    <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/
">Provides an interface for performing CKI, LIS toetsing and 
registration</wsdl:documentation>

    <wsdl:types>

        <s:schema elementFormDefault="qualified" targetNamespace="
http://services.bkr.nl/servicesv2/";>

            <s:element name="ExecuteRequest">

                <s:complexType>

                    <s:sequence>

                        <s:element minOccurs="0" maxOccurs="1" 
name="xmlMessage">

                            <s:complexType mixed="true">

                                <s:sequence>

                                    <s:any />

                                </s:sequence>

                            </s:complexType>

                        </s:element>

                    </s:sequence>

                </s:complexType>

            </s:element>

            <s:element name="ExecuteRequestResponse">

                <s:complexType>

                    <s:sequence>

                        <s:element minOccurs="0" maxOccurs="1" 
name="ExecuteRequestResult">

                            <s:complexType mixed="true">

                                <s:sequence>

                                    <s:any />

                                </s:sequence>

                            </s:complexType>

                        </s:element>

                    </s:sequence>

                </s:complexType>

            </s:element>

            <s:element name="ExecuteRequestCompressed">

                <s:complexType>

                    <s:sequence>

                        <s:element minOccurs="0" maxOccurs="1" 
name="xmlMessage">

                            <s:complexType mixed="true">

                                <s:sequence>

                                    <s:any />

                                </s:sequence>

                            </s:complexType>

                        </s:element>

                    </s:sequence>

                </s:complexType>

            </s:element>

            <s:element name="ExecuteRequestCompressedResponse">

                <s:complexType>

                    <s:sequence>

                        <s:element minOccurs="0" maxOccurs="1" 
name="ExecuteRequestCompressedResult">

                            <s:complexType mixed="true">

                                <s:sequence>

                                    <s:any />

                                </s:sequence>

                            </s:complexType>

                        </s:element>

                    </s:sequence>

                </s:complexType>

            </s:element>

        </s:schema>

    </wsdl:types>

    <wsdl:message name="ExecuteRequestSoapIn">

        <wsdl:part name="parameters" element="tns:ExecuteRequest" />

    </wsdl:message>

    <wsdl:message name="ExecuteRequestSoapOut">

        <wsdl:part name="parameters" element="tns:ExecuteRequestResponse" 
/>

    </wsdl:message>

    <wsdl:message name="ExecuteRequestCompressedSoapIn">

        <wsdl:part name="parameters" 
element="tns:ExecuteRequestCompressed" />

    </wsdl:message>

    <wsdl:message name="ExecuteRequestCompressedSoapOut">

        <wsdl:part name="parameters" 
element="tns:ExecuteRequestCompressedResponse" />

    </wsdl:message>

    <wsdl:portType name="ServicesV2Soap">

        <wsdl:operation name="ExecuteRequest">

            <wsdl:documentation xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/";>Execute the request. This method 
performs a central entry point for the systems CKI and LIS. The requests: 
registration, toets, monitor message, backoffice processing status and 
general statuses are supported.</wsdl:documentation>

            <wsdl:input message="tns:ExecuteRequestSoapIn" />

            <wsdl:output message="tns:ExecuteRequestSoapOut" />

        </wsdl:operation>

        <wsdl:operation name="ExecuteRequestCompressed">

            <wsdl:documentation xmlns:wsdl="
http://schemas.xmlsoap.org/wsdl/";>Execute the request. This method 
performs a central entry point for the systems CKI and LIS. The requests: 
registration, toets, monitor message, backoffice processing status and 
general statuses are supported.</wsdl:documentation>

            <wsdl:input message="tns:ExecuteRequestCompressedSoapIn" />

            <wsdl:output message="tns:ExecuteRequestCompressedSoapOut" />

        </wsdl:operation>

    </wsdl:portType>

    <wsdl:binding name="ServicesV2Soap" type="tns:ServicesV2Soap">

        <soap:binding transport="http://schemas.xmlsoap.org/soap/http"; />

        <wsdl:operation name="ExecuteRequest">

            <soap:operation soapAction="
http://services.bkr.nl/servicesv2/ExecuteRequest"; style="document" />

            <wsdl:input>

                <soap:body use="literal" />

            </wsdl:input>

            <wsdl:output>

                <soap:body use="literal" />

            </wsdl:output>

        </wsdl:operation>

        <wsdl:operation name="ExecuteRequestCompressed">

            <soap:operation soapAction="
http://services.bkr.nl/servicesv2/ExecuteRequestCompressed"; 
style="document" />

            <wsdl:input>

                <soap:body use="literal" />

            </wsdl:input>

            <wsdl:output>

                <soap:body use="literal" />

            </wsdl:output>

        </wsdl:operation>

    </wsdl:binding>

    <wsdl:binding name="ServicesV2Soap12" type="tns:ServicesV2Soap">

        <soap12:binding transport="http://schemas.xmlsoap.org/soap/http"; 
/>

        <wsdl:operation name="ExecuteRequest">

            <soap12:operation soapAction="
http://services.bkr.nl/servicesv2/ExecuteRequest"; style="document" />

            <wsdl:input>

                <soap12:body use="literal" />

            </wsdl:input>

            <wsdl:output>

                <soap12:body use="literal" />

            </wsdl:output>

        </wsdl:operation>

        <wsdl:operation name="ExecuteRequestCompressed">

            <soap12:operation soapAction="
http://services.bkr.nl/servicesv2/ExecuteRequestCompressed"; 
style="document" />

            <wsdl:input>

                <soap12:body use="literal" />

            </wsdl:input>

            <wsdl:output>

                <soap12:body use="literal" />

            </wsdl:output>

        </wsdl:operation>

    </wsdl:binding>

    <wsdl:service name="ServicesV2">

        <wsdl:documentation xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/
">Provides an interface for performing CKI, LIS toetsing and 
registration</wsdl:documentation>

        <wsdl:port name="ServicesV2Soap" binding="tns:ServicesV2Soap">

            <soap:address location="
http://msgservers:81/Services/WEBv2/ServicesV2.asmx"; />

        </wsdl:port>

        <wsdl:port name="ServicesV2Soap12" binding="tns:ServicesV2Soap12">

            <soap12:address location="
http://msgservers:81/Services/WEBv2/ServicesV2.asmx"; />

        </wsdl:port>

    </wsdl:service>

</wsdl:definitions>

We where able to fix the bad output by altering the generated code, this 
is the bad version:


        private void writeStartElement(java.lang.String prefix, 
java.lang.String namespace, java.lang.String localPart,
                                       javax.xml.stream.XMLStreamWriter 
xmlWriter) throws javax.xml.stream.XMLStreamException {
            java.lang.String writerPrefix = 
xmlWriter.getPrefix(namespace);
            if (writerPrefix != null) {
                xmlWriter.writeStartElement(namespace, localPart);
            } else {
                if (namespace.length() == 0) {
                    prefix = "";
                } else if (prefix == null) {
                    prefix = generatePrefix(namespace);
                }

                xmlWriter.writeStartElement(prefix, localPart, namespace);
                xmlWriter.writeNamespace(prefix, namespace);
                xmlWriter.setPrefix(prefix, namespace);
            }
        }

This is the adapted version (see the adapted 1st if block):


        private void writeStartElement(java.lang.String prefix, 
java.lang.String namespace, java.lang.String localPart,
                                       javax.xml.stream.XMLStreamWriter 
xmlWriter) throws javax.xml.stream.XMLStreamException {
            java.lang.String writerPrefix = 
xmlWriter.getPrefix(namespace);
            if (writerPrefix != null) {
                xmlWriter.writeStartElement(prefix, localPart, namespace);
                xmlWriter.setPrefix(prefix, namespace);
            } else {
                if (namespace.length() == 0) {
                    prefix = "";
                } else if (prefix == null) {
                    prefix = generatePrefix(namespace);
                }

                xmlWriter.writeStartElement(prefix, localPart, namespace);
                xmlWriter.writeNamespace(prefix, namespace);
                xmlWriter.setPrefix(prefix, namespace);
            }
        }


Please advise - is there something wrong with the wsdl? is there something 
wrong with the code generation?


many thanks

Reply via email to