java - 在 apache karaf 上使用 apache Camel 蓝图的 Soap 请求失败

标签 java soap apache-camel apache-karaf

我正在尝试使用 Camel 蓝图发送 SOAP 请求,现在我得到了这个blueprint.xml

<?xml version="1.0" encoding="UTF-8"?>
<blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
   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 http://camel.apache.org/schema/blueprint/camel-blueprint.xsd">

<bean id="serviceBean" class="osgiBlueprintSoap.Service"/>

<cxfEndpoint id="serviceEndpoint" 
    address="{http://some.url/services/}SomeService"
    wsdlUrl="{http://some.url/services/}SomeService?wsdl"
    serviceName="{http://some.url/services/}SomeService"
    portName="{http://some.url/services/}SomeServiceSoapPort">
    <properties>
        <entry key="dataFormat" value="MESSAGE"/>
    </properties>
</cxfEndpoint>  

<camelContext xmlns="http://camel.apache.org/schema/blueprint">
  <route id="timerToLog">
    <from uri="timer:foo?period=5000"/>
    <to uri="cxf:serviceBean:serviceEndpoint"/>
    <to uri="file:C:/output?fileName=db.txt"/>
  </route>
</camelContext>

Service 类现在只是一个空类。

将其部署到 karaf 上后出现此错误

org.xml.sax.SAXParseException: cvc-complex-type.2.4.a: Invalid content was found starting with element 'cxfEndpoint'. One of '{"http://www.osgi.org/xmlns/blueprint/v1.0.0":service, "http://www.osgi.org/xmlns/blueprint/v1.0.0":reference-list, "http://www.osgi.org/xmlns/blueprint/v1.0.0":bean, "http://www.osgi.org/xmlns/blueprint/v1.0.0":reference, WC[##other:"http://www.osgi.org/xmlns/blueprint/v1.0.0"]}" is expected.

谁能告诉我该 xml 有什么问题以及我该怎么做才能发送此请求?

最佳答案

XML 解析器会遇到错误,因为它不知道cxfEndpoint 是什么。您必须为您的路由定义正确的 XML 命名空间才能像这样工作:

xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"

然后像这样“camelcxf:cxfEndpoint”一样引用cxfEndpoint。

您可以在Camel源here中看到与您的问题类似的更完整的Blueprint CXF示例.

关于java - 在 apache karaf 上使用 apache Camel 蓝图的 Soap 请求失败,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32560266/

相关文章:

java - 从 PHP 代码调用使用 Axis 创建的 Java Web 服务

JMSExpiration 与 TimeToLive

java - 无法显示椭圆形

.net - 为什么 WsHttpbindings 给出错误为 "soap header action was not understood"而不是 basichttpbinding?

java - 使用 hsql hibernate 数据源隔离 Junit 测试

python - 为什么在使用 python suds 连接到 Microsoft CRM 时出现连接错误/超时?

java - camel-hdfs2没有用于方案的文件系统:hdfs

java - Apache Camel : How to iterate over list and call rest api?

java - Camel 聚合器在新的关联键上完成聚合

java - 在 XML/DOM 对象中通过属性值或文本节点表示 ‘conditions’