File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
Masrudyn Main
Greenhorn
Posts: 20
  • 0
  • Mark post as helpful
  • send pies
  • 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.

 
Lester Burnham
Rancher
Posts: 1337
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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
  • 0
  • Mark post as helpful
  • send pies
  • 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?
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic