用Axis2 传递复杂对象

本文介绍如何使用Axis2 Web服务框架传递复杂的Java对象。通过示例演示了如何定义复杂类型的WS-Definition Language (WSDL)及其实现过程,包括服务端的部署和客户端的调用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

用axis2 传递复杂对象
 
Web serivces 有个方法 :
 
Person searchPerson(Person person);
 
其中的Person定义为
class Person
{
    int age;
    String name;
    String address;
    Person father;
}
 
wsdl 定义为:
 
<types>
        <schema targetNamespace=" http://userguide.axis2.apache.org/xsd"
            xmlns=" http://www.w3.org/2001/XMLSchema"
            xmlns:wsdl=" http://schemas.xmlsoap.org/wsdl/"
            elementFormDefault="qualified">
 
<complexType name="Person">
    <all>
     <element name="age" type="xsd:int"/>
     <element name="name" type="xsd:string"/>
     <element name="address" type="xsd:string"/>
     <element name ="father" type="xsd1:Person"/>
    </all>
   </complexType>
 
 </schema>
<types>
 
------------------------------ -----------------------
<element name="searchPersonParam" type="xsd1:Person"/>
 
<element name="searchPersonReturn" type="xsd1:Person"/> 
------------------------------ -----------------------
<message name="searchPerson">
  <part element="xsd1:searchPersonParam " name="a"/>
 </message>
 <message name="searchPersonResponse">
  <part element="xsd1:searchPersonRetur n" name="result"/>
 </message> 
 
------------------------------ -----------------------
<portType name="Axis2SampleDocLitPortType ">
    <operation name="searchPerson">
   <input message="tns:searchPerson" name="searchPerson"/>
   <output message="tns:searchPersonRespon se" name="searchPersonResponse"/>
  </operation>
</portType>
------------------------------ -----------------------
 
<binding name="Axis2SampleDocLitPortBind ing"
        type="tns:Axis2SampleDocLitPort Type">
        <soap:binding style="document" transport=" http://schemas.xmlsoap.org/soap/http"/>
 
        <operation name="searchPerson">
   <soap:operation soapAction="searchPerson" style="document"/>
   <input name="searchPerson">
    <soap:body namespace=" http://userguide.axis2.apache.org/Axis2SampleDocLit"
                    use="literal"/>
   </input>
   <output name="searchPersonResponse">
    <soap:body namespace=" http://userguide.axis2.apache.org/Axis2SampleDocLit"
                    use="literal"/>
   </output>
  </operation>
</binding>
 
 <service name="Axis2SampleDocLitService ">
        <port binding="tns:Axis2SampleDocLitP ortBinding"
            name="Axis2SampleDocLitPort">
            <soap:address
                location=" http://userguide.axis2.apache.org/stkv3/wsdl/Axis2SampleDocLit.wsdl"/>
        </port>
    </service>
 
 
将此wsdl 保存为 Axis2SampleDocLit.wsdl 
运行
> WSDL2Java -uri ./Axis2Sample DocLit.wsdl -ss -sd -g -d xmlbeans -o ./Axis2SampleDocLit -p org.apache.axis2.userguide
 
然后修改服务代码,发布服务,编写客户端测试程序。 
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值