我有问题。还尝试了CFX的2.21.0版本。
WS(SOAP)有效,但REST不起作用...
我使用以下教程使用Apache Camel和CXF-RS创建REST服务:https://www.javainuse.com/camel/apache_camel_rest_cxfrs
我已经按照本教程中所示设置了代码,并正确地遵循了步骤。构建Maven项目之后,我已经能够使用创建的SNAPSHOT文件成功将捆绑软件安装在Apache Karaf上。 (创建了一个新的捆绑ID)。
当我运行命令以“启动”新创建的捆绑软件时,它似乎正常工作,没有显示任何错误。但是,当我访问本教程末尾提到的http://localhost:8181/cxf时,它说“未找到服务”:
您能告诉我什么可能导致此问题吗?
谢谢。
我的项目结构:
我的代码:
pom.xml:] >>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> <modelVersion>4.0.0</modelVersion> <groupId>com.fuseproject</groupId> <artifactId>camel-cxfrs-core</artifactId> <version>0.0.1-SNAPSHOT</version> <packaging>bundle</packaging> <repositories> <repository> <id>Central2</id> <name>Central2</name> <url>https://repo.maven.org/maven2</url> </repository> </repositories> <dependencies> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-core</artifactId> <version>2.12.0</version> </dependency> <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-cxf</artifactId> <version>2.12.0</version> </dependency> </dependencies> <build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-compiler-plugin</artifactId> <version>3.1</version> </plugin> <plugin> <groupId>org.apache.felix</groupId> <artifactId>maven-bundle-plugin</artifactId> <extensions>true</extensions> <version>2.4.0</version> </plugin> </plugins> </build> </project>
CamelProcessor.java:] >>
] >>package com.fuseproject.beans; import org.apache.camel.Exchange; import org.apache.camel.Processor; public class CamelProcessor implements Processor { public void process(Exchange exchange) throws Exception { // Get input from exchange String msg = exchange.getIn().getBody(String.class); // set output in exchange exchange.getOut().setBody("Hello World " + msg); } }
EmployeeServiceResource.java:
package com.fuseproject.beans; import javax.ws.rs.GET; import javax.ws.rs.Path; import javax.ws.rs.PathParam; @Path("/") public class EmployeeServiceResource { public EmployeeServiceResource() { } @GET @Path("/employees/{name}/") public String getCustomer(@PathParam("name") String name) { return null; } }
] >>applicationContext.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:cxf="http://camel.apache.org/schema/cxf" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xsi:schemaLocation=" http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://camel.apache.org/schema/cxf http://camel.apache.org/schema/cxf/camel-cxf.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://camel.apache.org/schema/spring http://camel.apache.org/schema/spring/camel-spring.xsd"> <cxf:rsServer id="restService" address="http://localhost:9000/employeeservice" serviceClass="com.fuseproject.beans.EmployeeServiceResource"> </cxf:rsServer> <bean id="processor" class="com.fuseproject.beans.CamelProcessor" /> <camelContext id="camelId" xmlns="http://camel.apache.org/schema/spring"> <route> <from uri="cxfrs://bean://restService" /> <process ref="processor" /> </route> </camelContext> </beans>
我正在使用以下教程使用Apache Camel和CXF-RS创建REST服务:https://www.javainuse.com/camel/apache_camel_rest_cxfrs我已经按照教程和..中所示设置了代码。 。
我有问题。还尝试了CFX的2.21.0版本。
WS(SOAP)有效,但REST不起作用...
对此有任何答案/解决方案吗?
我有问题。还尝试了CFX的2.21.0版本。
WS(SOAP)有效,但REST不起作用...