Thursday, January 20, 2011

The attribute xsi:nil="true" appears in SOAP envelope after upgrading to IS 8

During testing of our upgrade we noticed our java clients getting a new exception when getting an empty response back.
java.lang.NullPointerException
        at sun.reflect.UnsafeFieldAccessorImpl.ensureObj(UnsafeFieldAccessorImpl.java:36)
        at sun.reflect.UnsafeObjectFieldAccessorImpl.get(UnsafeObjectFieldAccessorImpl.java:18)
        at java.lang.reflect.Field.get(Field.java:358)
        at........
This was due to the returned message being different  under 7.x and 8.x:
------ 7.x ---------

<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ser-root:lookupTaxExemptResponse xmlns:ser-root="http://ns.discounttire.com/TaxExempt/v1"/>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>


------ 8.x ---------
<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
   <SOAP-ENV:Header/>
   <SOAP-ENV:Body>
      <ser-root:lookupTaxExemptResponse xsi:nil="true" xmlns:ser-root="http://ns.discounttire.com/TaxExempt/v1"/>
   </SOAP-ENV:Body>

</SOAP-ENV:Envelope>

There was a fix for this in 7.1.3 (when the problem seems to have first appeared) but it has not yet been applied to 8.x.   You have to apply the core patch (I'm assuming Core Patch 13 will have it as Patch 12 does not).

Then you also need to go to your IS web admin page -> Settings -> Extended and "Edit Extended Settings"
Add the following line:

watt.server.SOAP.generateNilTags=false
 
I haven't yet verified this as we don't have the patch yet. 
 
-------
Update:
Turns out this is the new behavior in wm8 and will not be fixed.  To get this error we were 
returning a bare list of document references.  So we switched to returning a document with a 
list of document references inside  and now as long as the list is initialized, it returns fine.  
The xsi:nil tag is inside the list, not at the top-level root element which is what caused the 
problem with java clients.

3 comments:

  1. Other option to this is to look at whether it is optional or not, I worked around this via pre-populating the empty structure on the pipeline for the mandatory items.. And maybe also it was the allow null property too.
    e.g. if you don't return a structure for a mandatory field, the IS web services layer will create it (and sticks the xsi:nil into it). If instead you create the dummy structure then it won't put that in it.

    ReplyDelete
  2. Really a nice blog Kevin, Even we found there are lots of items that are hard to figure out via the documentation and very few posts on the web about them. There are no step by step instructions for freshers or layman who want to learn webMethods. So we made http://idnxchange.com helping the community with lots of stuff to hang on.

    Integration developer network helps you in getting certified with its unique point based system. It also provides you a platform where you can further develop your knowledge by xchanging your views, knowledge and ideas with the integration community. IDN will sponsor certification to its members on reaching specified point thresholds. Moreover at IDN you can also view blog posts, webMethods videos, software, useful links, FAQ's posted by other members. IDN profile is a feature of IDN through which you can know other members technical expertise and their details.

    ReplyDelete
  3. watt.server.SOAP.generateNilTags=false worked for me.
    Version 8.2.1.0

    ReplyDelete