0
votes

I have exposed a web service using the CXF JAXWS Service via the HTTP outbound.

Given below is the syntax of my end-point declaration from my Mule config.

<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"  >

But this is no working. It gives the below error when tried to run this on mule server.

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                                 *
********************************************************************************

It is looking for a different port than what I have mentioned in the service endpoint declaration.

Please help me understand, what the issue is.

Given below is the wsdl of this service.

I have created this WSDL and then generated code using wsdl2java of cfx. Then Implemented the service interface operations. Then configured the service in a Mule flow.

<?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>
2

2 Answers

4
votes

I have absolutely no problem configuring a cxf:jaxws-service with a port attribute, so I think the issue is in your configuration.

For instance, the error says CXF is looking for {http://service.example.com}HelloServiceImplPort but surprisingly you're configuring the service namespace as http://example.org/HelloService. Though it doesn't need to be consistent, it usually is.

Looking at your WSDL, things seem correct so my guess is that the @WebService annotation on HelloServiceImpl.class contains funky values.

It should be:

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

Note that with a properly configured @WebService, you only need this in Mule XML config:

<cxf:jaxws-service serviceClass="com.example.service.HelloServiceImpl" />
0
votes

Isn't <cxf:jaxws-service serviceClass="interface-name and not implementation name> as cited in this example