.NET开发

本类阅读TOP10

·NHibernate快速指南(翻译)
·vs.net 2005中文版下载地址收藏
·【小技巧】一个判断session是否过期的小技巧
·VB/ASP 调用 SQL Server 的存储过程
·?dos下编译.net程序找不到csc.exe文件
·通过Web Services上传和下载文件
·学习笔记(补)《.NET框架程序设计(修订版)》--目录
·VB.NET实现DirectDraw9 (2) 动画
·VB.NET实现DirectDraw9 (1) 托管的DDraw
·建站框架规范书之——文件命名

分类导航
VC语言Delphi
VB语言ASP
PerlJava
Script数据库
其他语言游戏开发
文件格式网站制作
软件工程.NET开发
WSDL规则与示例(1)

作者:未知 来源:月光软件站 加入时间:2005-2-28 月光软件站

首先看看一段简单的JAVA代码,我们用它作为WSDL的服务实现代码:
public class Test
{
  public String echo(String u){
    return "Hello " + u;
  }
}
然后看看用它导出的WSDL:
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://businessEngine.hongsoft.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://businessEngine.hongsoft.com-impl" xmlns:intf="http://businessEngine.hongsoft.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
   <wsdl:types/>//我们没有自定义的类型

   <wsdl:message name="echoResponse">//返回的消息

      <wsdl:part name="echoReturn" type="xsd:string"/>

   </wsdl:message>

   <wsdl:message name="echoRequest">//请求的消息

      <wsdl:part name="u" type="xsd:string"/>

   </wsdl:message>

   <wsdl:portType name="Test">//一个portType可以看着一个类

      <wsdl:operation name="echo" parameterOrder="u">//一个operation就是一个方法

         <wsdl:input message="intf:echoRequest" name="echoRequest"/>

         <wsdl:output message="intf:echoResponse" name="echoResponse"/>

      </wsdl:operation>

   </wsdl:portType>

   <wsdl:binding name="TestSoapBinding" type="intf:Test">
      //下面指定消息封装方式

      <wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
      //下面将WSDL描述与具体实现进行绑定,这里采用SOAP方式

      <wsdl:operation name="echo">

         <wsdlsoap:operation soapAction=""/>

         <wsdl:input name="echoRequest">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://businessEngine.hongsoft.com" use="encoded"/>

         </wsdl:input>

         <wsdl:output name="echoResponse">

            <wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://businessEngine.hongsoft.com" use="encoded"/>

         </wsdl:output>

      </wsdl:operation>

   </wsdl:binding>
   //下面将发布的服务与前面的SOAP绑定进行关联

   <wsdl:service name="TestService">

      <wsdl:port binding="intf:TestSoapBinding" name="Test">

         <wsdlsoap:address location="http://localhost:8080/hongsoft/services/Test"/>

      </wsdl:port>

   </wsdl:service>

</wsdl:definitions>




相关文章

相关软件