用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/XMLSchem a"
xmlns:wsdl=" http://schemas.xmlsoap.org /wsdl/"
elementFormDefault="qualified">
<schema targetNamespace=" http://userguide.axis2.apache
xmlns=" http://www.w3.org/2001/XMLSchem
xmlns:wsdl=" http://schemas.xmlsoap.org
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>
<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"/> <script type="text/javascript">
</script>
<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>
<part element="xsd1:searchPersonParam
</message>
<message name="searchPersonResponse">
<part element="xsd1:searchPersonRetur
</message>
------------------------------
-----------------------
<portType name="Axis2SampleDocLitPortType
">
<operation name="searchPerson">
<input message="tns:searchPerson" name="searchPerson"/>
<output message="tns:searchPersonRespon se" name="searchPersonResponse"/>
</operation>
<input message="tns:searchPerson" name="searchPerson"/>
<output message="tns:searchPersonRespon
</operation>
</portType>
------------------------------
-----------------------
<binding name="Axis2SampleDocLitPortBind
ing"
type="tns:Axis2SampleDocLitPort Type">
<soap:binding style="document" transport=" http://schemas.xmlsoap.org /soap/http"/>
type="tns:Axis2SampleDocLitPort
<soap:binding style="document" transport=" http://schemas.xmlsoap.org
<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"> <script type="text/javascript"> </script>
<soap:body namespace=" http://userguide.axis2.apache .org/Axis2SampleDocLit"
use="literal"/>
</output>
</operation>
<soap:operation soapAction="searchPerson" style="document"/>
<input name="searchPerson">
<soap:body namespace=" http://userguide.axis2.apache
use="literal"/>
</input>
<output name="searchPersonResponse"> <script type="text/javascript"> </script>
<soap:body namespace=" http://userguide.axis2.apache
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/Axis2SampleDocL it.wsdl"/>
</port>
</service>
<port binding="tns:Axis2SampleDocLitP
name="Axis2SampleDocLitPort">
<soap:address
location=" http://userguide.axis2.apache
</port>
</service>
将此wsdl 保存为
Axis2SampleDocLit.wsdl
运行
> WSDL2Java -uri ./Axis2Sample DocLit.wsdl -ss -sd -g -d xmlbeans -o ./Axis2SampleDocLit -p org.apache.axis2.userguide
然后修改服务代码,发布服务,编写客户端测试程序。