我试图使用Camel公开JAX-WS Web服务(带注释的Java类)。使用单个参数时,Web服务会正确回复。另一方面,当使用Object或多个参数作为参数时,它不起作用。
以下是我在JBoss Fuse上部署的蓝图:
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0" xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf" xmlns:cxf="http://cxf.apache.org/blueprint/core" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd http://camel.apache.org/schema/blueprint/cxf http://camel.apache.org/schema/blueprint/cxf/camel-cxf.xsd http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd http://camel.apache.org/schema/blueprint http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">
<camelcxf:cxfEndpoint id="demo-target-cxf" address="http://localhost:9000/SourceExample/hello" serviceClass="com.sample.SourceExampleWSImpl" endpointName="SourceExamplePort" serviceName="SourceExampleService" />
<camelContext xmlns="http://camel.apache.org/schema/blueprint" id="fuse-demo-route-exmple-cxf">
<route id="demo-target-cxf">
<from uri="cxf:bean:demo-target-cxf" />
<transform>
<simple>${in.body}</simple>
</transform>
<log message="Message input: ${in.body}" />
<removeHeaders pattern="CamelHttp*" />
</route>
</camelContext>
</blueprint>
以下是Web Service实现类:
@WebService
public class SourceExampleWSImpl {
@WebMethod
public int getTotal(int x, int y) {
return x+y;
}
}
bundle ic正确部署在JBoss Fuse上。调用Web服务时,仅评估第一个参数。例如,使用参数1和4调用:
<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:sam="http://sample.com/">
<soapenv:Header/>
<soapenv:Body>
<sam:getTotal>
<arg0>1</arg0>
<arg1>4</arg1>
</sam:getTotal>
</soapenv:Body>
</soapenv:Envelope>
返回:
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
<soap:Body>
<ns2:getTotalResponse xmlns:ns2="http://sample.com/">
<return>1</return>
</ns2:getTotalResponse>
</soap:Body>
</soap:Envelope>
知道怎么解决吗? 感谢
答案 0 :(得分:2)
你的意思是预期的输出应该是
1 + 4 = 5
因为应该调用以下代码吗?
public int getTotal(int x, int y) {
return x+y;
}
如果不这样,当你使用camel-cxf作为bean时,bean只定义了契约,实现中的代码 not 正在使用中。
如果您只是想要一个标准的SOAP-WS并编写用于构建和处理SOAP请求/响应的Java代码,那么只需使用普通的CXF。