按照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>
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>
解决方案 »
- DWR上传文件 提示File uploads not supported?求大神
- 一个很难解决的webservice的问题
- 请教各位大侠!
- struts下来列表问题
- 第一次来
- 哪位高手帮帮我!
- 红叶java乐园 讨论struts开发,elcipse使用,idea使用
- 100分求《struts in action》的源代码,现在www.manning-source.com上无法下载了。
- 救急贴:给予我有效帮助的朋友,愿献上千分。
- 跪在碎玻璃上裸求Borland Enterprise server Appserver Edition 5.1.1-5.2.1
- 怎么使用 filter 限制系统登录程序
- attempt to create delete event with null entity?
public interface HelloWorld {
String sayHi(String text);
}加上去你的问题就解决啦。
实现类要指明接口@WebService(endpointInterface="com.ejb.IEjbTest", serviceName = "EjbTestService")