AnsweredAssumed Answered

issues in setting parameters of NikuDataBus object for any read Request

Question asked by vivek_g on Oct 19, 2011
Latest reply on Nov 25, 2011 by ddeneer
I am trying to consume "Resources" web service to call "readResource" method .

I am able to login successfully using the service but for calling read resource we need to pass two parameters of type Auth and NikuDataBus. Plz help on how to set these parameters.

code being used by me -

Auth auth = new Auth();
auth.setUsername(login.getUsername());
auth.setPassword(login.getPassword());
auth.setSessionID(sessionID);


NikuDataBus ndb = new NikuDataBus();


File file = new File("C:\\Users\\vivek_gupta27\\Warm_up\\try_resource\\src\\mypack\\read.xml");

DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
InputStream is;

is = new FileInputStream(file);

Document doc = dbf.newDocumentBuilder().parse(is);

Object any_obj = doc;

ndb.setAny(any_obj);


NikuDataBus result = port.readResource(ndb, auth);


read.xml file being used is -

<?xml version="1.0" encoding="UTF-8" ?>
<NikuDataBus xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../xsd/nikuxog_read.xsd">

<Header version="6.0.13" action="read" objectType="resource" externalSource="NIKU">
<args name="include_contact" value="true" />
<args name="include_management" value="true" />
<args name="include_custom" value="true" />
<args name="include_financial" value="true" />
</Header>
<Query>
<Filter name="primaryRoleID" criteria="EQUALS">Developer</Filter>
<Filter name="isActive" criteria="EQUALS">true</Filter>
<Filter name="resourceType" criteria="OR">Labor</Filter>
<Filter name="resourceID" criteria="OR">wayneHill</Filter>
</Query>
</NikuDataBus>


error message -


Oct 18, 2011 11:18:30 AM org.apache.cxf.phase.PhaseInterceptorChain doDefaultLogging
WARNING: Interceptor for {http://www.niku.com/xog/Object}ResourcesService#{http://www.niku.com/xog/Object}ReadResource has thrown exception, unwinding now
org.apache.cxf.interceptor.Fault: Marshalling Error: A DOM document "class com.sun.org.apache.xerces.internal.dom.DeferredDocumentImpl" is found but an element is needed. Use Document.getDocumentElement() and set that object instead.
at org.apache.cxf.jaxb.JAXBEncoderDecoder.marshall(JAXBEncoderDecoder.java:256)
at org.apache.cxf.jaxb.io.DataWriterImpl.write(DataWriterImpl.java:169)
at org.apache.cxf.interceptor.AbstractOutDatabindingInterceptor.writeParts(AbstractOutDatabindingInterceptor.java:110)
at org.apache.cxf.interceptor.BareOutInterceptor.handleMessage(BareOutInterceptor.java:68)
at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:255)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:546)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:343)
at org.apache.cxf.endpoint.ClientImpl.invoke(ClientImpl.java:295)
at org.apache.cxf.frontend.ClientProxy.invokeSync(ClientProxy.java:73)
at org.apache.cxf.jaxws.JaxWsClientProxy.invoke(JaxWsClientProxy.java:124)
at $Proxy32.readResource(Unknown Source)
at mypack.Resource_Check.main(Resource_Check.java:128)
Caused by: javax.xml.bind.MarshalException


Please check where have i went wrong in setting up parameters of Auth or NikuDataBus before making the call. If possible , provide with the sample code on client of web service.

Outcomes