按照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>
解决方案 »
- struts2 超链接访问action bbs
- json转map方法
- java 取字段名
- servlet中用什么方法能使输入的URL以中文结尾
- struts2 转换类型--不大理解请高手指点
- 问个关于struts和javascript的菜鸟问题
- 问请我在socket的类里有一个成员变量jFrame类,当jFrame的Jbutton的actionliterner作用时,会有效吗?
- 我的SQL SERVER数据库中有时间字段create_date(数值为2003-3-4这种形式),在JSP中如何根据这个字段值筛选出某一周内的记录
- 还是j2ee的问题,请指点!
- 怎么将编写的class文件和html上传到Web服务器
- 怎么使用 filter 限制系统登录程序
- attempt to create delete event with null entity?
public interface HelloWorld {
String sayHi(String text);
}加上去你的问题就解决啦。
实现类要指明接口@WebService(endpointInterface="com.ejb.IEjbTest", serviceName = "EjbTestService")