webservice之wsdl详解

例子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");
}
}


  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值