设为首页 加入收藏

TOP

wsdl 关于nillable和minOccurs 在.NET和java中的不同(三)
2019-09-03 03:26:46 】 浏览:115
Tags:wsdl 关于 nillable minOccurs .NET java 不同
ger phoneNbr) {this.phoneNbr = phoneNbr;} }

2.2.2、定义服务类:WebServiceTest.java

package com.lubiao.axis;

public class WebServiceTest{
	public String helloWorld(int id,Integer phoneNbr,String name,Person person){
		return "Hello World";
	}
}

helloWorld方法有4个参数,前三个参数和Person类的三个属性是一样的,加入这三个参数的目的是进行对比测试。
2.2.3、查看生成的Wsdl

<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://axis.lubiao.com" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://axis.lubiao.com" xmlns:intf="http://axis.lubiao.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
  <!--WSDL created by Apache Axis version: 1.4 Built on Apr 22, 2006 (06:55:48 PDT)-->
  <wsdl:types>
    <schema elementFormDefault="qualified" targetNamespace="http://axis.lubiao.com" xmlns="http://www.w3.org/2001/XMLSchema">
      <element name="helloWorld">
        <complexType>
          <sequence>
            <element name="id" type="xsd:int"/>
            <!--nillable默认为false,minOccurs默认为1:即id元素为必输,且值不能为空-->
            <element name="phoneNbr" type="xsd:int"/>
            <!--nillable默认为false,minOccurs默认为1:即phoneNbr元素为必输,且值不能为空-->
            <element name="name" type="xsd:string"/>
            <!--nillable默认为false,minOccurs默认为1:即name元素为必输,且值不能为空-->
            <element name="person" type="impl:Person"/>
            <!--nillable默认为false,minOccurs默认为1:即person元素为必输,且值不能为空-->
          </sequence>
        </complexType>
      </element>
      <complexType name="Person">
        <sequence>
          <element name="id" type="xsd:int"/>
          <!--nillable默认为false,minOccurs默认为1:即id元素为必输,且值不能为空-->
          <element name="name" nillable="true" type="xsd:string"/>
          <!--nillable默认为true,minOccurs默认为1:即name元素为必输,但值可以为空-->
          <element name="phoneNbr" nillable="true" type="xsd:int"/>
          <!--nillable默认为true,minOccurs默认为1:即phoneNbr元素为必输,但值可以为空-->
        </sequence>
      </complexType>
      <element name="helloWorldResponse">
        <complexType>
          <sequence>
            <element name="helloWorldReturn" type="xsd:string"/>
          </sequence>
        </complexType>
      </element>
    </schema>
  </wsdl:types>
  <!-- 其它元素省略 -->
</wsdl:definitions>

2.2.4、得出结论
* id参数和Person.id属性都是值类型:[元素节点] 都必输,[元素取值] 都不能为空;
* phoneNbr参数和Person.phoneNbr属性都是包装类型:[元素节点] 都必输,但前者[元素取值]不能为空,后者[元素取值]可以为空;
* name参数和Person.name属性都是普通的引用类型:[元素节点] 都必输,但前者[元素取值]不能为空,后者[元素取值]可以为空;
* person参数属于普通引用类型:[元素节点]必输,且[元素取值]不能为空;
*总结:此框架生成wsdl时认为:
        1、作为方法参数时,不管是值类型、包装类型还是普通引用类型,[元素节点]都为必输项,且[元素取值]都不能为空;
        2、作为对象属性时,不管是值类型、包装类型还是普通引用类型,[元素节点]都为必输项,其中值类型的[元素取值]不能为空,但包装类型和普通

首页 上一页 1 2 3 4 5 6 7 下一页 尾页 3/11/11
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
上一篇《深入.NET平台和C#编程》内部测.. 下一篇.NET中使用反射访问属性方法

最新文章

热门文章

Hot 文章

Python

C 语言

C++基础

大数据基础

linux编程基础

C/C++面试题目