WSDL 如下:
- <?xml version="1.0" encoding="UTF-8"?>
- <wsdl:deFinitions targetNamespace="http://xfire.codehaus.org/BookService" xmlns:tns="http://xfire.codehaus.org/BookService" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:soap12="http://www.w3.org/2003/05/soap-envelope" xmlns:ns1="http://demo.xfire.codehaus.org" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soapenc11="http://schemas.xmlsoap.org/soap/encoding/" xmlns:soapenc12="http://www.w3.org/2003/05/soap-encoding" xmlns:soap11="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
- <wsdl:types>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://xfire.codehaus.org/BookService">
- <xsd:element name="getBooks">
- <xsd:complexType/>
- </xsd:element>
- <xsd:element name="getBooksResponse">
- <xsd:complexType>
- <xsd:sequence>
- <xsd:element maxOccurs="1" minOccurs="1" name="book" nillable="true" type="ns1:Book">
- <xsd:annotation>
- <xsd:documentation>All books.</xsd:documentation>
- </xsd:annotation>
- </xsd:element>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:element>
- </xsd:schema>
- <xsd:schema xmlns:xsd="http://www.w3.org/2001/XMLSchema" attributeFormDefault="qualified" elementFormDefault="qualified" targetNamespace="http://demo.xfire.codehaus.org">
- <xsd:complexType name="Book">
- <xsd:sequence>
- <xsd:element minOccurs="0" name="author" nillable="true" type="xsd:string"/>
- <xsd:element minOccurs="0" name="isbn" nillable="true" type="xsd:string"/>
- <xsd:element minOccurs="0" name="title" nillable="true" type="xsd:string"/>
- </xsd:sequence>
- </xsd:complexType>
- </xsd:schema>
- </wsdl:types>
- <wsdl:message name="getBooksRequest">
- <wsdl:part name="parameters" element="tns:getBooks">
- </wsdl:part>
- </wsdl:message>
- <wsdl:message name="getBooksResponse">
- <wsdl:part name="parameters" element="tns:getBooksResponse">
- </wsdl:part>
- </wsdl:message>
- <wsdl:portType name="BookServicePortType">
- <wsdl:documentation/>
- <wsdl:operation name="getBooks">
- <wsdl:documentation/>
- <wsdl:input name="getBooksRequest" message="tns:getBooksRequest">
- </wsdl:input>
- <wsdl:output name="getBooksResponse" message="tns:getBooksResponse">
- </wsdl:output>
- </wsdl:operation>
- </wsdl:portType>
- <wsdl:binding name="BookServiceHttpBinding" type="tns:BookServicePortType">
- <wsdlsoap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http"/>
- <wsdl:operation name="getBooks">
- <wsdlsoap:operation soapAction=""/>
- <wsdl:input name="getBooksRequest">
- <wsdlsoap:body use="literal"/>
- </wsdl:input>
- <wsdl:output name="getBooksResponse">
- <wsdlsoap:body use="literal"/>
- </wsdl:output>
- </wsdl:operation>
- </wsdl:binding>
- <wsdl:service name="BookService">
- <wsdl:port name="BookServiceHttpPort" binding="tns:BookServiceHttpBinding">
- <wsdlsoap:address location="http://hehui:8080/xfire/services/BookService"/>
- </wsdl:port>
- </wsdl:service>
- </wsdl:deFinitions>
build.xml 如下:
- <?xml version="1.0"?>
- <project name="wsgen" default="wsgen" basedir=".">
- <taskdef name="wsgen" classname="org.codehaus.xfire.gen.WsGenTask"
- />
- <target name="wsgen" description="remove all built files">
- <wsgen outputDirectory="."
- wsdl="BookService.wsdl" package="net" overwrite="true"/>
- </target>
- </project>
- import net.BookServiceClient;
- import org.codehaus.xfire.demo.Book;
- public class XFireClient2 {
- /**
- * @param args
- */
- public static void main(String[] args) {
- // Todo Auto-generated method stub
- BookServiceClient client = new BookServiceClient();
- Book book = client.getBookServiceHttpPort().getBooks();
- System.out.println(book.getTitle().getValue());
- }
- }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 [email protected] 举报,一经查实,本站将立刻删除。