JAX-RPC问题javax.xml.rpc.ServiceException:

zzpsmis
06-12-19 1 1769

import javax.xml.rpc.ServiceFactory; 这个类
ServiceFactory factory = ServiceFactory.newInstance();报错
错误如下:
javax.xml.rpc.ServiceException: Failed to create factory: org.apache.axis.client.ServiceFactory
at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:79)
at JAXRPC.DIITip.main(DIITip.java:19)
Caused by: java.lang.ClassNotFoundException: org.apache.axis.client.ServiceFactory
at java.net.URLClassLoader$1.run(URLClassLoader.java:200)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
at javax.xml.rpc.ServiceFactory.newInstance(ServiceFactory.java:73)
... 1 more

zzpsmis
2006-12-19 18:20

代码如下:
public class DIIClient {

// modified from sun j2ee jaxrpc example

private static String endpoint = "http://localhost:8070/simple-ws4ee/exactpath/jse";
private static String qnameService = "HelloWorldService";
private static String qnamePort = "HelloWorld";

private static String ENCODING_STYLE_PROPERTY =
"javax.xml.rpc.encodingstyle.namespace.uri";
private static String NS_XSD =
"http://www.w3.org/2001/XMLSchema";
private static String URI_ENCODING =
"http://schemas.xmlsoap.org/soap/encoding/";

public static void main(String[] args) {

System.out.println("Endpoint address = " + endpoint);

try {
ServiceFactory factory = ServiceFactory.newInstance();
Service service = factory.createService(new QName(qnameService));

QName port = new QName(qnamePort);

Call call = service.createCall(port);
call.setTargetEndpointAddress(endpoint);

call.setProperty(Call.SOAPACTION_USE_PROPERTY,
new Boolean(true));
call.setProperty(Call.SOAPACTION_URI_PROPERTY, "");
call.setProperty(ENCODING_STYLE_PROPERTY, URI_ENCODING);
QName QNAME_TYPE_STRING = new QName(NS_XSD, "string");
call.setReturnType(QNAME_TYPE_STRING);


call.setOperationName(new QName(endpoint,
"getHelloWorld"));
call.addParameter("String_1", QNAME_TYPE_STRING,
ParameterMode.IN);
String[] params = { "jboss!" };

String result = (String)call.invoke(params);
System.out.println(result);

} catch (Exception ex) {
ex.printStackTrace();
}
}
}