例子eg:
<definitions xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:tns="http://impl.service01.com/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns="http://schemas.xmlsoap.org/wsdl/"targetNamespace="http://impl.service01.com/" name="SayHelloImplService">
<!--
<types>标签中<xsd:schema>标签的schemaLocation="http://localhost:8234/CallSayHelloService?xsd=1"定义了webservice的方法,"http://localhost:8234/CallSayHelloService?xsd=1"显示的xml元素为:
<xs:schema xmlns:tns="http://impl.service01.com/" xmlns:xs="http://www.w3.org/2001/XMLSchema" version="1.0" targetNamespace="http://impl.service01.com/">
<xs:element name="Say" type="tns:Say"/>
<xs:element name="SayResponse" type="tns:SayResponse"/>
<xs:complexType name="Say">
<xs:sequence>
<xs:element name="arg0" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
<xs:complexType name="SayResponse">
<xs:sequence>
<xs:element name="return" type="xs:string" minOccurs="0"/>
</xs:sequence>
</xs:complexType>
</xs:schema>
其中:定义了say方法及传入参数
arg0的类型去say的返回方法
SayResponse及输出参数
return的类型。
-->
<types>
<xsd:schema>
<xsd:import namespace="http://impl.service01.com/" schemaLocation="http://localhost:8234/CallSayHelloService?xsd=1"/>
</xsd:schema>
</types>
<!--
message
标签定义了webservice的响应消息,<part>标签的element属性指向types标签定义的方法、、
这两个标签对应:String ss=s.say("Jcak");
-->
<message name="Say">
<part name="parameters" element="tns:Say"/>
</message>
<message name="SayResponse">
<part name="parameters" element="tns:SayResponse"/>
</message>
<!--
<portType>标签定义了SEI的相关内容,它的<operation>指定方法
-->
<portType name="SayHelloImpl">
<operation name="Say">
<input message="tns:Say"/>
<output message="tns:SayResponse"/>
</operation>
</portType>
<!--
<binding>是SEI的实现类
这两个标签对应:SayHelloImpl s=aa.getSayHelloImplPort();
-->
<binding name="SayHelloImplPortBinding" type="tns:SayHelloImpl">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document"/>
<operation name="Say">
<soap:operation soapAction=""/>
<input>
<soap:body use="literal"/>
</input>
<output>
<soap:body use="literal"/>
</output>
</operation>
</binding>
<!--
<service>标签标示service的服务名name="SayHelloImplService"及地址<soap>
对应:SayHelloImplService aa=new SayHelloImplService();
-->
<service name="SayHelloImplService">
<port name="SayHelloImplPort" binding="tns:SayHelloImplPortBinding">
<soap:address location="http://localhost:8234/CallSayHelloService"/>
</port>
</service>
</definitions>
客户端调用:
public class Server01ClientTest {
public static void main(String[] args){
SayHelloImplService aa=new SayHelloImplService();
SayHelloImpl s=aa.getSayHelloImplPort();
System.out.println("客户端调用成功:");
String ss=s.say("Jcak");
}
}
public static void main(String[] args){
SayHelloImplService aa=new SayHelloImplService();
SayHelloImpl s=aa.getSayHelloImplPort();
System.out.println("客户端调用成功:");
String ss=s.say("Jcak");
}
}