D:\>wsimport -s . http://localhost:8080/CXF_3/cxf/hello?wsdl
parsing WSDL...
[WARNING] Ignoring SOAP port "HelloServicePort": it uses non-standard SOAP 1.2 b
inding.
You must specify the "-extension" option to use this binding.
line 47 of http://localhost:8080/CXF_3/cxf/hello?wsdl
[WARNING] Service "HelloServiceService" does not contain any usable ports. try r
unning wsimport with -extension switch.
line 46 of http://localhost:8080/CXF_3/cxf/hello?wsdl
generating code...
compiling code...
-----------------------------------------以下是服务代码-------------------------------------
cxf-servlet.xml:
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:jaxws="http://cxf.apache.org/jaxws" xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd"> <!-- 引入CXF Bean定义如下,早期的版本中使用 --> <import resource="classpath:META-INF/cxf/cxf.xml" /> <import resource="classpath:META-INF/cxf/cxf-extension-soap.xml" /> <import resource="classpath:META-INF/cxf/cxf-servlet.xml" /> <!-- 第一种发布方式:简单发布(没有接口的发布) --> <!-- id:唯一标示 implementor:提供服务的类 address:服务的请求url--> <jaxws:endpoint id="helloService" implementor="cn.itcast.cxf.HelloService" address="/hello"> <!-- 加入请求的消息拦截器 --> <jaxws:inInterceptors> <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"></bean> </jaxws:inInterceptors> <!-- 加入响应的消息拦截器 --> <jaxws:outInterceptors> <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"></bean> </jaxws:outInterceptors> </jaxws:endpoint> </beans>
HelloService:
package cn.itcast.cxf;
import javax.jws.WebService;
@WebService
@BindingType(value=SOAPBinding.SOAP12HTTP_BINDING)
public class HelloService {
public String sayHello(String name){
System.out.println("正在调用sayHello方法");
return "hello " + name;
}
}
----------------------------以下是分析--------------------------------------------
将 HelloService.java的@BindingType(value=SOAPBinding.SOAP12HTTP_BINDING)注释掉就可以了.