日期:2014-05-19  浏览次数:20710 次

关于cxf的一个超简单的报错
直接帖代码
客户端:
import com.client.TestClient;
import com.client.TestServer;

public class TestClientImpl implements TestClient {
TestServer testService ;
public int doSearchCount() {
// TODO Auto-generated method stub
int count = testService.doSearchCount();
return count;
}
public TestServer getTestService() {
return testService;
}
public void setTestService(TestServer testService) {
this.testService = testService;
}

}

package com.client;

public interface TestClient {
public int doSearchCount();
}


import javax.jws.WebService;

@WebService
public interface TestServer {
public int doSearchCount();
}

客户端的配置文件如下:
<?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"
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">
<!-- service bean设置 -->
<bean id="testClient" class="com.client.impl.TestClientImpl">
<property name="testService">
<ref bean="testService"/>
</property>
</bean>
<jaxws:client id="testService" serviceClass="com.client.TestServer"
address="http://localhost:8080/TestWebService/testexample">
</jaxws:client>
</beans>

服务端:

import javax.jws.WebService;

import org.springframework.orm.ibatis.support.SqlMapClientDaoSupport;

import com.TestServer;

@WebService(endpointInterface="com.TestServer")
public class TestServerImp extends SqlMapClientDaoSupport implements TestServer{

public int doSearchCount() {
/*ApplicationContext ac = new ClassPathXmlApplicationContext();
ac.getBean("");*/
return (Integer)getSqlMapClientTemplate().queryForObject("Test.queryStockTotal");

}

}


import javax.jws.WebService;

@WebService
public interface TestServer {
public int doSearchCount();
}
服务端的配置文件如下:
<?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"
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">
<bean id="test" class="com.impl.TestServerImp">
<property name="sqlMapClient">
<ref bean="sqlMapClient"/>
</property>
</bean>
<!-- 事务代理bean -->
<bean id="textProxy" parent="txProxyTemplate">
<property name="target">
<ref bean="test" />
</property>
</bean>

<!-- bean 发布成webservice的定义 -->
<jaxws:server id="testService" serviceBean="#textProxy"
address="/testexample">
</jaxws:server>
</beans>




------解决方案--------------------
你没有正确调用WEBSERVICE服务。http://topic.csdn.net/u/20120829/14/c746a92d-1a6e-4a9f-aa2d-e01ee457cebc.html?6097具体看这