Apache camel blueprint webservice"找不到端口"

时间:2015-09-18 07:53:14

标签: java web-services wsdl apache-camel apache-karaf

我试图用Apache camel公开WebService。我使用maven作为捆绑包构建我的项目,并将其部署在Apache karaf上。

现在我在karaf日志中总是得到

Error occurred during starting Camel: CamelContext(camel) due Could not find definition for port {http://localhost:8181/cxf/webservices/inputoutput}Calculator. org.apache.cxf.service.factory.ServiceContructionException: Could not find definition for port {http://localhost:8181/cxf/webservices/inputoutput}Calculator.

这是我在camel-context.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"
       xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.0.0"
       xmlns:jaxws="http://cxf.apache.org/blueprint/jaxws"
       xmlns:cxf="http://cxf.apache.org/blueprint/core"
       xmlns:camel="http://camel.apache.org/schema/blueprint"
       xmlns:camelcxf="http://camel.apache.org/schema/blueprint/cxf"
       xsi:schemaLocation="
         http://www.osgi.org/xmlns/blueprint/v1.0.0 http://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd
         http://cxf.apache.org/blueprint/jaxws http://cxf.apache.org/schemas/blueprint/jaxws.xsd
         http://cxf.apache.org/blueprint/core http://cxf.apache.org/schemas/blueprint/core.xsd
         ">

<camelcxf:cxfEndpoint id="inputOutput"
                    address="/webservices/inputoutput"
                    endpointName="ns:Calculator"
                    serviceName="ns:CalculatorService"
                    wsdlURL="META-INF/wsdl/Calculator.wsdl"
                    serviceClass="osgiBlueprintSoap.CalculatorService"
                    xmlns:ns="http://localhost:8181/cxf/webservices/inputoutput"/>

<bean id="inputOutputRoutes" class="osgiBlueprintSoap.InputOutputRoutes"/>

<camelContext id="camel" xmlns="http://camel.apache.org/schema/blueprint">
  <routeBuilder ref="inputOutputRoutes"/>
</camelContext>

</blueprint>

我在我的InputOutputRoutes中构建我的路线,就像这样

public class InputOutputRoutes extends RouteBuilder {

@Override
public void configure() throws Exception {
    // webservice responses
    AddResponse output = new AddResponse();
    output.setAddReturn(5); // just for testing

    from("cxf:bean:inputOutput?dataFormat=PAYLOAD")
            .convertBodyTo(Add.class)
            .wireTap(
                    "file:C:/output?fileName=request-${date:now:yyyy-MM-dd-HHmmssSSS}")
            .choice().when(simple("${body.surname} == 'test'"))
            .transform(constant(output)).otherwise()
            .transform(constant(output));
}
}

这就是我的wsdl看起来像

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://calculator"
xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://calculator"
xmlns:intf="http://calculator" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/"
xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 
    PDT) -->
<wsdl:types>
    <schema elementFormDefault="qualified" targetNamespace="http://localhost:8181/cxf/webservices/inputoutput"
        xmlns="http://www.w3.org/2001/XMLSchema">
        <element name="add">
            <complexType>
                <sequence>
                    <element name="a" type="xsd:double" />
                    <element name="b" type="xsd:double" />
                </sequence>
            </complexType>
        </element>
        <element name="addResponse">
            <complexType>
                <sequence>
                    <element name="addReturn" type="xsd:double" />
                </sequence>
            </complexType>
        </element>
    </schema>
</wsdl:types>
<wsdl:message name="addRequest">
    <wsdl:part element="impl:add" name="parameters">
    </wsdl:part>
</wsdl:message>
<wsdl:message name="addResponse">
    <wsdl:part element="impl:addResponse" name="parameters">
    </wsdl:part>
</wsdl:message>
<wsdl:portType name="Calculator">
    <wsdl:operation name="add">
        <wsdl:input message="impl:addRequest" name="addRequest">
        </wsdl:input>
        <wsdl:output message="impl:addResponse" name="addResponse">
        </wsdl:output>
    </wsdl:operation>
</wsdl:portType>
<wsdl:binding name="CalculatorSoapBinding" type="impl:Calculator">
    <wsdlsoap:binding style="document"
        transport="http://schemas.xmlsoap.org/soap/http" />
    <wsdl:operation name="add">
        <wsdlsoap:operation soapAction="" />
        <wsdl:input name="addRequest">
            <wsdlsoap:body use="literal" />
        </wsdl:input>
        <wsdl:output name="addResponse">
            <wsdlsoap:body use="literal" />
        </wsdl:output>
    </wsdl:operation>
</wsdl:binding>
<wsdl:service name="CalculatorService">
    <wsdl:port binding="impl:CalculatorSoapBinding" name="Calculator">
        <wsdlsoap:address location="http://localhost:8181/cxf/webservices/inputoutput" />
    </wsdl:port>
</wsdl:service>
</wsdl:definitions>

我使用maven中的cxf-codegen-plugin从wsdl生成java类。

几天以来,我们已经尝试让这个网络服务工作了...... 谁能告诉我我还在做错什么?任何帮助表示赞赏...

0 个答案:

没有答案