Search code examples
javaapache-cameljbossfuse

unable to connect web service using java stubs input String output POJO


I have a Web Service(Called Connect), and another Web Service (Called Client). I am trying to call Connect WS through Client WS using generated stubs. The stubs are created using wsdl2java maven plugin.

And I can't print the error as well Checking through SOAPUI encountering following error to the corresponding request.

<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
  <soap:Fault>
     <faultcode>soap:Server</faultcode>
     <faultstring>Exception occurred during execution on the exchange: Exchange[ID-DESKTOP-980NI68-1543911108884-98-1]</faultstring>
  </soap:Fault>

Here is a snippet of code that call the Web Service,Connect. "request" is the parameter:

InterfaceClassService IFS = new InterfaceClassService();
wsdl.java2.InterfaceClass interfaceClass = IFS.getInterfaceClassPort();
Pojo pojo = interfaceClass.callThirdParty(request);
String response = pojo.getResponse();
return  response + " Client_WSDL2Java";

this is my POM.XML:

<?xml version="1.0" encoding="UTF-8"?>
<project xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd" xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">


<modelVersion>4.0.0</modelVersion>
  <groupId>com.mycompany</groupId>
  <artifactId>camel-blueprint</artifactId>
  <version>1.0.0-SNAPSHOT</version>
  <packaging>bundle</packaging>
  <name>Camel Blueprint Quickstart</name>
  <description>Empty Camel Blueprint Example</description>
  <licenses>
    <license>
      <name>Apache License, Version 2.0</name>
      <url>http://www.apache.org/licenses/LICENSE-2.0.html</url>
      <distribution>repo</distribution>
    </license>
  </licenses>
  <properties>
    <camel.version>2.21.0.fuse-710018-redhat-00001</camel.version>
    <project.reporting.outputEncoding>UTF-8</project.reporting.outputEncoding>
    <version.maven-bundle-plugin>3.2.0</version.maven-bundle-plugin>
    <jboss.fuse.bom.version>7.1.0.fuse-710023-redhat-00001</jboss.fuse.bom.version>
    <project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
  </properties>
  <dependencyManagement>
    <dependencies>
      <dependency>
        <groupId>org.jboss.fuse</groupId>
        <artifactId>jboss-fuse-parent</artifactId>
        <version>${jboss.fuse.bom.version}</version>
        <type>pom</type>
        <scope>import</scope>
      </dependency>
    </dependencies>
  </dependencyManagement>
  <dependencies>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-core</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-blueprint</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-api</artifactId>
    </dependency>
    <dependency>
      <groupId>org.slf4j</groupId>
      <artifactId>slf4j-log4j12</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-cxf</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-transports-http-jetty</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.cxf</groupId>
      <artifactId>cxf-rt-frontend-jaxws</artifactId>
    </dependency>
    <dependency>
      <groupId>log4j</groupId>
      <artifactId>log4j</artifactId>
    </dependency>
    <dependency>
      <groupId>org.apache.camel</groupId>
      <artifactId>camel-test-blueprint</artifactId>
      <scope>test</scope>
      <exclusions>
        <exclusion>
          <artifactId>org.apache.felix.fileinstall</artifactId>
          <groupId>org.apache.felix</groupId>
        </exclusion>
      </exclusions>
    </dependency>
  </dependencies>
  <repositories>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>fuse-public-repository</id>
      <name>FuseSource Community Release Repository</name>
      <url>https://repo.fusesource.com/nexus/content/groups/public</url>
    </repository>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ga-repository</id>
      <name>Red Hat GA Repository</name>
      <url>https://maven.repository.redhat.com/ga</url>
    </repository>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ea-repository</id>
      <name>Red Hat EA Repository</name>
      <url>https://maven.repository.redhat.com/earlyaccess/all</url>
    </repository>
    <repository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>jboss-ea-repository</id>
      <name>Red Hat JBoss Early Access Repository</name>
      <url>http://repository.jboss.org/nexus/content/groups/ea</url>
    </repository>
  </repositories>
  <pluginRepositories>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>fuse-public-repository</id>
      <name>FuseSource Community Release Repository</name>
      <url>https://repo.fusesource.com/nexus/content/groups/public</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ga-repository</id>
      <name>Red Hat GA Repository</name>
      <url>https://maven.repository.redhat.com/ga</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>red-hat-ea-repository</id>
      <name>Red Hat EA Repository</name>
      <url>https://maven.repository.redhat.com/earlyaccess/all</url>
    </pluginRepository>
    <pluginRepository>
      <releases>
        <enabled>true</enabled>
        <updatePolicy>never</updatePolicy>
      </releases>
      <snapshots>
        <enabled>false</enabled>
      </snapshots>
      <id>jboss-ea-repository</id>
      <name>Red Hat JBoss Early Access Repository</name>
      <url>http://repository.jboss.org/nexus/content/groups/ea</url>
    </pluginRepository>
  </pluginRepositories>
  <build>
    <defaultGoal>install</defaultGoal>
    <plugins>
      <plugin>
        <groupId>org.apache.felix</groupId>
        <artifactId>maven-bundle-plugin</artifactId>
        <version>${version.maven-bundle-plugin}</version>
        <extensions>true</extensions>
        <configuration>
          <instructions>
            <Bundle-SymbolicName>client_wsdl2java</Bundle-SymbolicName>
            <Bundle-Name>Empty Camel Blueprint Example [client_wsdl2java]</Bundle-Name></instructions></configuration>
      </plugin>
      <plugin>
        <artifactId>maven-compiler-plugin</artifactId>
        <version>3.7.0</version>
        <configuration>
          <source>1.8</source>
          <target>1.8</target>
        </configuration>
      </plugin>
      <plugin>
        <artifactId>maven-resources-plugin</artifactId>
        <version>3.0.2</version>
        <configuration>
          <encoding>UTF-8</encoding>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.camel</groupId>
        <artifactId>camel-maven-plugin</artifactId>
        <version>${camel.version}</version>
        <configuration>
          <useBlueprint>true</useBlueprint>
        </configuration>
      </plugin>
      <plugin>
        <groupId>org.apache.cxf</groupId>
        <artifactId>cxf-codegen-plugin</artifactId>
        <executions>
          <execution>
            <id>generate-sources</id>
            <phase>generate-sources</phase>
            <goals>
              <goal>wsdl2java</goal>
            </goals>
            <configuration>
              <sourceRoot>${project.build.directory}/generated/cxf</sourceRoot>
              <wsdlOptions>
                <wsdlOption>
                  <wsdl>${basedir}/src/main/resources/myService.wsdl</wsdl>
                </wsdlOption>
              </wsdlOptions>
            </configuration>
          </execution>
        </executions>
      </plugin>
    </plugins>
  </build>
</project>

When I run it as Local Camel Context it works fine and does the task, but when I deploy it in the red hat fuse server 7.0 it gives me an error. the bundle is deployed properly and the is started as well. here is the error that i get from server logs:

Failed delivery for (MessageId: ID-DESKTOP-980NI68-1543911108884-98-2 on ExchangeId: ID-DESKTOP-980NI68-1543911108884-98-1). Exhausted after delivery attempt: 1 caught: org.apache.camel.CamelExecutionException: Exception occurred during execution on the exchange: Exchange[ID-DESKTOP-980NI68-1543911108884-98-1] Message History --------------------------------------------------------------------------------------------------------------------------------------- RouteId ProcessorId Processor Elapsed (ms) [_route1 ] [_route1 ] [cxf://bean:client_wsdl2java ] [ 2] [_route1 ] [_log3 ] [log ] [ 2] [_route1 ] [_setBody1 ] [setBody[bean[ref:client_wsdl2java1 method:Client_callThirdParty]] ] [ 0] Stacktrace ---------------------------------------------------------------------------------------------------------------------------------------

ANY HELP WOULD BE APPRECIATED!! THANKS IN ADVANCE.

EDIT: Camel Route in blueprint DSL:

<camelContext
        id="camelContext-598b2e86-31b2-4224-8776-9eff5ac2d2254" xmlns="http://camel.apache.org/schema/blueprint">
        <route id="_route1">
            <from id="_from1" uri="cxf:bean:orderEndpoint"/>
            <log id="_log4" message="log 2 ${body}"/>
            <setBody id="_setBody1">
                <method bean="OrderEndpoint1" method="Reply"/>
            </setBody>
            <transform id="_transform1">
                <simple>${body}</simple>
            </transform>
            <log id="_log2" message="log 3 ${body}"/>
        </route>
        <!-- test route -->
        <route id="_route2">
            <from id="_from2" uri="seda:incomingValue"/>
            <log id="_log1" message=" log seda Storing ${body}"/>
        </route>
    </camelContext>

Solution

  • Perhaps there are different versions of the Pojo class in client and webservice. Check this, for example with the javap utility from a JDK.

    javap -cp [path/to/jarfile] -v [your.package.Pojo]
    

    Run this command for the JAR file of the webservice that contains the Pojo class and the JAR file of the client that contains the Pojo class. The command outputs a lot of stuff, you have to find the checksum of the class at the beginning.

    Classfile path/to/whatever/Pojo.class
    Last modified ...
    MD5 checksum 99b7c66e2eb1ffe0a1ba39b65de7912d  << should be same for both Pojo classes
    ....
    

    Compare the checksums of the Pojo classes in client and webservice. They should be same, if not, their version is different and this could be the reason the response cannot be converted to the Pojo type.