Hi Chamila, Can you please attach the error stack-trace you are getting ?
Thanks. On Thu, Sep 17, 2015 at 9:43 AM, Chamila Wijayarathna <cham...@wso2.com> wrote: > Hi all, > > Currently I am trying to call some methods of BPS-HumanTaskClientAPIAdmin > from an IS back end component. To do this I have added > "HumanTaskClientAPIAdmin.wsdl", "ws-humanyask-types.xsd" and "xml.xsd" > files to currently existing service stub at IS, which is > org.wso2.carbon.identity.workflow.mgt.bps.stub > [1]. I took the HumanTaskClientAPIAdmin.wsdl from a latest BPS pack and > other 2 files from [2]. > I newly added following task to the pom.xml of the service stub. > > > > > > > > *<java classname="org.apache.axis2.wsdl.WSDL2Java" fork="true"> <arg > line="-uri src/main/resources/HumanTaskUploader.wsdl -u -uw -o > target/generated-code -p org.wso2.carbon.humantask.stub.upload -ns2p > http://services.deployer.humantask.carbon.wso2.org > <http://services.deployer.humantask.carbon.wso2.org>=org.wso2.carbon.humantask.stub.upload,http://services.deployer.humantask.carbon.wso2.org/xsd=org.wso2.carbon.humantask.stub.upload.types > > <http://services.deployer.humantask.carbon.wso2.org/xsd=org.wso2.carbon.humantask.stub.upload.types>"/> > <classpath refid="maven.dependency.classpath"/> <classpath > refid="maven.compile.classpath"/> <classpath > refid="maven.runtime.classpath"/></java>* > > In my backend component where I need to call the methods of this stub, we > already had a dependency to the stub. > > > *<dependency>* > > > > * <groupId>org.wso2.carbon.identity</groupId> > <artifactId>org.wso2.carbon.identity.workflow.mgt.bps.stub</artifactId></dependency>* > > Then I added following code to call the service through the stub. > > > > > > > > > > > > > > > > > > > > > *int tenantId = > CarbonContext.getThreadLocalCarbonContext().getTenantId();List<BPSProfileDTO> > bpsProfiles = > bpsProfileDAO.listBPSProfiles(tenantId);HumanTaskClientAPIAdminStub stub = > null;TSimpleQueryInput input = new TSimpleQueryInput();TStatus readyState = > new TStatus();//TSimpleQueryCategory queryCategory = new > TSimpleQueryCategory("ALL_TASKS", > true);readyState.setTStatus("READY");input.addStatus(readyState);input.setPageSize(100000);input.setPageNumber(0);input.setSimpleQueryCategory(TSimpleQueryCategory.ALL_TASKS);for > (int i = 0; i < bpsProfiles.size(); i++) { String host = > bpsProfiles.get(i).getHost(); URL servicesUrl = new URL(new URL(host), > "services/HumanTaskClientAPIAdmin"); stub = new > HumanTaskClientAPIAdminStub(servicesUrl.toString()); ServiceClient client > = stub._getServiceClient(); authenticate(client, > bpsProfiles.get(i).getUsername(), bpsProfiles.get(i).getUsername()); > TTaskSimpleQueryResultSet results = stub.simpleQuery(input);}* > > But when I call the stub.simpleQuery() method I am getting an error without > any details and when I debugged the code, I found out that it gives a *Method > threw 'java.lang.LinkageError' exception. Cannot evaluate > org.apache.axiom.soap.impl.llom.soap11.SOAP11BodyImpl.toString()* > error at auto generated stub method while creating the SOAP envelope. > Following is the auto generated code for above method. > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > *public > org.wso2.carbon.identity.workflow.mgt.bps.stub.types.TTaskSimpleQueryResultSet > simpleQuery( > org.wso2.carbon.identity.workflow.mgt.bps.stub.types.TSimpleQueryInput > simpleQueryInput587) throws > java.rmi.RemoteException > ,org.wso2.carbon.humantask.stub.upload.IllegalStateFault > ,org.wso2.carbon.humantask.stub.upload.IllegalArgumentFault{ > org.apache.axis2.context.MessageContext _messageContext = null; try{ > org.apache.axis2.client.OperationClient _operationClient = > _serviceClient.createClient(_operations[22].getName()); > _operationClient.getOptions().setAction("http://docs.oasis-open.org/ns/bpel4people/ws-humantask/api/200803/simpleQuery > > <http://docs.oasis-open.org/ns/bpel4people/ws-humantask/api/200803/simpleQuery>"); > _operationClient.getOptions().setExceptionToBeThrownOnSOAPFault(true); > > addPropertyToOperationClient(_operationClient,org.apache.axis2.description.WSDL2Constants.ATTR_WHTTP_QUERY_PARAMETER_SEPARATOR,"&"); > // create a message context _messageContext = new > org.apache.axis2.context.MessageContext(); // create SOAP envelope > with that payload org.apache.axiom.soap.SOAPEnvelope env = null; > org.oasis_open.docs.ns.bpel4people.ws_humantask.api._200803.SimpleQuery > dummyWrappedType = null; env = > toEnvelope(getFactory(_operationClient.getOptions().getSoapVersionURI()), > simpleQueryInput587, > dummyWrappedType, > optimizeContent(new > javax.xml.namespace.QName("http://docs.oasis-open.org/ns/bpel4people/ws-humantask/api/200803 > <http://docs.oasis-open.org/ns/bpel4people/ws-humantask/api/200803>", > "simpleQuery"))); > //adding SOAP soap_headers > _serviceClient.addHeadersToEnvelope(env);// set the message context with that > soap envelope_messageContext.setEnvelope(env);// add the message contxt to > the operation > client_operationClient.addMessageContext(_messageContext);//execute the > operation client_operationClient.execute(true); > org.apache.axis2.context.MessageContext _returnMessageContext = > _operationClient.getMessageContext( > org.apache.axis2.wsdl.WSDLConstants.MESSAGE_LABEL_IN_VALUE); > org.apache.axiom.soap.SOAPEnvelope _returnEnv = > _returnMessageContext.getEnvelope(); > java.lang.Object object = fromOM( > _returnEnv.getBody().getFirstElement() , > org.oasis_open.docs.ns.bpel4people.ws_humantask.api._200803.SimpleQueryResponse.class, > getEnvelopeNamespaces(_returnEnv)); > return > getSimpleQueryResponseTaskSimpleQueryResultSet((org.oasis_open.docs.ns.bpel4people.ws_humantask.api._200803.SimpleQueryResponse)object); > }catch(org.apache.axis2.AxisFault f){ > org.apache.axiom.om.OMElement faultElt = f.getDetail(); if > (faultElt!=null){ if (faultExceptionNameMap.containsKey(new > org.apache.axis2.client.FaultMapKey(faultElt.getQName(),"simpleQuery"))){ > //make the fault by reflection try{ > java.lang.String exceptionClassName = > (java.lang.String)faultExceptionClassNameMap.get(new > org.apache.axis2.client.FaultMapKey(faultElt.getQName(),"simpleQuery")); > java.lang.Class exceptionClass = > java.lang.Class.forName(exceptionClassName); > java.lang.Exception ex = (java.lang.Exception) exceptionClass.newInstance(); > //message class java.lang.String > messageClassName = (java.lang.String)faultMessageMap.get(new > org.apache.axis2.client.FaultMapKey(faultElt.getQName(),"simpleQuery")); > java.lang.Class messageClass = > java.lang.Class.forName(messageClassName); java.lang.Object > messageObject = fromOM(faultElt,messageClass,null); > java.lang.reflect.Method m = exceptionClass.getMethod("setFaultMessage", > new java.lang.Class[]{messageClass}); > m.invoke(ex,new java.lang.Object[]{messageObject}); > if (ex instanceof > org.wso2.carbon.humantask.stub.upload.IllegalStateFault){ > throw (org.wso2.carbon.humantask.stub.upload.IllegalStateFault)ex; > } if (ex instanceof > org.wso2.carbon.humantask.stub.upload.IllegalArgumentFault){ > throw (org.wso2.carbon.humantask.stub.upload.IllegalArgumentFault)ex; > } throw new > java.rmi.RemoteException(ex.getMessage(), ex); > }catch(java.lang.ClassCastException e){ // we cannot intantiate > the class - throw the original Axis fault throw f; > } catch (java.lang.ClassNotFoundException e) { // we cannot > intantiate the class - throw the original Axis fault throw f; > }catch (java.lang.NoSuchMethodException e) { // we > cannot intantiate the class - throw the original Axis fault > throw f; } catch (java.lang.reflect.InvocationTargetException e) { > // we cannot intantiate the class - throw the original Axis > fault throw f; } catch > (java.lang.IllegalAccessException e) { // we cannot intantiate > the class - throw the original Axis fault throw f; > } catch (java.lang.InstantiationException e) { // we cannot > intantiate the class - throw the original Axis fault throw f; > } }else{ throw f; } }else{ throw > f; } } finally { if (_messageContext.getTransportOut() != null) > { > _messageContext.getTransportOut().getSender().cleanup(_messageContext); > } }}* > > What is the issue here? Am I missing anything at creating stub? How can I > overcome this? > > Thank You! > > 1. > https://github.com/wso2/carbon-identity/tree/master/service-stubs/identity/org.wso2.carbon.identity.workflow.mgt.bps.stub > 2. > https://github.com/wso2/carbon-business-process/tree/master/service-stubs/humantask/org.wso2.carbon.humantask.stub/src/main/resources > > -- > *Chamila Dilshan Wijayarathna,* > Software Engineer > Mobile:(+94)788193620 > WSO2 Inc., http://wso2.com/ > > _______________________________________________ > Dev mailing list > Dev@wso2.org > http://wso2.org/cgi-bin/mailman/listinfo/dev > > -- Kasun Bandara *Software Engineer* Mobile : +94 (0) 718 338 360 <%2B94%20%280%29%20773%20451194> kas...@wso2.com <thili...@wso2.com>
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev