按照CXF官方网站的步骤,可Client调用的时候确出现
javax.xml.ws.WebServiceException: Could not find operation info for web method sayHi.
的异常.大家帮我看看,很着急,多谢多谢!接口HelloWorld 代码如下:package demo.test;
import javax.jws.WebService;
public interface HelloWorld {
String sayHi(String text); 
}实现类HelloWorldImpl 代码如下:package demo.test;
public class HelloWorldImpl implements HelloWorld {
public String sayHi(String text) {
return "Hello " + text;
}
}beans.xml如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schemas/jaxws.xsd"> <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" />
<jaxws:endpoint 
  id="helloWorld" 
  implementor="demo.test.HelloWorldImpl" 
  address="/HelloWorld" />
</beans>client的xml如下:
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:jaxws="http://cxf.apache.org/jaxws"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://cxf.apache.org/jaxws http://cxf.apache.org/schema/jaxws.xsd">    <bean id="client" class="demo.test.HelloWorld" 
      factory-bean="clientFactory" factory-method="create"/>
    
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
  <property name="serviceClass" value="demo.test.HelloWorld"/>
  <property name="address" value="http://localhost:8080/myweb/services/HelloWorld"/>
</bean>
</beans>Client调用代码如下:package demo.test;
import org.springframework.context.support.ClassPathXmlApplicationContext;
public class ClientCall { public String getHelloMessage(String p){
     ClassPathXmlApplicationContext context 
        = new ClassPathXmlApplicationContext(new String[] {"demo/test/clientbean.xml"});     HelloWorld client = (HelloWorld)context.getBean("client");
    
    String response = client.sayHi(p);
    return response;

}访问http://localhost:8080/myweb/HelloWorld?wsdl内容如下: <?xml version="1.0" encoding="utf-8" ?> 
- <wsdl:definitions xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://test.demo/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" name="HelloWorldImplService" targetNamespace="http://test.demo/">
  <wsdl:portType name="HelloWorldImpl" /> 
- <wsdl:binding name="HelloWorldImplServiceSoapBinding" type="tns:HelloWorldImpl">
  <soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" /> 
  </wsdl:binding>
- <wsdl:service name="HelloWorldImplService">
- <wsdl:port binding="tns:HelloWorldImplServiceSoapBinding" name="HelloWorldImplPort">
  <soap:address location="http://localhost:8080/axis1/ws/HelloWorld" /> 
  </wsdl:port>
  </wsdl:service>
  </wsdl:definitions>