Camel cxf:cxfEndpoint生产者错误:无法找到带有操作名称的BindingOperationInfo

ksw*_*ghs 6 java web-services cxf apache-camel

我使用camel cxf:cxfEndpoint调用soap服务,但是收到此BindingOperationInfo错误.配置对我来说是正确的,但不知道我做错了什么.

端点配置:

<!--  Soap Client -->
<cxf:cxfEndpoint id="accountEndpoint" address="http://localhost:3333/wspoc/user"
        wsdlURL="/wsdl/userSvc.wsdl"
        serviceClass="com.cog.poc.acct.HelloWorldImplService"
        endpointName="ws:HelloWorldImplPort"
        serviceName="ws:HelloWorldImplService" 
    xmlns:ws="http://acct.poc.cog.com/" loggingFeatureEnabled="true">
    <cxf:properties>
        <entry key="dataFormat" value="POJO"/>
    </cxf:properties>
</cxf:cxfEndpoint>
Run Code Online (Sandbox Code Playgroud)

我的Java DSL路由器配置.

from("direct:invokeMyUpdate")
        .bean("myAcctSvcClient", "buildSoapReq")
        .setHeader(CxfConstants.OPERATION_NAME, constant("getAccountInfo"))
        .to("cxf:bean:accountEndpoint")
Run Code Online (Sandbox Code Playgroud)

WSDL元素:

<definitions targetNamespace="http://acct.poc.cog.com/"
name="HelloWorldImplService" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://acct.poc.cog.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns="http://schemas.xmlsoap.org/wsdl/">


<service name="HelloWorldImplService">
    <port name="HelloWorldImplPort" binding="tns:HelloWorldImplPortBinding">
        <soap:address location="http://localhost:3333/wspoc/user" />
    </port>
</service>

 <binding name="HelloWorldImplPortBinding" type="tns:HelloWorld">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http"
        style="rpc" />
    <operation name="getHelloWorldAsString">
        <soap:operation soapAction="" />
        <input>
            <soap:body use="literal" namespace="http://acct.poc.cog.com/" />
        </input>
        <output>
            <soap:body use="literal" namespace="http://acct.poc.cog.com/" />
        </output>
    </operation>
    <operation name="getAccountInfo">
        <soap:operation soapAction="" />
        <input>
            <soap:body use="literal" namespace="http://acct.poc.cog.com/" />
        </input>
        <output>
            <soap:body use="literal" namespace="http://acct.poc.cog.com/" />
        </output>
    </operation>
</binding>
Run Code Online (Sandbox Code Playgroud)

以下是错误:

Stacktrace:java.lang.IllegalArgumentException:找不到具有操作名称{ http://acct.poc.cog.com/ } getAccountInfo 的BindingOperationInfo .请检查operationName和operationNamespace的消息头.at org.apache.camel.component.cxf.CxfProducer.getBindingOperationInfo(CxfProducer.java:379)[camel-cxf-2.16.0.jar:2.16.0] at org.apache.camel.component.cxf.CxfProducer.prepareBindingOperation (CxfProducer.java:211)[camel-cxf-2.16.0.jar:2.16.0] at org.apache.camel.component.cxf.CxfProducer.process(CxfProducer.java:110)[camel-cxf-2.16. 0.jar:2.16.0] at org.apache.camel.processor.SendProcessor.process(SendProcessor.java:141)[camel-core-2.16.0.jar:2.16.0]

kas*_*asi 5

你也尝试过设置:

<setHeader headerName="operationNamespace">
  <constant>http://acct.poc.cog.com/</constant>
</setHeader>
Run Code Online (Sandbox Code Playgroud)

在JAVA DSL我想:

from("direct:invokeMyUpdate")
    .bean("myAcctSvcClient", "buildSoapReq")
    .setHeader(CxfConstants.OPERATION_NAME, constant("getAccountInfo"))
    .setHeader(CxfConstants.OPERATION_NAMESPACE, constant("http://acct.poc.cog.com/"))
    .to("cxf:bean:accountEndpoint")
Run Code Online (Sandbox Code Playgroud)

我的第二个提示是运行调试器并将断点放在行上CxfProducer.java:379.比检查值CxfProducer.client.conduitSelector.endpoint.binding.bindingInfo.operations.
我试图解决类似的问题,其中从wsdl加载的操作集是空白的.

编辑:我找到了我的问题的来源,为什么创建的端点是类型org.apache.cxf.endpoint.EndpointImpl而不是org.apache.cxf.jaxws.support.JaxWsEndpointImpl没有操作信息.CxfEndpoint示例:

<cxf:cxfEndpoint
        id="id"
        ...
        serviceClass="service.class.name"
 >
Run Code Online (Sandbox Code Playgroud)

service.class.name错误地声明为webservice客户端类,而不是webservice接口类.

  • 有了您的多个答案,问题得到了解决。我还将 cxfEndpoint serviceClass 设置为 Web 服务客户端。当我将其更改为界面时,它起作用了。谢谢你。 (2认同)