axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "John G. Norman" <j...@7fff.com>
Subject Re: Axis2 1.2 sanity check: Can generated POJO service/client handle 0-length array?
Date Thu, 24 May 2007 13:05:09 GMT
See note after exception trace below.

Dims, if you advise, I will add some code to the POJO example code shipped
with Axis 1.2, and will add to Jira.

Also see after the exception trace below for a note about the POJO service.

Here's a summary:

In the Java POJO service:

    return new Job[0];

In the WSDL:

<xs:element name="getJobsLaunchedResponse">
    <xs:complexType>
    <xs:sequence>
<xs:element maxOccurs="unbounded" name="return" nillable="true"
type="ns:Job"/>
</xs:sequence>
</xs:complexType>
</xs:element>

<wsdl:operation name="getJobsLaunched">
<wsdl:input message="axis2:getJobsLaunchedMessage"
wsaw:Action="urn:getJobsLaunched"/>
<wsdl:output message="axis2:getJobsLaunchedResponse"/>
<wsdl:fault message="axis2:getJobsLaunchedFault"
name="getJobsLaunchedFault"/>
</wsdl:operation>

In the response that gets a client-side exception (exception trace below):

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:getJobsLaunchedResponse
xmlns:ns="http://v00.services.exampleco.com/xsd"
/></soapenv:Body></soapenv:Envelope>

An example of a good response:

<?xml version='1.0' encoding='UTF-8'?><soapenv:Envelope xmlns:soapenv="
http://schemas.xmlsoap.org/soap/envelope/"><soapenv:Body><ns:getJobsLaunchedResponse
xmlns:ns="http://v00.services.exampleco.com/xsd"><ns:return><description
xmlns="http://v00.services.exampleco.com/xsd">The bottle-washer has many
responsibilities.</description><discontinued xmlns="
http://v00.services.exampleco.com/xsd">false</discontinued><fee xmlns="
http://v00.services.exampleco.com/xsd">300</fee><jid xmlns="
http://v00.services.exampleco.com/xsd">ZWEWprOZEZSCWLPndg4-vqD2xKI</jid><location
xmlns="http://v00.services.exampleco.com/xsd">Cambridge</location><name
xmlns="http://v00.services.exampleco.com/xsd">bottle-washer</name><organization
xmlns="http://v00.services.exampleco.com/xsd">exampleco.com</organization><payment
xmlns="http://v00.services.exampleco.com/xsd">5000</payment><reference
xmlns="http://v00.services.exampleco.com/xsd">JOB-001</reference><referralId
xmlns="http://v00.services.exampleco.com/xsd">iQSF587mI9niSrA5E2C1kP4qTaQ</referralId></ns:return><ns:return><description
xmlns="http://v00.services.exampleco.com/xsd">The bottle-washer has many
responsibilities.</description><discontinued xmlns="
http://v00.services.exampleco.com/xsd">false</discontinued><fee xmlns="
http://v00.services.exampleco.com/xsd">300</fee><jid xmlns="
http://v00.services.exampleco.com/xsd">gkQqnYvQ3wT48vbcWznqhds3Syo</jid><location
xmlns="http://v00.services.exampleco.com/xsd">Cambridge</location><name
xmlns="http://v00.services.exampleco.com/xsd">bottle-washer</name><organization
xmlns="http://v00.services.exampleco.com/xsd">exampleco.com</organization><payment
xmlns="http://v00.services.exampleco.com/xsd">5000</payment><reference
xmlns="http://v00.services.exampleco.com/xsd">JOB-001</reference><referralId
xmlns="http://v00.services.exampleco.com/xsd
">f823FbOqFKoT7OrTNd238HO2lx0</referralId></ns:return></ns:getJobsLaunchedResponse></soapenv:Body></soapenv:Envelope>



Exception trace:

com.exampleco.clients.ServiceException: java.lang.RuntimeException:
java.lang.RuntimeException: Unexpected subelement getJobsLaunchedResponse
    at

[much deleted, then . . .]

Caused by: java.lang.RuntimeException: java.lang.RuntimeException:
Unexpected subelement getJobsLaunchedResponse
    at com.exampleco.generated.stubs.ReferralServiceStub.fromOM(
ReferralServiceStub.java:17392)
    at com.exampleco.generated.stubs.ReferralServiceStub.getJobsLaunched(
ReferralServiceStub.java:557)
    at com.exampleco.clients.impl.ReferralServiceImpl.getJobsLaunched(
ReferralServiceImpl.java:156)
    ... 17 more
Caused by: java.lang.RuntimeException: Unexpected subelement
getJobsLaunchedResponse
    at
com.exampleco.generated.stubs.ReferralServiceStub$GetJobsLaunchedResponse$Factory.parse
(ReferralServiceStub.java:16924)
    at com.exampleco.generated.stubs.ReferralServiceStub.fromOM(
ReferralServiceStub.java:17281)
    ... 19 more


-----

So much is right about the POJO service apparatus. But if I had to put my
finger on something that would improve it, it would be making the sample
application (the weather one) a bit more complicated. The three things I
would add to that application, to make it resemble a bit more what happens
in the real world, would be: (1) A method than returns void; (2) A method
that throws exceptions that the client is expected to catch; (3) returning
arrays, and zero-length arrays.

One of the reasons that beefing up this example would help is because there
is so much churn on the list regarding these topics. The POJO service
apparatus is very close to following the 80/20 paradigm for the bulk of
simple Java cases.


On 5/23/07, Davanum Srinivas <davanum@gmail.com> wrote:
>
> It seems like the schema in the wsdl might need a tweak as the adb
> generated code is expecting at least 1. could you try saving the wsdl
> and tweaking the schema (minOccurs/maxOccurs) and then codegen using
> the tweaked wsdl. If you make no headway, please log a bug with your
> javabean/wsdl etc.
>
> thanks,
> dims
>
> On 5/23/07, John G. Norman <john@7fff.com> wrote:
> > Thanks, dims.
> >
> > I'm returning an array of javabeans. So it's like:
> >
> > return new Thingy[0];
> >
> > (Returning many of them is fine; returning one of them is fine.)
> >
> >
> > On 5/23/07, Davanum Srinivas <davanum@gmail.com> wrote:
> > >
> > > Say you are returning an array of strings...are you doing this?
> > >
> > > return new String[0];
> > >
> > > or this?
> > >
> > > return null;
> > >
> > > thanks,
> > > dims
> > >
> > > On 5/23/07, John G. Norman < john@7fff.com> wrote:
> > > > Hi.
> > > >
> > > > My Axis2 1.2 POJO service
> > > > (http://ws.apache.org/axis2/1_2/pojoguide.html) can
> > return
> > > > an array of length 0.
> > > >
> > > > Does anyone know definitively if this will work with a vanilla
> client
> > > > generated with org.apache.axis2.tool.ant.AntCodegenTask
> > > > taking all of the defaults?
> > > >
> > > > (I.e., I'm trying to leverage as much of the auto-generated stuff as
> > > > possible.)
> > > >
> > > > At present, my client is generating a runtime exception: unexpected
> > > > subelement.
> > > >
> > > > Before I start going into this, if anyone has a proof case that a
> > 0-length
> > > > array can be successfully returned, I would appreciate it.
> > > >
> > > > I'm not going to paste in the XML 'cos I'm more concerned to know if
> > anyone
> > > > can confirm the successful case, before I start to debug.
> > > >
> > > >
> > >
> > >
> > > --
> > > Davanum Srinivas :: http://davanum.wordpress.com
> > >
> > >
> > ---------------------------------------------------------------------
> > > To unsubscribe, e-mail:
> > axis-user-unsubscribe@ws.apache.org
> > > For additional commands, e-mail: axis-user-help@ws.apache.org
> > >
> > >
> >
> >
>
>
> --
> Davanum Srinivas :: http://davanum.wordpress.com
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: axis-user-unsubscribe@ws.apache.org
> For additional commands, e-mail: axis-user-help@ws.apache.org
>
>

Mime
View raw message