01步:
接口类:
package com.css.mule.test.serviceA;
import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;@WebService
public interface Echo {
    public String hello(@WebParam(name ="str")String str);
}
实现类:
package com.css.mule.test.serviceA; import javax.jws.WebParam;
import javax.jws.WebResult;
import javax.jws.WebService;
@WebService(serviceName = "alisdEchoUMO", endpointInterface = "com.css.mule.test.serviceA.Echo") public class EchoImpl implements Echo {     public String hello(String str) {
        System.out.println("----service------");
        return "hello--" + str;
    }
}
02步:
cxf-config.xml<?xml version="1.0" encoding="UTF-8"?>
  <mule xmlns="http://www.mulesource.org/schema/mule/core/2.2"  
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
        xmlns:spring="http://www.springframework.org/schema/beans"  
        xmlns:vm="http://www.mulesource.org/schema/mule/vm/2.2"  
        xmlns:cxf="http://www.mulesource.org/schema/mule/cxf/2.2"  
        xmlns:axis="http://www.mulesource.org/schema/mule/axis/2.2"  
        xmlns:smtps="http://www.mulesource.org/schema/mule/smtps/2.2"  
        xmlns:http="http://www.mulesource.org/schema/mule/http/2.2"  
        xmlns:stdio="http://www.mulesource.org/schema/mule/stdio/2.2"  
        xmlns:soap="http://www.mulesource.org/schema/mule/soap/2.2"  
        xsi:schemaLocation="  
                 http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd  
                 http://www.mulesource.org/schema/mule/core/2.2 http://www.mulesource.org/schema/mule/core/2.2/mule.xsd  
                 http://www.mulesource.org/schema/mule/stdio/2.2 http://www.mulesource.org/schema/mule/stdio/2.2/mule-stdio.xsd  
                 http://www.mulesource.org/schema/mule/vm/2.2 http://www.mulesource.org/schema/mule/vm/2.2/mule-vm.xsd  
                 http://www.mulesource.org/schema/mule/cxf/2.2 http://www.mulesource.org/schema/mule/cxf/2.2/mule-cxf.xsd  
                 http://www.mulesource.org/schema/mule/axis/2.2 http://www.mulesource.org/schema/mule/axis/2.2/mule-axis.xsd  
                 http://www.mulesource.org/schema/mule/smtps/2.2 http://www.mulesource.org/schema/mule/smtps/2.2/mule-smtps.xsd  
                 http://www.mulesource.org/schema/mule/soap/2.2 http://www.mulesource.org/schema/mule/soap/2.2/mule-soap.xsd  
                 http://www.mulesource.org/schema/mule/http/2.2 http://www.mulesource.org/schema/mule/http/2.2/mule-http.xsd  
                 ">  
       <description>  
          eagleMule demo which shows how to publish web services over CXF.  
      </description>  
      <model name="eagleMule">  
           <service name="testMuleService">  
              <inbound>  
                  <axis:inbound-endpoint address="http://localhost:8899/services/testMuleService">  
                      <soap:http-to-soap-request-transformer />  
                  </axis:inbound-endpoint>  
                  <cxf:inbound-endpoint address="http://localhost:8898/services/testMuleService">  
                      <soap:http-to-soap-request-transformer />  
                  </cxf:inbound-endpoint>  
              </inbound>  
              <component class="com.css.mule.test.serviceA.EchoImpl">
              </component>  
          </service>  
      </model>
</mule>
03步:
启动mule。
package main; import org.mule.api.context.MuleContextFactory;
import org.mule.api.context.WorkManager;
import org.apache.cxf.configuration.ConfigurationException;
import org.mule.api.MuleContext;
import org.mule.api.MuleException;
import org.mule.api.lifecycle.InitialisationException;
import org.mule.config.spring.SpringXmlConfigurationBuilder;
import org.mule.context.DefaultMuleContextFactory; public class MuleMain {
    
    public static void main(String[] args) throws ConfigurationException, InitialisationException {
        try {
            String configFile = "cxf-config.xml";
            String[] configFileArr = new String[] { configFile };
            MuleContextFactory muleContextFactory = new DefaultMuleContextFactory();
            MuleContext context = muleContextFactory.createMuleContext(
                    new SpringXmlConfigurationBuilder(configFileArr));
            context.start();
        } catch (MuleException t) {
            t.printStackTrace();
        }
    }
}
04:
客户端调用:
package client;import java.io.IOException;import org.apache.cxf.jaxws.JaxWsProxyFactoryBean;
import org.mule.api.MuleException;
import org.mule.api.MuleMessage;
import org.mule.module.client.MuleClient;
import com.css.mule.test.serviceA.Echo; public class Client {
    public static void main(String[] args) throws IOException {
        MuleClient client = null;
        try {
            client = new MuleClient();
            String url = "http://localhost:8898/services/testMuleService?wsdl&method=hello";             MuleMessage message = client.send(url, "eagle", null);
            Object obj = message.getPayload();
            System.out.println("--------------obj---------"+ obj.getClass().getName());
            if (obj instanceof String) {
                System.out.println("---------str--------------" + obj);   
            }
        } catch (MuleException e) {
            e.printStackTrace();
        } finally {
            client.dispose();
        }
    }


//
//  public static void main(String[] args) {
//         
//         JaxWsProxyFactoryBean factory = new JaxWsProxyFactoryBean();
//         
//         factory.setAddress("http://localhost:65082/services/EchoUMO?wsdl");
//         
//         factory.setServiceClass(Echo.class);
//         
//         Echo helloworld = (Echo) factory.create();
//        
//         System.out.println(helloworld.hello("alisd"));
//     }
 
 
 
}问题如下:启动mule后。测试cxf发布是否成功:
IE:输入:http://localhost:8898/services/testMuleService?wsdl  <?xml version="1.0" encoding="UTF-8" ?> 
- <wsdl:definitions name="alisdEchoUMO" targetNamespace="http://serviceA.test.mule.css.com/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://serviceA.test.mule.css.com/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
- <wsdl:types>
- <xs:schema attributeFormDefault="unqualified" elementFormDefault="unqualified" targetNamespace="http://serviceA.test.mule.css.com/" xmlns:tns="http://serviceA.test.mule.css.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema">
  <xs:element name="hello" type="tns:hello" /> 
  <xs:element name="helloResponse" type="tns:helloResponse" /> 
- <xs:complexType name="hello">
- <xs:sequence>
  <xs:element minOccurs="0" name="str" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
- <xs:complexType name="helloResponse">
- <xs:sequence>
  <xs:element minOccurs="0" name="return" type="xs:string" /> 
  </xs:sequence>
  </xs:complexType>
  </xs:schema>
  </wsdl:types>
- <wsdl:message name="helloResponse">
  <wsdl:part element="tns:helloResponse" name="parameters" /> 
  </wsdl:message>
+ <wsdl:message name="hello">
  <wsdl:part element="tns:hello" name="parameters" /> 
  </wsdl:message>
- <wsdl:portType name="Echo">
- <wsdl:operation name="hello">
  <wsdl:input message="tns:hello" name="hello" /> 
  <wsdl:output message="tns:helloResponse" name="helloResponse" /> 
  </wsdl:operation>
  </wsdl:portType>
- <wsdl:binding name="alisdEchoUMOSoapBinding" type="tns:Echo">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
- <wsdl:operation name="hello">
  <soap:operation soapAction="" style="document" /> 
- <wsdl:input name="hello">
  <soap:body use="literal" /> 
  </wsdl:input>
- <wsdl:output name="helloResponse">
  <soap:body use="literal" /> 
  </wsdl:output>
  </wsdl:operation>
  </wsdl:binding>
- <wsdl:service name="alisdEchoUMO">
- <wsdl:port binding="tns:alisdEchoUMOSoapBinding" name="EchoImplPort">
  <soap:address location="http://localhost:8898/services/testMuleService" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>
发布成功。
问题在于Client调用时调用不到。EchoImpl的方法没有走。
代码片段,
public class Client {
    public static void main(String[] args) throws IOException {
        MuleClient client = null;
        try {
            client = new MuleClient();
            String url = "http://localhost:8898/services/testMuleService?wsdl&method=hello";             MuleMessage message = client.send(url, "eagle", null);
            Object obj = message.getPayload();
            System.out.println("--------------obj---------"+ obj.getClass().getName());
            if (obj instanceof String) {
                System.out.println("---------str--------------" + obj);   
            }
        } catch (MuleException e) {
            e.printStackTrace();
        } finally {
            client.dispose();
        }
    }