[Webinar] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

Handling optional attributes in Web Service

Posted on 2011-04-26
7
Medium Priority
?
604 Views
Last Modified: 2012-06-22
Hi, I am invoking a web service using the stub classes. When Axis converts Java object into SOAP request (on invoking _call operation), it also inserts the attributes which Ihave not set with null value. The tag looks like:

<AttributeName xmlns="" xsi:nil="true" />

The problem is that the XSD on the server does not accept "nil" value for the attribute. Either the attribute should not be there, or it should have some value other than "nil".

One way to handle this would be to apply XSLT transformation in Axis handlers to remove unwanted attributes, but I don't find it very clean.  Is there anything else I can do rmeove the unwanted attributes? May be some kind of option in Axis to include only those attributes which have been set in the Java object.

Any sugeestions please?

Thanks

Leo
0
Comment
Question by:LeoKris
  • 4
  • 3
7 Comments
 
LVL 92

Expert Comment

by:objects
ID: 35465762
Sounds like a problem with the XSD. Are both ends using the same XSD?
0
 
LVL 92

Expert Comment

by:objects
ID: 35465772
What is nillable set to in the XSD?
0
 

Author Comment

by:LeoKris
ID: 35465843
it is set to false. Here is how it looks in the stub classes:

 elemField = new org.apache.axis.description.ElementDesc();
        elemField.setFieldName("AttributeName");
        elemField.setXmlName(new javax.xml.namespace.QName("", "AttributeName"));
        elemField.setXmlType(new javax.xml.namespace.QName("urn:abc:names:xyz:ef:TRAN:2:0", "AttributeNameType"));
        elemField.setMinOccurs(0);
        elemField.setNillable(false);
        typeDesc.addFieldDesc(elemField);
0
2017 Webroot Threat Report

MSPs: Get the facts you need to protect your clients.
The 2017 Webroot Threat Report provides a uniquely insightful global view into the analysis and discoveries made by the Webroot® Threat Intelligence Platform to provide insights on key trends and risks as seen by our users.

 
LVL 92

Accepted Solution

by:
objects earned 1500 total points
ID: 35465871
What version of axis?
Theres a really old possibly related bug https://issues.apache.org/jira/browse/AXIS-2054

Also some observations here that may help
0
 

Author Comment

by:LeoKris
ID: 35465901
It is 1.4
0
 

Author Comment

by:LeoKris
ID: 35473245
thanks Objects. The link gave a patch to fix this problem. But, my situation is a bit more complex that uses multiple XSDs. So, I am using XSLT transformation (just before signing the SOAP request) to remove the tags which are nill. It works fine.

Thanks for your help.

Leo
0
 

Author Closing Comment

by:LeoKris
ID: 35473250
Though solution did not fix the problem, it helped identify that it is a bug with Axis 1.4 libraries.
0

Featured Post

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Online collaboration is quickly becoming embedded in the workplace, and its benefits are tangible. See what the current landscape looks like and what the future holds for collaboration tools and the future of work.
In this post we will learn how to make Android Gesture Tutorial and give different functionality whenever a user Touch or Scroll android screen.
The purpose of this video is to demonstrate how to set up the WordPress backend so that each page automatically generates a Mailchimp signup form in the sidebar. This will be demonstrated using a Windows 8 PC. Tools Used are Photoshop, Awesome…
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.
Suggested Courses
Course of the Month20 days, 14 hours left to enroll

810 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question