[ 
http://issues.apache.org/jira/browse/AXIS2-1129?page=comments#action_12433934 ] 
            
Derek Foster commented on AXIS2-1129:
-------------------------------------

Ajith is correct in that there is a typo in the example that I posted, but he 
is wrong when he suggests that this bug report is a result of user error (at 
least, for the reason stated). The line

final FullDocument full = Full.Factory.newInstance(); 

should indeed be:

final FullDocument full = FullDocument.Factory.newInstance();

This is the way that it is and has always been in my actual code (note that the 
first version doesn't even compile). I apparently accidentally modified it when 
I posted the bug report (probably because I did some search-and-replace on the 
code and WSDL to try to avoid exposing too much proprietary information in a 
public forum like this one).

However, it is the second, correctly compiling, version of the code that 
exhibits the error that I described. And it is a real error.

As far as generating the object structure, I cannot do this in my application 
because the entire purpose of my server is to receive a chunk of (large, 
complicated) XML via SOAP from an external source, and pass on a slightly 
modified version of the raw XML via a socket connection to an external 
destination. For test purposes, I need to feed it "canned" XML as if received 
from the external source. Therefore, my test client builds a SOAP message 
including this "canned" XML, then transmits it to the server, where the server 
can parse it as it normally would and send it to the destination. Generating 
the object structure is not a realistic option here, and would require writing 
thousands of lines of code. This makes no sense, especially since the 
XML-to-Objects translation is exactly what the parse() methods are supposed to 
do, if they were working correctly.

Anyway, I think that it is a pretty major problem if the parse() methods 
generate incorrect results which are different from those which are produced by 
constructing the objects programmatically, which is what Ajith seems to be 
saying. Those two ways of constructing objects are supposed to produce 
identical results. Otherwise, what's the purpose of having parse methods at all?

Although I understand Eran's desire to get Axis 1.1 out the door, I still think 
that this is a major bug deserving of being a blocker. It is going to be a 
nasty surprise to anyone trying to parse XML with XMLBeans (which is, after 
all, what XMLBeans are for) to find out that the parse() methods don't work as 
expected, and instead end up constructing objects containing redundant 
information. Being able to correctly parse XML with XMLBeans to build a an 
object structure capable of being transmitted via SOAP does not seem to me to 
be a particularly exotic or rarely used feature. This is the sort of problem 
that I think should have been fixed prior to the Axis2 1.0 release, really.


> Doubled wrapper elements around XMLBeans-generated XML
> ------------------------------------------------------
>
>                 Key: AXIS2-1129
>                 URL: http://issues.apache.org/jira/browse/AXIS2-1129
>             Project: Apache Axis 2.0 (Axis2)
>          Issue Type: Bug
>          Components: core, om, wsdl, client-api, databinding
>    Affects Versions: 1.0
>            Reporter: Derek Foster
>
> I recently noticed a big problem in how Axis2 generates XML for  XMLBeans 
> objects. It appears to be creating the wrapper element around
> an XMLBean twice, thus generating erroneous XML for a SOAP message. This 
> appears to be a big problem that would affect a lot of web services, and is 
> making it impossible for my company to use Axis2 to talk to our server.
> This error was found in the latest nightly build (September 8), but has 
> apparently been around for some time.
> I have a particular WSDL, as follows:
> <?xml version="1.0" encoding="UTF-8"?>
> <definitions name="FDefinitions"
>    targetNamespace="http://www.c-corp.com/wsdl/2004-10-01/F";
>    xmlns:tns="http://www.c-corp.com/wsdl/2004-10-01/F";
>    xmlns:c="http://www.c-corp.com/wsdl/2004-10-01/c";
>    xmlns:F="http://www.dummy-temp-address";
>    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/";
>    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/";
>    xmlns:xs="http://www.w3.org/2001/XMLSchema";
>    xmlns="http://schemas.xmlsoap.org/wsdl/";>
>    <types>
>       <xs:schema targetNamespace="http://www.c-corp.com/wsdl/2004-10-01/F";>
>          <xs:import namespace="http://www.dummy-temp-address"; 
> schemaLocation="F.xsd"/>
>          <xs:element name="return" type="xs:string"/>
>          <xs:element name="failure" type="xs:string"/>
>       </xs:schema>
>       <xs:schema targetNamespace="http://www.c-corp.com/wsdl/2004-10-01/c";>
>          <xs:element name="CPassword" type="xs:string"/>
>          <xs:element name="CLogin" type="xs:string"/>
>       </xs:schema>
>    </types>
>    <message name="FEvent">
>       <part name="contents" element="F:full"/>
>    </message>
>    <message name="FResponse">
>       <part name="return" element="tns:return"/>
>    </message>
>    <message name="CPassword">
>       <part name="CPassword" element="c:CPassword"/>
>    </message>
>    <message name="CLogin">
>       <part name="CLogin" element="c:CLogin"/>
>    </message>
>    <message name="Failure">
>       <part name="faultDetail" element="tns:failure"/>
>    </message>
>    <portType name="FPortType">
>       <documentation>F Port Type</documentation>
>       <operation name="acceptFEvent" parameterOrder="contents">
>          <input name="acceptFEventRequest" message="tns:FEvent"/>
>          <output name="acceptFEventResponse" message="tns:FResponse"/>
>          <fault name="Failure" message="tns:Failure"/>
>       </operation>
>    </portType>
>    <binding name="FSoapBinding" type="tns:FPortType">
>       <documentation>F Soap Binding</documentation>
>       <soap:binding style="document" 
> transport="http://schemas.xmlsoap.org/soap/http"/>
>       <operation name="acceptFEvent">
>          <soap:operation soapAction="acceptFEventAction"/>
>          <input>
>             <soap:header message="tns:CLogin" part="CLogin" use="literal"/>
>             <soap:header message="tns:CPassword" part="CPassword" 
> use="literal"/>
>             <soap:body use="literal"/>
>          </input>
>          <output>
>             <soap:body use="literal"/>
>          </output>
>          <fault name="Failure">
>             <soap:fault name="Failure" use="literal"/>
>          </fault>
>       </operation>
>    </binding>
>    <service name="FService">
>       <documentation>F Web Service</documentation>
>       <port name="FPort" binding="tns:FSoapBinding">
>          <soap:address 
> location="http://localhost:8080/axis/services/FService"/>
>       </port>
>    </service>
> </definitions>
> My WSDL references the following XML schema:
> <?xml version="1.0" encoding="UTF-8"?>
> <xs:schema targetNamespace="http://www.dummy-temp-address";
>            xmlns="http://www.dummy-temp-address";
>            xmlns:xs="http://www.w3.org/2001/XMLSchema";
>            xmlns:c="http://www.c-corp.com/schemas/c/schema_annotation";
>            elementFormDefault="unqualified"
>            attributeFormDefault="unqualified"
>            version="DRAFT">
>    <xs:element name="full" type="Full"/>
>    <xs:complexType name="Full">
>       <xs:sequence>
>          <xs:element name="message-header" type="MessageHeader"/>
>          <xs:element name="event-reference" type="EventReference"/>
>          <xs:any/>
>       </xs:sequence>
>    </xs:complexType>
>    <xs:complexType name="MessageHeader">
>       <xs:sequence>
>          <xs:any/>
>       </xs:sequence>
>    </xs:complexType>
>    <xs:complexType name="EventReference">
>       <xs:sequence>
>          <xs:element name="event-id" type="xs:string"/>
>          <xs:element name="update" type="xs:unsignedInt"/>
>          <xs:element name="response-plan-id" type="xs:string" minOccurs="0"/>
>       </xs:sequence>
>    </xs:complexType>
> </xs:schema>
> After running WSDL2Java to generate the appropriate classes, I am using the 
> following code to generate and transmit a client message to my SOAP server:
>    protected ReturnDocument executeTest (
>       final String targetEndpoint,
>       final CLoginDocument login,
>       final CPasswordDocument password )
>       throws Exception
>    {
>       final FServiceStub service = new FServiceStub( null, targetEndpoint );
>       final Options options = service._getServiceClient().getOptions();
>       options.setProperty( 
> org.apache.axis2.transport.http.HTTPConstants.CHUNKED, Boolean.FALSE );
>       service._getServiceClient().setOptions( options );
>       final FullDocument full = Full.Factory.newInstance();
>       full.setFull( getSituation() );
>       return service.acceptFEvent( full, login, password );
>    }
>    private Full getSituation ()
>       throws XmlException
>    {
>       return Full.Factory.parse(
>          "   <full xmlns=\"http://www.dummy-temp-address\";>\n" +
>             "      <message-header>\n" +
> ... and so forth: see output for the rest of this string ...
>             "      </details>\n" +
>             "   </full>\n" );
>    }
> When I execute the above code, I get the following message sent to my server:
> POST /axis2/services/FService HTTP/1.1
> SOAPAction: acceptFEventAction
> User-Agent: Axis2
> Host: 127.0.0.1
> Content-Length: 8785
> Content-Type: text/xml; charset=UTF-8
> <?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope 
> xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/";><soapenv:Header><CLogin
>  
> xmlns="http://www.c-corp.com/wsdl/2004-10-01/c";>admin</CLogin></soapenv:Header><soapenv:Body><full
>  xmlns="http://www.dummy-temp-address";><full>
>       <message-header>
>          <sender>
>             <organization-id>QSenderOrganizationID</organization-id>
>             <center-id>QSenderCenterID</center-id>
>          </sender>
>          <message-type-version>1</message-type-version>
>          <message-number>435</message-number>
>          <message-time-stamp>
>             <date>20040625</date>
>             <time>201225</time>
>             <utc-offset>-0400</utc-offset>
>          </message-time-stamp>
>          <message-expiry-time>
>             <date>20040625</date>
>             <time>221222</time>
>             <utc-offset>-0400</utc-offset>
>          </message-expiry-time>
>       </message-header>
>       <event-reference>
>          <event-id>1234</event-id>
>          <update>1</update>
>       </event-reference>
>       <event-indicators>
>          <event-indicator>
>             <priority>4</priority>
>          </event-indicator>
>       </event-indicators>
>       <headline>
>          <headline>
>             <incident>accident</incident>
>          </headline>
>       </headline>
>       <details>
>       </details>
>    </full></full></soapenv:Body></soapenv:Envelope>
> Note that there is a doubled 'full' element in the output (one inside the 
> other). There should be only one level of 'full', but there are two,
> one inside the other. This is very wrong, and is unsurprisingly rejected by 
> my server.
> Calling toString() on the results of getSituation() returns the string that 
> was passed into the Factory.parse() method as I would expect.
> Calling toString() on the FullDocument instance results in two levels of 
> 'full', not one as it should.
> It occurred to me that maybe I should not be including a declaration for 
> 'full' in the string passed to Factory.parse() (note that there is no 
> documentation as to what should be passed into Factory.parse(),making it 
> difficult to interpret), so I tried omitting the outer 'full' tag and its 
> close tag, and just included the elements that it contains. However, when 
> doing this, I got errors from the parse method complaining
> that there was more than one element present in the string being parsed. So 
> although it seems to be possible to generate correct XML via this method as 
> long as there is only a single child element of the 'full' element, this is 
> not an acceptable solution in my case.
> I tried changing the declaration of the 'full' element so that it had 
> minOccurs=0 maxOccurs="unbounded". This caused WSDL2Java to declare the type 
> of it as an array rather than a single instance. However, this merely meant 
> that each element in the array was surrounded by two 'full' tags, rather than 
> one.
> This seems to me to be a fairly blatant error which would affect almost all 
> use of XMLBeans binding. I would like to have this considered
> a blocker for Axis 1.1. 
> Derek

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: 
http://issues.apache.org/jira/secure/Administrators.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]

Reply via email to