webservice之wsdl详解
2016-03-06 11:35
393 查看
例子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");
}
}
<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");
}
}
相关文章推荐
- HDU 1418 抱歉
- 51nod 1015 水仙花数
- 2016寒假训练——尺取法
- 研究生毕业前要完成的事
- Effective Java 第一条:考虑用静态工厂方法替代构造器
- Hibernate注解
- iOS Xcode, 解决“Could not insert new outlet connection”的问题。
- javascript高级程序设计笔记-第十章(DOM)
- C语言实现使用静态数组来构造栈结构
- Java集合框架之概括
- #Android学习#Fragment简单切换及常用控件用法
- 《暗时间》读书笔记(三)
- 详解XHTML中的标题标签与段落标签的使用
- 进程与线程的区别(转)
- 如何赚到互联网的“下一桶金”
- 非ios系统是否还有出路?
- EL表达<%@page isELIgnored="false"%>问题
- 用python爬虫来爬华科宿舍查电费
- ttps://localhost:1158/em无法访问无法访问,OC4J Configuration issue
- [LeetCode]287. Find the Duplicate Number