首页 > 开发 > 综合 > 正文

webservice系列教学(17)-例程用到的wsdl文件等

2024-07-21 02:25:09
字体:
来源:转载
供稿:网友

《service1.asmx》
<%@ webservice language="vb" codebehind="service1.asmx.vb" class="yundan.service1" %>
《service1.asmx.vb》
imports system.web.services
<webservice(namespace := "http://tempuri.org/")> _
public class service1
    inherits system.web.services.webservice
#region " web 服务设计器生成的代码 "

    public sub new()
        mybase.new()

        '该调用是 web 服务设计器所必需的。
        initializecomponent()

        '在 initializecomponent() 调用之后添加您自己的初始化代码

    end sub

    'web 服务设计器所必需的
    private components as system.componentmodel.icontainer

    '注意:以下过程是 web 服务设计器所必需的
    '可以使用 web 服务设计器修改此过程。
    '不要使用代码编辑器修改它。
    <system.diagnostics.debuggerstepthrough()> private sub initializecomponent()
        components = new system.componentmodel.container()
    end sub

    protected overloads overrides sub dispose(byval disposing as boolean)
        'codegen: 此过程是 web 服务设计器所必需的
        '不要使用代码编辑器修改它。
        if disposing then
            if not (components is nothing) then
                components.dispose()
            end if
        end if
        mybase.dispose(disposing)
    end sub

#end region
<webmethod()> public function test(byval a as integer, byval b as integer) as integer
        return a + b
    end function
end class
《service1.wsdl》
<?xml version="1.0" encoding="utf-8"?>
<definitions xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/xmlschema" xmlns:s0="http://tempuri.org/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tm="http://microsoft.com/wsdl/mime/textmatching/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" targetnamespace="http://tempuri.org/" xmlns="http://schemas.xmlsoap.org/wsdl/">
  <types>
    <s:schema elementformdefault="qualified" targetnamespace="http://tempuri.org/">
      <s:element name="test">
        <s:complextype>
          <s:sequence>
            <s:element minoccurs="1" maxoccurs="1" name="a" type="s:int" />
            <s:element minoccurs="1" maxoccurs="1" name="b" type="s:int" />
          </s:sequence>
        </s:complextype>
      <s:element name="string" nillable="true" type="s:string" />
      <s:element name="arrayofstring" nillable="true" type="s0:arrayofstring" />
      <s:element name="boolean" type="s:boolean" />
      <s:element name="int" type="s:int" />
  <message name="testsoapin">
    <part name="parameters" element="s0:test" />
  </message>
  <message name="testsoapout">
    <part name="parameters" element="s0:testresponse" />
  </message>
  <message name="testhttpgetin">
    <part name="a" type="s:string" />
    <part name="b" type="s:string" />
  </message>
  <message name="testhttpgetout">
    <part name="body" element="s0:int" />
  </message>
  <message name="testhttppostin">
    <part name="a" type="s:string" />
    <part name="b" type="s:string" />
  </message>
  <message name="testhttppostout">
    <part name="body" element="s0:int" />
  </message>
    <operation name="test">
      <input message="s0:testsoapin" />
      <output message="s0:testsoapout" />
    </operation>
<porttype name="service1httpget">
    <operation name="test">
      <input message="s0:testhttpgetin" />
      <output message="s0:testhttpgetout" />
    </operation>
</porttype>
<porttype name="service1httppost">
    <operation name="test">
      <input message="s0:testhttppostin" />
      <output message="s0:testhttppostout" />
    </operation>
  </porttype>
<binding name="service1soap" type="s0:service1soap">
    <soap:binding transport="http://schemas.xmlsoap.org/soap/http" style="document" />
    <operation name="test">
      <soap:operation soapaction="http://tempuri.org/test" style="document" />
      <input>
        <soap:body use="literal" />
      </input>
      <output>
        <soap:body use="literal" />
      </output>
    </operation>
  </binding>
  <binding name="service1httpget" type="s0:service1httpget">
    <http:binding verb="get" />
  <operation name="test">
      <http:operation location="/test" />
      <input>
        <http:urlencoded />
      </input>
      <output>
        <mime:mimexml part="body" />
      </output>
    </operation>
  </binding>
<binding name="service1httppost" type="s0:service1httppost">
    <http:binding verb="post" />
    <operation name="test">
      <http:operation location="/test" />
      <input>
        <mime:content type="application/x-www-form-urlencoded" />
      </input>
      <output>
        <mime:mimexml part="body" />
      </output>
    </operation>
  </binding>
  <service name="service1">
    <port name="service1soap" binding="s0:service1soap">
      <soap:address location="http://192.168.0.4/yundan/service1.asmx" />
    </port>
    <port name="service1httpget" binding="s0:service1httpget">
      <http:address location="http://192.168.0.4/yundan/service1.asmx" />
    </port>
    <port name="service1httppost" binding="s0:service1httppost">
      <http:address location="http://192.168.0.4/yundan/service1.asmx" />
    </port>
  </service>
</definitions>
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表