我正在尝试对一段CXF soap服务代码进行单元测试。该代码执行没有任何问题。但是无论我在响应中将其设置为什么,它每次都返回null。
public class MyRouteTest extends CamelTestSupport
{
private int port = AvailablePortFinder.getNextAvailable();
@Override
protected RouteBuilder createRouteBuilder() throws Exception {
return new RouteBuilder() {
@Override
public void configure() throws Exception {
JaxbDataFormat jaxb = new JaxbDataFormat();
jaxb.setContextPath("com.example");
from("cxf:http://localhost:"+port+"/test/OpenIssue?serviceClass="+OpenIssue.class.getCanonicalName())
.convertBodyTo(OpenIssueRequest.class)
.setBody(constant("OK"));
}
};
}
@Test
public void testMySoapRoute() {
OpenIssueRequest request = new OpenIssueRequest();
request.setXXX(270);
request.setYYY("A");
request.setZZZ("ABCD");
String out = template.requestBody("cxf:http://localhost:"+port+"/test/OpenIssue?serviceClass="+OpenIssue.class.getCanonicalName(),request,String.class);
assertNotNull(out);
}
}
此代码应返回“ OK”作为响应,但会返回null
答案 0 :(得分:0)
我正在使用骆驼2.15.0.redhat-630329版本。我将其更新为2.17.0.redhat-630329的驼峰版。它会自动解决。