生成WSDL文件的三种方法

来源:互联网 发布:淘宝卖家一年的收入 编辑:程序博客网 时间:2024/05/23 02:01

在.NET中有三种方式生成WSDL:

1.在Web Service的URL后面加上WDSL需求,如下:

http://localhost/webExamples/simpleService.asmx?WSDL

2.使用disco.exe。在命令行中写下如下的命令:

disco http://localhost/webExamples/simpleService.asmx

3.使用System.Web.Services.Description命名空间下提供的类

每个 WSDL 文件的根元素都是 <definitions>,必须在其中提供服务的完整描述。首先,必须在 <definitions> 元素中提供各种名称空间的声明。

<definitions> 元素包含一个或多个 < portType > 元素,每个元素都是一系列 operation。可以将单个portType元素看作是将各种方法组成类的一个逻辑分组。应该将每个Types称为服务,因此整个 WSDL 文件将成为一个服务集合。

在每个服务内可以有几个方法或者 operation,WSDL 通过 <operation> 元素来引用它们。

下面是一个最简单的WSDL例子

<?xml version="1.0" encoding="UTF-8" ?>
<definitions name="MobilePhoneService"
targetNamespace="www.mobilephoneservice.com/MobilePhoneService-interface"
xmlns="http://schemas.xmlsoap.org/wsdl/"
xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"
xmlns:tns="http://www.mobilephoneservice.com/MobilePhoneService"
xmlns:xsd="http://www.w3.org/1999/XMLSchema">

<portType name="MobilePhoneService_port">
<operation name="getListOfModels ">
.......
.......
</operation>

<operation name="getPrice">
.......
.......
</operation>
</portType>
</definitions>

 

原创粉丝点击