• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Axis2 parameter ordering is wrong when not all elements are not passed

 
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi I'm using Axis2 for my webservices. My service has 5 parameters:
- <xs:sequence>
<xs:element minOccurs="0" name="CIF" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="NRIC" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="PP" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="CountryOfPPIssue" nillable="true" type="xs:string" />
<xs:element minOccurs="0" name="FIN" nillable="true" type="xs:string" />
</xs:sequence>

When the request does not passed in all the elements, Axis2 will reorder the parameter, thus screwing up my code. Eg. when the first parameter CIF is not passed in, now the second parameter NRIC becomes the first parameter CIF:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:int="http://interact.unica.ocbc.com">
<soapenv:Header/>
<soapenv:Body>
<int:getPartyId>
<int:NRIC>S7654321F</int:NRIC>
</int:getPartyId>
</soapenv:Body>
</soapenv:Envelope>

Is there something wrong in my config? Please help. Thanks.

 
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
"If the first parameter is not passed, then the second parameter becomes the first" - that makes sense to me. If the receiving side can not handle a missing parameter, why don't you send a dummy value that indicates "null" or "N/A"?
 
Masrudyn Main
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

Thanks for your reply - I was expecting Axis to figure out which parameter the request has by looking at the element name. In the example request:
<int:getPartyId>
<int:NRIC>S7654321F</int:NRIC>
</int:getPartyId>

I was passing element NRIC - so shouldn't Axis assign that to the second parameter (NRIC), instead? Or this is not how it works?

The problem here is that my Webservice is being accessed by another middleware and it will not pass any elements if they are null.

If the above is the right behaviour, does that mean I have to change my code to use name value pairs instead?
 
Lester Burnham
Rancher
Posts: 1337
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'm confused - the example you posted shows a single NRIC element. Are you saying that the actual SOAP that gets sent has the NRIC value in a CIF element? If so, are you sure that the correct setter is being called (the one for NRIC, not the one for CIF)?

If some part of the XML pipeline expects all parameter to be present, you should set appropriate minOccurs and maxOccurs values.
 
Masrudyn Main
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The SOAP request sends only the NRIC element and value but when it gets to Axis2, it interprets it as the CIF element value. I found out by printing all the parameters that has been passed to my web service class.

I've already set the minOccurs= 0 in my WSDL (see my first post). Actually the WSDL was generated by Axis2. I'm writing a bottom-up webservice

 
Masrudyn Main
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
BTW, it seems to me that Axis2 is processing the parameters by position rather than by name. This is the first time I am using Axis2 for writing webservices. Is that how Axis2 behaves?
 
reply
    Bookmark Topic Watch Topic
  • New Topic