我已经用成功创建了 WSDL 的 java 编写了 Webservice。我被困在用 java 为我的 web 服务编写 web 服务客户端。我想从一些 jsp 类中使用我的 web 服务。我该怎么做?
@WebService
public interface AddService {
double getMultipicationResult(double M1, double M2);
}
@WebService(endpointInterface = "com.sample.AddService")
public class AddServiceImpl implements AddService {
public AddServiceImpl() {
}
@Override
public double getMultipicationResult(double M1, double M2) {
M1 = M1*M2;
return M1;
}
}
我给客户写了类似的东西:-
public class AddServiceClient {
private AddServiceClient() {
}
public static void main(String args[]){
{
ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext(new String[] {"SpringClientWebServices.xml"});
AddService client = (AddService)context.getBean("client");
double response = 0.0;
response = client.getMultipicationResult(10.0, 20.5);
}
}
和 SpringClientWebServices.xml 如下:-
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:context="http://www.springframework.org/schema/context"
xmlns:jdbc="http://www.springframework.org/schema/jdbc"
xsi:schemaLocation="http://www.springframework.org/schema/beans
http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
http://www.springframework.org/schema/jdbc
http://www.springframework.org/schema/jdbc/spring-jdbc-3.0.xsd
http://www.springframework.org/schema/context
http://www.springframework.org/schema/context/spring-context-3.0.xsd">
<bean id="client" class="com.sample.AddService"
factory-bean="clientFactory" factory-method="create"/>
<bean id="clientFactory" class="org.apache.cxf.jaxws.JaxWsProxyFactoryBean">
<property name="serviceClass" value="com.sample.AddService"/>
<property name="address" value="http://localhost:8080/sample/services/Addition"/>
</bean>
</beans>
我收到如下异常:-
Exception in thread "main" org.springframework.beans.factory.CannotLoadBeanClassException: Cannot find class [org.apache.cxf.jaxws.JaxWsProxyFactoryBean] for bean with name 'clientFactory' defined in class path resource [SpringClientWebServices.xml]; nested exception is java.lang.ClassNotFoundException: org.apache.cxf.jaxws.JaxWsProxyFactoryBean