假设我们有一个简单的Web服务,其中包含以下WSDL:
<?xml version="1.0"?>
<wsdl:definitions name="HelloWorld" targetNamespace="http://codenotfound.com/services/helloworld" xmlns:tns="http://codenotfound.com/services/helloworld"
xmlns:types="http://codenotfound.com/types/helloworld" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://codenotfound.com/types/helloworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1.0">
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string" />
<xsd:element name="lastName" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="greeting">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="greeting" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="SayHelloInput">
<wsdl:part name="person" element="types:person" />
</wsdl:message>
<wsdl:message name="SayHelloOutput">
<wsdl:part name="greeting" element="types:greeting" />
</wsdl:message>
<wsdl:portType name="HelloWorld_PortType">
<wsdl:operation name="sayHello">
<wsdl:input message="tns:SayHelloInput" />
<wsdl:output message="tns:SayHelloOutput" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorld_SoapBinding" type="tns:HelloWorld_PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sayHello">
<soap:operation soapAction="http://codenotfound.com/services/helloworld/sayHello" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorld_Service">
<wsdl:documentation>Hello World service</wsdl:documentation>
<wsdl:port name="HelloWorld_Port" binding="tns:HelloWorld_SoapBinding">
<soap:address location="http://localhost:8080/codenotfound/ws/helloworld" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
让我们还假设我有一个开发的客户端,可以毫无问题地使用所有公开的服务。
但是,如果您现在更改由此暴露的wsdl:
<?xml version="1.0"?>
<wsdl:definitions name="HelloWorld" targetNamespace="http://codenotfound.com/services/helloworld" xmlns:tns="http://codenotfound.com/services/helloworld"
xmlns:types="http://codenotfound.com/types/helloworld" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<xsd:schema targetNamespace="http://codenotfound.com/types/helloworld" xmlns:xsd="http://www.w3.org/2001/XMLSchema" elementFormDefault="qualified"
attributeFormDefault="unqualified" version="1.0">
<xsd:element name="person">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="firstName" type="xsd:string" />
<xsd:element name="lastName" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:element name="greeting">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="greeting" type="xsd:string" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
</xsd:schema>
</wsdl:types>
<wsdl:message name="HelloInput">
<wsdl:part name="person" element="types:person" />
</wsdl:message>
<wsdl:message name="HelloOutput">
<wsdl:part name="greeting" element="types:greeting" />
</wsdl:message>
<wsdl:portType name="HelloWorld_PortType">
<wsdl:operation name="sayHello">
<wsdl:input message="tns:HelloInput" />
<wsdl:output message="tns:HelloOutput" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="HelloWorld_SoapBinding" type="tns:HelloWorld_PortType">
<soap:binding style="document" transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="sayHello">
<soap:operation soapAction="http://codenotfound.com/services/helloworld/sayHello" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="HelloWorld_Service">
<wsdl:documentation>Hello World service</wsdl:documentation>
<wsdl:port name="HelloWorld_Port" binding="tns:HelloWorld_SoapBinding">
<soap:address location="http://localhost:8080/codenotfound/ws/helloworld" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
也就是说,仅更改了WSDL规范中消息的名称。也就是说,将<wsdl:message name="SayHelloInput">
更改为<wsdl:message name="HelloInput">
,将<wsdl:message name="SayHelloOutput">
更改为<wsdl:message name="HelloOutput">
。现在的问题是:这两个Web服务版本之间有什么区别?如果如上例所示更改了WSDL,它将对保持不变的客户端产生什么影响?
非常感谢!