4 Replies Latest reply on Jan 19, 2015 2:02 AM by swiderski.maciej

    (S.O.S)Wildfly 8.1.0.final and JBPM6.1.0.Final : Web Service Task out of the Box Not able to call Webservice successfully where WebMethod has pojo as the argument.

    sanjay05222

      What is the flow ?

      Step 0


      parameteroasis00.png

      Define Variable vOasisNotificationCtlDto


      Step 1

      parameteroasis0.png

      Set the Pojo vOasisNotificationCtlDto ref which is Data Model as well. I use remote Api to Pass the Pojo to the First Scripting task which hidden behind the Script Panel.

      Step 2

      parameteroasis.png  Parameter is Assigned as vOasisNotificationCtlDto of Type Defined in Variable Definition in Step 0

      Step 3 POJO looks Like below

      parameteroasis000.png

      Step 4  WSDL Looks Like Below


      wsdl.png

      Work Item Config


      wi.png

      WHAT IS THE PROBLEM.

      1. When work Item sends the request to the webservice. it uses CXF dynamic client to make the request what happens is that its throws a illegal argument exception and it is really really wierd. my web service works find with SOAPUI and Simple Dynamic CXF clients in Java but it doesnt work from this Web Serice Task.


      ERROR THROWN BELOW

       

      errrr.png

      CFX Details

      1. wildfly has default cxf  2.7.11

      2. jboss-deployment-structure  excluded webservices

      3. web inf\lib  included the cxf 2.2.3 jars

       

      Finally I am not able to call SOAP webserice

      If we are not able to solve this probably will have to pick other products.  Thanks in advance.

       

        • 1. Re: (S.O.S)Wildfly 8.1.0.final and JBPM6.1.0.Final : Web Service Task out of the Box Not able to call Webservice successfully where WebMethod has pojo as the argument.
          swiderski.maciej

          as you noticed (by the exception) the class is not what web service expects. Even though it is named the same and has all the fields. You need to generate the model from wsdl directly using wsdl2java tools for example wsconsume that comes with JBoss AS. Then bundle these classes into a jar file and attach that jar as dependency of your project. Then you'll be able to use these classes as variables and they will be properly used for web service invocation.

           

          HTH

          1 of 1 people found this helpful
          • 2. Re: (S.O.S)Wildfly 8.1.0.final and JBPM6.1.0.Final : Web Service Task out of the Box Not able to call Webservice successfully where WebMethod has pojo as the argument.
            sanjay05222

            First of all thanks for reading and reviewing my problem and suggesting the possible strategy to solve this issue. I will be trying this right away and will provide you the feedback soon.

             

            Here are my thoughts. see in JBPM engine level we have this object which I have defined which is data model and the same will act as the object to invoke the cxv dynamic client apis. I checked the dynamic apis it takes in the object and then it creates the MessagePart and creates the soap message and then post it to the webservice. it should work I had tried different style of cxf clients they work all fine. I created a simple client with just the DTO as the object and passed to client.invoke(   , obj)

             

            pardon me if my understanding is little not clear. why you think that class is not the right one which webservice expects. ? if you see that com.xxx.mdsoasis.OasisNotificationCtlDto  and com.xxx.mdsoasis.OasisNotiicationCtlDto are exact class names which it is comparing.  I debugged and I saw the issue right there in the cxf apis I am not sure what the problem is I believe its the classloader issue.

             

            CXF Mentions : The JaxWsDynamicClientFactory sets the Thread context ClassLoader to a new ClassLoader that contains the classes for the generated types. If you need the original ClassLoader, make sure you save it prior to calling createClient.

             

            If i see closely the code in WebServiceWorkItemHandler  out of the box i see that this same DTO will work if we follow above note provided by them, I am not so expert on class loaders but I am thinking to extend the work item and see if I can make it flexible WebService Task. which work the way I wanted to invoke with out runing wsconsume. but lets see how far i would be successful. I have some deadlines as well.

             

            Summarize .

            1. Go ahead and pack classes which i get from wsconsume and test

            2. Have steps to extend exisitng webServiceWorkItemHandler in order to liverage from the advanced CXF WSDynamic Factory class.

            Currently if we fix the class loading issue in the before calling the createClient will solve this issue and we can use the same DTO whic is the process level to pass as Parameter to the web operation.

             

            Look at the JIRA which I have logged at the CXF Jira , actually I wanted to share the information which I have captured and where exactly the issue happens. I cannot conclude that it is a error becuase may be WebServiceWorkItemHandler. is not calling or using the CXF apis correctly and hence they are not working also the name of the classes are same but as they come from different class loaders they are having issue.

             

            https://issues.apache.org/jira/browse/CXF-6197

             

            ** I just wanted to share the information , I myself not sure on the things but thought if we share probably you might look at it might get some conclusive rationalization for the above issue.

            Thanks again for looking at the post and answering it


            look at the debugger below

            object-Item-Inspect.png    typeClass-debug-inspect.png

            This method is inside the CXF Apis , I will update the post with the class name

            Class Name :  ClientImpl


               private void checkPart(MessagePartInfo part, Object object) {

                    if (part == null || part.getTypeClass() == null || object == null) {

                        return;

                    }

                    Class<?> typeClass = part.getTypeClass();

                    if (typeClass == null) {

                        return;

                    }

                    if (typeClass.isPrimitive()) {

                        if (typeClass == Long.TYPE) {

                            typeClass = Long.class;

                        } else if (typeClass == Integer.TYPE) {

                            typeClass = Integer.class;

                        } else if (typeClass == Short.TYPE) {

                            typeClass = Short.class;

                        } else if (typeClass == Byte.TYPE) {

                            typeClass = Byte.class;

                        } else if (typeClass == Character.TYPE) {

                            typeClass = Character.class;

                        } else if (typeClass == Double.TYPE) {

                            typeClass = Double.class;

                        } else if (typeClass == Float.TYPE) {

                            typeClass = Float.class;

                        } else if (typeClass == Boolean.TYPE) {

                            typeClass = Boolean.class;

                        }

                    } else if (typeClass.isArray() && object instanceof Collection) {

                        //JAXB allows a pseudo [] <--> List equivalence

                        return;

                    }

                    if (!typeClass.isInstance(object)) {

                        throw new IllegalArgumentException("Part " + part.getName() + " should be of type "

                            + typeClass.getName() + ", not "

                            + object.getClass().getName());

                    }

                }

            I Now I may be totally wrong but just thinking load and sharing information as i said.

             

            Do you think that something can be done in below so that I dont have to create the classes.  I have observed in debugger that control doesnt not go beyond italics and bold how come client is already inside the clients map object ??

            this is another mystery I am not able to resolve when I run the debugger.

             

            protected synchronized Client getWSClient(WorkItem workItem, String interfaceRef) {

                    if (clients.containsKey(interfaceRef)) {

                       return clients.get(interfaceRef);

                    }

                   

                    String importLocation = (String) workItem.getParameter("Url");

                    String importNamespace = (String) workItem.getParameter("Namespace");

                    if (importLocation != null && importLocation.trim().length() > 0

                    && importNamespace != null && importNamespace.trim().length() > 0) {

                    Client client = dcf.createClient(importLocation, new QName(importNamespace, interfaceRef), getInternalClassLoader(), null);

                        clients.put(interfaceRef, client);

                        return client;

                    }

                   

                   

                    long processInstanceId = ((WorkItemImpl) workItem).getProcessInstanceId();

                    WorkflowProcessImpl process = ((WorkflowProcessImpl) ksession.getProcessInstance(processInstanceId).getProcess());

                    List<Bpmn2Import> typedImports = (List<Bpmn2Import>)process.getMetaData("Bpmn2Imports");

                   

                    if (typedImports != null ){

                        Client client = null;

                        for (Bpmn2Import importObj : typedImports) {

                            if (WSDL_IMPORT_TYPE.equalsIgnoreCase(importObj.getType())) {

                                try {

                                    client = dcf.createClient(importObj.getLocation(), new QName(importObj.getNamespace(), interfaceRef), getInternalClassLoader(), null);

                                    clients.put(interfaceRef, client);

                                    return client;

                                } catch (Exception e) {

                                logger.error("Error when creating WS Client", e);

                                    continue;

                                }

                            }

                        }

                    }

                    return null;

                }

             

             

            Thanks

            Sanjay Gautam

            • 3. Re: (S.O.S)Wildfly 8.1.0.final and JBPM6.1.0.Final : Web Service Task out of the Box Not able to call Webservice successfully where WebMethod has pojo as the argument.
              sanjay05222

              Maciej Swiderski wrote:

               

              as you noticed (by the exception) the class is not what web service expects. Even though it is named the same and has all the fields. You need to generate the model from wsdl directly using wsdl2java tools for example wsconsume that comes with JBoss AS. Then bundle these classes into a jar file and attach that jar as dependency of your project. Then you'll be able to use these classes as variables and they will be properly used for web service invocation.

               

              HTH

              Why do you think that the data model which i created by kie work bench "Data Modeler" same object can be passed to the CXF apis ? so that it can prepare the soap request . ?? looks like that I have to brush up on my class loading fundamentals.

              • 4. Re: (S.O.S)Wildfly 8.1.0.final and JBPM6.1.0.Final : Web Service Task out of the Box Not able to call Webservice successfully where WebMethod has pojo as the argument.
                swiderski.maciej

                wsdl generation tools might produce different class structure than the one created by data modeler and in many cases these are the ones that causes issues. And you're right they are most likely due to classloading "features".

                 

                HTH