本文主要是介绍Axis 学习笔记之返回对象,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
server-config.xml中的核心内容
<service name="BookService" provider="java:RPC">
<parameter name="allowedMethods" value="*" />
<parameter name="className" value="com.BookService" />
<parameter name="scope" value="application" />
<beanMapping xmlns:myNS="urn:wu" qname="myNS:Book" languageSpecificType="java:com.Book"/>
</service>
客户端的程序的调用方式:
public class Client {
public static void main(String[] args) {
try {
String endpoint = "http://localhost:8080/axis/services/BookService";
Service service = new Service();
Call call = (Call) service.createCall();
call.setTargetEndpointAddress(new java.net.URL(endpoint));
//序列化对象
QName qname = new QName("urn:wu", "Book");//注册实体对象
call.registerTypeMapping(Book.class, qname,
new BeanSerializerFactory(Book.class, qname),
new BeanDeserializerFactory(Book.class, qname));
call.setOperationName("getList");
Book[] re= (Book[])call.invoke(new Object[]{"abc"});
System.out.println("123");
} catch (Exception ex) {
System.out.println(ex.getMessage());
}
}
}
这篇关于Axis 学习笔记之返回对象的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!