Loading

CXF学习(3) wsdl文件

<!--一次webservice调用,其实并不是方法调用,而是发送SOAP消息 ,即xml片段-->
<!--以上一篇中的wsdl文档为例,这里我将注释写到文档中 -->
<!--targetNamespace 相当于java中的package -->
<!--实际项目中应该会有wsdl:import标签,和java总的import概念是样的 -->
<!--xmlns相当于java中的import,里面的地址,和地址打开后里面的内容的targetNamespace是对应的 -->
<wsdl:definitions xmlns:xsd="http://www.w3.org/2001/XMLSchema"
    xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:tns="http://hello.test.com/"
    xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:ns1="http://schemas.xmlsoap.org/soap/http"
    name="HelloWorldWS" targetNamespace="http://hello.test.com/">
    <!--types里面是标准的xml文档 -->
    <wsdl:types>
        <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema"
            xmlns:tns="http://hello.test.com/" elementFormDefault="unqualified"
            targetNamespace="http://hello.test.com/" version="1.0">
            <xs:element name="sayHello" type="tns:sayHello" />
            <xs:element name="sayHelloResponse" type="tns:sayHelloResponse" />
            <xs:complexType name="sayHello">
                <!-- 这里sequence里面是空的是因为没有参数,通常有参数的时候还有形如: -->
                <!-- <xs:element minOccurs="0"> name="return" type="xs:string"/> -->
                <!-- 这样的子元素。其中minOccurs表示最少出现0次,没有写明最多出现多少次,默认最多就是出现一次 -->
                <xs:sequence />
            </xs:complexType>
            <xs:complexType name="sayHelloResponse">
                <xs:sequence />
            </xs:complexType>
        </xs:schema>
    </wsdl:types>
    <!-- webservice 接口中的每一个方法对应两个message -->
    <wsdl:message name="sayHello">
        <wsdl:part element="tns:sayHello" name="parameters"></wsdl:part>
    </wsdl:message>
    <wsdl:message name="sayHelloResponse">
        <wsdl:part element="tns:sayHelloResponse" name="parameters"></wsdl:part>
    </wsdl:message>
    <!-- portType下面包含N个operation,每一个operation对应一个操作s -->
    <wsdl:portType name="HelloWorld">
        <wsdl:operation name="sayHello">
            <!-- 传入消息为sayHello -->
            <wsdl:input message="tns:sayHello" name="sayHello"></wsdl:input>
            <!-- 传出消息为  -->
            <wsdl:output message="tns:sayHelloResponse" name="sayHelloResponse"></wsdl:output>
        </wsdl:operation>
    </wsdl:portType>
    <wsdl:binding name="HelloWorldWSSoapBinding" type="tns:HelloWorld">
        <soap:binding style="document"
            transport="http://schemas.xmlsoap.org/soap/http" />
        <wsdl:operation name="sayHello">
            <soap:operation soapAction="" style="document" />
            <wsdl:input name="sayHello">
                <soap:body use="literal" />
            </wsdl:input>
            <wsdl:output name="sayHelloResponse">
                <soap:body use="literal" />
            </wsdl:output>
        </wsdl:operation>
    </wsdl:binding>
    <wsdl:service name="HelloWorldWS">
        <wsdl:port binding="tns:HelloWorldWSSoapBinding" name="HelloWorldImplPort">
            <soap:address location="http://localhost:1234/ws" />
        </wsdl:port>
    </wsdl:service>
</wsdl:definitions>

 

posted @ 2016-04-15 11:10  注销111  阅读(394)  评论(0编辑  收藏  举报