我有一个Web服务(称为Connect)和另一个Web服务(称为Client)。我正在尝试使用生成的存根通过客户端WS调用Connect WS。存根是使用 wsdl2java maven插件创建的。
我也无法打印错误 通过SOAPUI进行检查,遇到对相应请求的以下错误。
<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>
这是调用Web Service,Connect的代码段。 “ request”是参数:
InterfaceClassService IFS = new InterfaceClassService();
wsdl.java2.InterfaceClass interfaceClass = IFS.getInterfaceClassPort();
Pojo pojo = interfaceClass.callThirdParty(request);
String response = pojo.getResponse();
return response + " Client_WSDL2Java";
这是我的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>
当我将其作为Local Camel Context运行时,它可以正常运行并完成任务, 但是,当我将其部署在Red Hat Fusion Server 7.0中时,它给了我一个错误。 捆绑软件已正确部署,并且也已启动。 这是我从服务器日志中得到的错误:
(MessageId:ID-DESKTOP-980NI68-1543911108884-98-2在ExchangeId:ID-DESKTOP-980NI68-1543911108884-98-1上)传递失败。尝试交付后用尽:1个被捕获:org.apache.camel.CamelExecutionException:在交换执行期间发生异常:Exchange [ID-DESKTOP-980NI68-1543911108884-98-1]消息历史记录---------- -------------------------------------------------- -------------------------------------------------- ------------------------- RouteId ProcessorId处理器已用(ms)[_route1] [_route1] [cxf:// bean:client_wsdl2java] [2] [_route1] [_log3] [log] [2] [_route1] [_setBody1] [setBody [bean [ref:client_wsdl2java1方法:Client_callThirdParty]]] [0] Stacktrace -------------- -------------------------------------------------- -------------------------------------------------- ---------------------
任何帮助都将被认可!! 谢谢。
编辑:蓝图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>
答案 0 :(得分:0)
客户端和Web服务中的Pojo
类的版本可能不同。例如,使用JDK的javap
实用工具进行检查。
javap -cp [path/to/jarfile] -v [your.package.Pojo]
对包含Pojo
类的Web服务的JAR文件和包含Pojo
类的客户端的JAR文件运行此命令。该命令输出很多东西,您必须在开始时找到该类的校验和。
Classfile path/to/whatever/Pojo.class
Last modified ...
MD5 checksum 99b7c66e2eb1ffe0a1ba39b65de7912d << should be same for both Pojo classes
....
比较客户端和Web服务中Pojo类的校验和。它们应该是相同的,否则,它们的版本是不同的,这可能是无法将响应转换为Pojo
类型的原因。