2013-04-08 78 views
0

我已经通过HTTP出站使用CXF JAXWS服务公开了Web服务。运行CXF JAX WS服务的问题

下面给出了我的Mule配置中的终点声明的语法。

<http:inbound-endpoint address="http://localhost:8080/HelloService" exchange-pattern="request-response"> 
     <cxf:jaxws-service serviceClass="com.example.service.HelloServiceImpl" wsdlLocation="wsdl/helloservice.wsdl" 
     namespace="http://example.org/HelloService"   
     port="HelloServicePort" service="HelloService" > 

但是这是行不通的。 当试图在mule服务器上运行时,它会给出下面的错误。

2013-04-08 16:34:35,252 ERROR [main] mule.MuleServer (MuleServer.java:474) - 
******************************************************************************** 
* A Fatal error has occurred while the server was running:      * 
* Could not find definition for port           * 
* {http://service.example.com/}HelloServiceImplPort.    * 
* (org.apache.cxf.service.factory.ServiceConstructionException)    * 
*                    * 
* The error is fatal, the system will shutdown         * 
******************************************************************************** 

它正在寻找与我在服务端点声明中提到的端口不同的端口。

请帮我理解,问题是什么。

以下给出的是该服务的wsdl。

我已经创建了这个WSDL,然后使用cfx的wsdl2java生成代码。 然后执行服务接口操作。 然后在Mule流中配置服务。

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<wsdl:definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://example.org/HelloService" 
xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" 
name="HelloService" targetNamespace="http://example.org/HelloService" 
xmlns:per="http://example.org/HelloService/person" 
xmlns:comp="http://example.org/HelloService/company" 
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" > 

    <wsdl:types>   
    <xsd:schema targetNamespace="http://example.org/HelloService/company" >  
     <xsd:include schemaLocation="company.xsd" ></xsd:include>  
    </xsd:schema> 
    <xsd:schema targetNamespace="http://example.org/HelloService/person"> 
     <xsd:include schemaLocation="person.xsd" ></xsd:include>  
    </xsd:schema> 
    </wsdl:types> 


    <wsdl:message name="addCompanyRequest"> 
    <wsdl:part element="comp:Company" name="company"/> 
    </wsdl:message> 

    <wsdl:message name="addPersonRequest"> 
    <wsdl:part element="per:Person" name="person"/> 
    </wsdl:message> 

    <wsdl:message name="addCompanyResponse"> 
    <wsdl:part element="comp:CompResponse" name="response"/> 
    </wsdl:message> 

    <wsdl:message name="addPersonResponse"> 
    <wsdl:part element="per:PerResponse" name="response"/> 
    </wsdl:message> 

    <wsdl:portType name="HelloService"> 
    <wsdl:operation name="addCompany"> 
     <wsdl:input message="tns:addCompanyRequest" name="addCompanyRequest" /> 
     <wsdl:output message="tns:addCompanyResponse" name="addCompanyResponse" /> 
    </wsdl:operation> 

    <wsdl:operation name="addPerson"> 
     <wsdl:input message="tns:addPersonRequest" name="addPersonRequest" /> 
     <wsdl:output message="tns:addPersonResponse" name="addPersonResponse" /> 
    </wsdl:operation> 

    </wsdl:portType> 

    <wsdl:binding name="HelloServiceSOAP" type="tns:HelloService"> 
     <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/> 
    <wsdl:operation name="addCompany"> 
     <soap:operation soapAction="" style="document" /> 
     <wsdl:input name="addCompanyRequest"> 
     <soap:body use="literal"/> 
     </wsdl:input> 
     <wsdl:output name="addCompanyResponse"> 
     <soap:body use="literal"/> 
     </wsdl:output> 
    </wsdl:operation> 

    <wsdl:operation name="addPerson"> 
     <soap:operation soapAction="" style="document" /> 
     <wsdl:input name="addPersonRequest"> 
     <soap:body use="literal"/> 
     </wsdl:input> 
     <wsdl:output name="addPersonResponse"> 
     <soap:body use="literal"/> 
     </wsdl:output> 
    </wsdl:operation> 

    </wsdl:binding> 

    <wsdl:service name="HelloService"> 
    <wsdl:port binding="tns:HelloServiceSOAP" name="HelloServicePort"> 
     <soap:address location="http://localhost:8080/HelloService"/> 
    </wsdl:port> 
    </wsdl:service> 

</wsdl:definitions> 

回答

4

我绝对没有问题了port属性配置cxf:jaxws-service,所以我认为这个问题是在你的配置。

例如,错误表示CXF正在寻找{http://service.example.com}HelloServiceImplPort,但令人惊讶的是,您将服务名称空间配置为http://example.org/HelloService。虽然它不需要一致,但它通常是。

看着你的WSDL,事情看起来是正确的,所以我的猜测是HelloServiceImpl.class上的@WebService注释包含时髦的值。

它应该是:

@WebService(endpointInterface = "...interface class...", targetNamespace = "http://example.org/HelloService", serviceName = "HelloService", portName = "HelloServicePort", wsdlLocation = "wsdl/helloservice.wsdl") 

需要注意的是有正确地配置@WebService,你只需要这骡子XML配置:

<cxf:jaxws-service serviceClass="com.example.service.HelloServiceImpl" /> 
+1

服务的名称空间为http://example.org/HelloService服务的实现类位于com.example.service包中,其中包含t他的类名称为HelloServiceImpl。我想这就是它正在寻找名称为HelloServiceImplPort且名称空间为{http://service.example.com}的端口的原因。但是我已经使用namespace属性指定了命名空间,并且在mule配置中也提到了wsdl中的端口名称。 – user1760178 2013-04-09 13:22:36

+0

我已将我的wsdl添加到该问题。 – user1760178 2013-04-09 13:22:57

+0

我明白了。它是我的impl类中的@WebService注释的问题。非常感谢David Dassot。 – user1760178 2013-04-09 19:10:56

0

是不是<cxf:jaxws-service serviceClass="interface-name and not implementation name>在本example

引用