WSDL实例解析

WSDL文件复杂类型的解析及其实例化代码生成 1.设计要求根据WebService的地址,对其WSDL文件进行解析,重点解析其中包含的复杂类型。针对解析出的复杂类型的结构,生成对应的类实例化代码。2.WSDL解析过程WSDL的解析过程就是对WSDL内标签一层一层深入的过程,直到获得所需的那一层数据,下面以WSDL文件中的复杂类型(ComplexType)的解析为例,对该部分的代码进行说明。public void parseWSDL(String 阅读详情
转:http://www.blogjava.net/ricegun/articles/328544.html

WSDL实例解析

关键字: web service

WSDL的主要文档元素

WSDL文档可以分为两部分。顶部分由抽象定义组成,而底部分则由具体描述组成。抽象部分以独立于平台和语言的方式定义SOAP消息,它们并不包含任何随 机器或语言而变的元素。这就定义了一系列服务,截然不同的应用都可以实现。具体部分,如数据的序列化则归入底部分,因为它包含具体的定义。在上述的文档元 素中,<types>、<message>、<portType>属于抽象定义 层,<binding>、<service>属于具体定义层。所有的抽象可以是单独存在于别的文件中,也可以从主文档中导入。 

WSDL文档的结构实例解析 
下面我们将通过一个实际的WSDL文档例子来详细说明各标签的作用及关系。

Wsdl代码 
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <definitions  
  3. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  
  4. xmlns:tns="http://www.jsoso.com/wstest"  
  5. xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
  6. xmlns="http://schemas.xmlsoap.org/wsdl/"  
  7. targetNamespace="http://www.jsoso.com/wstest"  
  8. name="Example">  
  9. <types>  
  10. <xsd:schema>  
  11. <xsd:import  
  12. namespace="http://www.jsoso.com/wstest"  
  13. schemaLocation="http://localhost:8080/hello?xsd=1"></xsd:import>  
  14. </xsd:schema>  
  15. </types>  
  16. <message name="toSayHello">  
  17. <part name="userName" type="xsd:string"></part>  
  18. </message>  
  19. <message name="toSayHelloResponse">  
  20. <part name="returnWord" type="xsd:string"></part>  
  21. </message>  
  22. <message name="sayHello">  
  23. <part name="person" type="tns:person"></part>  
  24. <part name="arg1" type="xsd:string"></part>  
  25. </message>  
  26. <message name="sayHelloResponse">  
  27. <part name="personList" type="tns:personArray"></part>  
  28. </message>  
  29. <message name="HelloException">  
  30. <part name="fault" element="tns:HelloException"></part>  
  31. </message>  
  32. <portType name="Example">  
  33. <operation name="toSayHello" parameterOrder="userName">  
  34. <input message="tns:toSayHello"></input>  
  35. <output message="tns:toSayHelloResponse"></output>  
  36. </operation>  
  37. <operation name="sayHello" parameterOrder="person arg1">  
  38. <input message="tns:sayHello"></input>  
  39. <output message="tns:sayHelloResponse"></output>  
  40. <fault message="tns:HelloException" name="HelloException"></fault>  
  41. </operation>  
  42. </portType>  
  43. <binding name="ExamplePortBinding" type="tns:Example">  
  44. <soap:binding  
  45. transport="http://schemas.xmlsoap.org/soap/http"  
  46. style="rpc"></soap:binding>  
  47. <operation name="toSayHello">  
  48. <soap:operation soapAction="sayHello"></soap:operation>  
  49. <input>  
  50. <soap:body use="literal"  
  51. namespace="http://www.jsoso.com/wstest"></soap:body>  
  52. </input>  
  53. <output>  
  54. <soap:body use="literal"  
  55. namespace="http://www.jsoso.com/wstest"></soap:body>  
  56. </output>  
  57. </operation>  
  58. <operation name="sayHello">  
  59. <soap:operation soapAction="sayHello"></soap:operation>  
  60. <input>  
  61. <soap:body use="literal"  
  62. namespace="http://www.jsoso.com/wstest"></soap:body>  
  63. </input>  
  64. <output>  
  65. <soap:body use="literal"  
  66. namespace="http://www.jsoso.com/wstest"></soap:body>  
  67. </output>  
  68. <fault name="HelloException">  
  69. <soap:fault name="HelloException" use="literal"></soap:fault>  
  70. </fault>  
  71. </operation>  
  72. </binding>  
  73. <service name="Example">  
  74. <port name="ExamplePort" binding="tns:ExamplePortBinding">  
  75. <soap:address location="http://localhost:8080/hello"></soap:address>  
  76. </port>  
  77. </service>  
  78. </definitions>  

 

由于上面的事例XML较长,我们将其逐段分解讲解

 

WSDL文档的根元素:<definitions>

Xml代码 
  1. <definitions  
  2. xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/"  
  3. xmlns:tns="http://www.jsoso.com/wstest"  
  4. xmlns:xsd="http://www.w3.org/2001/XMLSchema"  
  5. xmlns="http://schemas.xmlsoap.org/wsdl/"  
  6. targetNamespace="http://www.jsoso.com/wstest"  
  7. name="Example">  
  8. ……  
  9. ……  
  10. </definitions>  

 <definitions>定义了文档中用到的各个xml元素的namespace缩写,也界定了本文档自己的 targetNamespace="http://www.jsoso.com/wstest",这意味着其它的XML要引用当前XML中的元素时,要声 明这个namespace。注意xmlns:tns="http://www.jsoso.com/wstest"这个声明,它标示了使用tns这个前缀 指向自身的命名空间。

 

WSDL文档数据类型定义元素:<types>

Xml代码 
  1. <types>  
  2. <xsd:schema>  
  3. <xsd:import  
  4. namespace="http://www.jsoso.com/wstest"  
  5. schemaLocation="http://localhost:8080/hello?xsd=1"></xsd:import>  
  6. </xsd:schema>  
  7. </types>  

 <types>标签定义了当前的WSDL文档用到的数据类型。要说明的是,为了最大程度的平台中立性,WSDL 使用 XML Schema 语法来定义数据类型。这些数据类型用来定义web service方法的参数和返回指。对于通用的原生数据类型如:integer , boolean , char , float等,在W3C的标准文档http://www.w3.org/2001/XMLSchema中已经做了定义。这里我们要引入的schema定义 schemaLocation="http://localhost:8080/hello?xsd=1"是我们自定义的Java对象类型。

 

WSDL文档消息体定义元素:< message >

Xml代码 
  1. <message name="toSayHello">  
  2. <part name="userName" type="xsd:string"></part>  
  3. </message>  
  4. <message name="toSayHelloResponse">  
  5. <part name="returnWord" type="xsd:string"></part>  
  6. </message>  
  7. <message name="sayHello">  
  8. <part name="person" type="tns:person"></part>  
  9. <part name="arg1" type="xsd:string"></part>  
  10. </message>  
  11. <message name="sayHelloResponse">  
  12. <part name="personList" type="tns:personArray"></part>  
  13. </message>  
  14. <message name="HelloException">  
  15. <part name="fault" element="tns:HelloException"></part>  
  16. </message>  

 <message>元素定义了web service函数的参数。<message>元素中的每个<part>子元素都和某个参数相符。输入参数在<message>元素中定义,与输出参数相 隔离,输出参数有自己的<message>元素。兼作输入、输出的参数在输入输出的<message>元素中有它们相应的<part>元素。输出 <message>元素以"Response"结尾,对Java而言方法得返回值就对应一个输出的<message>。每个<part>元素都有名字和类 型属性,就像函数的参数有参数名和参数类型。 

在上面的文档中有两个输入参数、两个输出参数和一个错误参数(对应Java中的Exception)。 

 输入参数<message>的name属性分别命名为toSayHello,sayHello。 
toSayHello对应输入参数userName,参数类型为xsd:string,在Java语言中就是String; 
sayHello对应两个输入参数person和arg1,类型为tns:person和xsd:string。这里tns:person类型就是引用了< types >标签中的类型定义。 

 输出参数<message>的name属性分别命名为toSayHelloResponse和sayHelloResponse。 
这个名称和输入参数的<message>标签name属性对应,在其后面加上Response尾缀。 
toSayHelloResponse对应的返回值是returnWord,参数类型为xsd:string; 
sayHelloResponse对应的返回值是personList,参数类型为tns:personArray(自定义类型); 

 错误参数<message>的name属性为HelloException。 
它的<part>子标签element而不是type来定义类型。 

以上的message标签的name属性通常使用web service函数方法名作为参照,错误参数标签则使用异常类名为参照。标签中的参数名称,即part子元素的name属性是可自定义的(下一章节详细说 明)。message标签的参数类型将引用types标签的定义。

 

WSDL文档函数体定义元素:< portType >

Xml代码 
  1. <portType name="Example">  
  2. <operation name="toSayHello" parameterOrder="userName">  
  3. <input message="tns:toSayHello"></input>  
  4. <output message="tns:toSayHelloResponse"></output>  
  5. </operation>  
  6. <operation name="sayHello" parameterOrder="person arg1">  
  7. <input message="tns:sayHello"></input>  
  8. <output message="tns:sayHelloResponse"></output>  
  9. <fault message="tns:HelloException" name="HelloException"></fault>  
  10. </operation>  
  11. </portType>  

 
在<operation>元素中,name属性表示服务方法名,parameterOrder属性表示方法的参数顺序,使用空格符分割多个参 数,如:“parameterOrder="person arg1”。<operation>元素的子标签<input>表示输入参数说明,它引用<message>标签中的输入参 数。<output>表示输出参数说明,它引用<message>标签中的输出参数。<fault>标签在Java方法中的特别 用来表示异常(其它语言有对应的错误处理机制),它引用<message>标签中的错误参数。 

WSDL绑定实现定义元素:< binding >

Xml代码 
  1. <binding name="ExamplePortBinding" type="tns:Example">  
  2. <soap:binding  
  3. transport="http://schemas.xmlsoap.org/soap/http"  
  4. style="rpc"></soap:binding>  
  5. <operation name="toSayHello">  
  6. <soap:operation soapAction="sayHello"></soap:operation>  
  7. <input>  
  8. <soap:body use="literal"  
  9. namespace="http://www.jsoso.com/wstest"></soap:body>  
  10. </input>  
  11. <output>  
  12. <soap:body use="literal"  
  13. namespace="http://www.jsoso.com/wstest"></soap:body>  
  14. </output>  
  15. </operation>  
  16. <operation name="sayHello">  
  17. <soap:operation soapAction="sayHello"></soap:operation>  
  18. <input>  
  19. <soap:body use="literal"  
  20. namespace="http://www.jsoso.com/wstest"></soap:body>  
  21. </input>  
  22. <output>  
  23. <soap:body use="literal"  
  24. namespace="http://www.jsoso.com/wstest"></soap:body>  
  25. </output>  
  26. <fault name="HelloException">  
  27. <soap:fault name="HelloException" use="literal"></soap:fault>  
  28. </fault>  
  29. </operation>  
  30. </binding>  

 <binding>标签是完整描述协议、序列化和编码的地方,<types>,<message>和<portType>标签处理抽象的数据内容,而<binding>标签是处理数据传输的物理实现。 
<binding>标签把前三部分的抽象定义具体化。 

首先<binding>标签使用<soap:binding>的transport和style属性定义了Web Service的通讯协议HTTP和SOAP的请求风格RPC。其次<operation>子标签将portType中定义的 operation同SOAP的请求绑定,定义了操作名称soapAction,输出输入参数和异常的编码方式及命名空间。 

WSDL服务地址绑定元素:< service >

Xml代码 
  1. <service name="Example">  
  2. <port name="ExamplePort" binding="tns:ExamplePortBinding">  
  3. <soap:address location="http://localhost:8080/hello"></soap:address>  
  4. </port>  
  5. </service>  

 service是一套<port>元素。在一一对应形式下,每个<port>元素都和一个location关联。如果同一个<binding>有多个<port>元素与之关联,可以使用额外的URL地址作为替换。 

一个WSDL文档中可以有多个<service>元素,而且多个<service>元素十分有用,其中之一就是可以根据目标URL来组织端口。在一个 WSDL文档中,<service>的name属性用来区分不同的service。在同一个service中,不同端口,使用端口的"name"属性区 分。 

简单的描述了WSDL对SOAP协议的支持,以及在Web Service中的作用。

《跨界杂谈》华为印象(五):高度集权的矩阵式架构 高度集权的矩阵式架构 “高度集权的矩阵式架构”不是官方术语。是笔者的一位同事非常经典的总结。解释这个句话还是有点困难的,笔者入职华为三年也没彻底搞明白,在这里只能尝试性的解释一下。 矩阵 我们先看一下“矩阵”。华为有两套部门职能体系,华为内部术语,叫实线部门和虚线部门。由实线与虚线部门交叉构成矩阵。大部分(但不是所有)华为员工都由两个部门(两个领导)进行管理。对员工而言,所谓的实线部 阅读详情

相关推荐

Cloudflare 5秒盾逆向实战:从503到cf_clearance的全流程拆解(附避坑指南)

本文深入拆解了Cloudflare 5秒盾的完整逆向流程,从首次503响应到最终获取cf_clearance令牌,详细解析了五层挑战机制。文章重点分享了实战中的核心避坑指南,包括时间戳校验、动态图片尺寸获取、会话保持方案选择以及复杂环境检测的应对策略,为开发者提供了一套绕过5秒盾的实用方法论。

weixin_29327977的博客 2308

wsdl接口,soap:address location地址为内部地址

wsdl接口,soap:address location地址为内部地址,通过"org.apache.cxf"包访问的时候,出现"org.apache.cxf.interceptor.Fault: Could not send Message"。第二种方式:比较适合的方式,还是有甲方进行修改比较合适。第一种方式:通过指定conduit的方式,指定地址。

weixin_38110854的博客 2235

BUCK型DC/DC变换器的建模与仿真

BUCK型DC-DC变换器的建模与仿真摘要1 文献调研1.1 研究背景1.2 Buck电路的应用场合2 原理分析2.1 模型介绍2.2 模型分析2.3 频域和时域响应2.4 参数指标要求3 参数设计3.1 校正器选择3.2 校正器参数整定3.2.1 积分器3.2.2 一阶微分环节3.2.3 超前校正器3.3 改进4 结论与展望参考文献 摘要   目前工业自动化水平已成为衡量各行各业现代化水平的一个重要标志。如何对一个系统进行建模分析、补偿校正变得越来越重要。   本文选择BUCK型DC/DC变换器作为载体,

屠龙归来仍是少年 2万+

wsdl文档 中soap:address location、soap12:address location、http:address location的作用

最近接口提供方升级接口,导致我调用出错,在此记录下本次解决问题后的弄懂的一些知识点。 最初是cxf调用提供方接口报错:Could not send Message. 1.首先排查接口能否访问,接口提供方webservice地址:http://59.2.1.18:6901/services/MyServices?wsdl 能正常访问 2.检查wsdl文档 wsdl:service部分内容如下...

xx244的博客 1万+

【SoloPi】SoloPi使用2-功能使用,录制回放

Soloπ是什么 Soloπ是一个无线化、非侵入式的Android自动化工具,公测版拥有录制回放、性能测试、一机多控三项主要功能,能为测试开发人员节省宝贵时间。 录制回放功能 Soloπ拥有录制操作的能力,用户只需要通过Soloπ执行用例步骤,Soloπ就能够将用户的操作记录下来,并且支持在各个设备上进行回放,这一切都能够在手机上独立完成。 ...

q_Catherine的博客 5829

FoundationPose复现及Realsense应用

FoundationPose是一个统一的基础模型,用于6D对象姿态估计和跟踪,支持基于模型和无模型的设置。在测试时可以立即应用于未见过的新对象,无需微调,只要给出其CAD模型,或者捕获少量RGBD参考图像。得益于统一框架,下游姿态估计模块在两种3D模型设置中都是相同的,当没有CAD模型时,使用神经隐式表示进行高效的新视角合成。通过大规模合成训练,辅以大型语言模型(LLM)、一种基于transformer的新架构和对比学习公式,实现了强大的泛化能力。

m0_56661101的博客 1万+

解决nginx反向代理web service的soap:address location问题

解决nginx反向代理web service的soap:address location问题

一个标题 3417

MAX31865三线PT100测温实战:配置、接线与代码全解析

本文详细解析MAX31865三线PT100测温的配置、接线与代码实现。通过实战经验分享,介绍如何利用MAX31865芯片实现高精度温度测量,重点讲解三线制接法的自动误差补偿功能,并提供完整的寄存器配置、SPI通信和温度转换算法,帮助开发者快速解决工业测温中的常见问题。

ss78901的博客 758

wsdl文档中的soap:address的生成规则_闲谈PREEvision中的二次开发

我们在使用PREEvision工具的时候经常听到二次开发,那它到底是个什么东西呢?能做什么?又该如何开发?今天我们就来简单的聊一聊。我们知道PREEvision是一款基于模型的、集成式的、可视化的E/E架构开发工具。PREEvision的二次开发是指利用工具提供给用户一系列的开放接口,来实现不同场景下自定义的各种便捷功能。为满足用户在开发过程中不同场景下的花式需求,PREEvisoin可...

weixin_39787792的博客 766

S型速度曲线C程序实现

S型速度曲线C语言程序实现 前言 S型曲线相较于梯形速度曲线具有运行更加平稳的特点,S型曲线共有八种运行情况,感兴趣可以查阅相关文献 代码段 #include <stdio.h> #include <math.h> #define FP64 double int main(void) { /**************************** 定义相关变量(需要映射到PLC寄存器才能进行监控) ***********************/ FP6

LSX312441548的博客 8393

GibbsCAM软件二次开发:GibbsCAM软件API接口详解

API(Application Programming Interface,应用程序编程接口)是一种允许不同软件之间进行通信的接口。在GibbsCAM软件中,API提供了与外部程序交互的能力,使得开发者可以利用GibbsCAM的强大功能进行二次开发,定制化满足特定的制造需求。GibbsCAM的API主要基于.NET框架,使用C#或VB.NET等语言进行编程。在GibbsCAM软件中,通过API接口创建自定义几何形状是实现复杂零件设计和加工策略定制的关键步骤。

kkchenjj的博客 1497

Jsoup解析WSDL文档代码实例

系列文章目录 提示:这里可以添加系列文章的所有文章的目录,目录需要自己手动添加 例如:第一章 Python 机器学习入门之pandas的使用 提示:写完文章后,目录可以自动生成,如何生成可参考右边的帮助文档 文章目录系列文章目录前言一、pandas是什么?二、使用步骤1.引入库2.读入数据总结 前言 提示:这里可以添加本文要记录的大概内容: 例如:随着人工智能的不断发展,机器学习这门技术也越来越重要,很多人都开启了学习机器学习,本文就介绍了机器学习的基础内容。 提示:以下是本篇文章正文内容,下面案例

ccsss_ddnn的博客 992

11、ThingsBoard集群部署k8s

今天终于有时间去搞这个啦,拖了很久了,一直没时间,因为我本地没有那么多机器资源,开虚拟机不够,如果租用阿里云服务器,需要有充值的时间,因为这个费用是按小时付费,需要有连贯的时间来搞才行,今天恰好有时间,就开始搞了,弄成功搞出来了,特地写博客记录下来。

AldrichEugene 992

wsdl java 解析_WSDL实例解析

WSDL的主要文档元素WSDL文档可以分为两部分。顶部分由抽象定义组成,而底部分则由具体描述组成。抽象部分以独立于平台和语言的方式定义SOAP消息,它们并不包含任何随 机器或语言而变的元素。这就定义了一系列服务,截然不同的应用都可以实现。具体部分,如数据的序列化则归入底部分,因为它包含具体的定义。在上述的文档元 素中,、、属于抽象定义 层,、属于具体定义层。所有的抽象可以是单独存在于别的文件中,也...

weixin_42545503的博客 265

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

WSDL实例解析(1)

WSDL文档可以分为两部分。顶部分由抽象定义组成,而底部分则由具体描述组成。抽象部分以独立于平台和语言的方式定义SOAP消息,它们并不包含任何随 机器或语言而变的元素。这就定义了一系列服务,截然不同的应用都可以实现。具体部分,如数据的序列化则归入底部分,因为它包含具体的定义。在上述的文档元 素中,、、属于抽象定义 层,、属于具体定义层。所有的抽象可以是单独存在于别的文件中,也可以从主文档中导入。 

zhang6560329的专栏 573

jdk-8u144-linux-x64.tar.gz.

该资源为搭建Linux系统Java环境用,资源的后缀为tar.gz格式的压缩包

WebService之 WSDL 实例解析

WSDL的主要文档元素 WSDL文档可以分为两部分。顶部分由抽象定义组成,而底部分则由具体描述组成。抽象部分以独立于平台和语言的方式定义SOAP消息,它们并不包含任何随机器或语言而变的元素。这就定义了一系列服务,截然不同的应用都可以实现。具体部分,如数据的序列化则归入底部分,因为它包含具体的定义。在上述的文档元素中,<types>、<message&gt...

weixin_33836874的博客 150

VC中sqlite的使用

在VC中对sqlite的使用,实现数据库大批数据的快速插入,读取数据库中的数据在ListCtrl中显示

java调用wsdl实例_简单实用java调用WSDL接口,并解析返回数据格式

最近因为一些数据问题,需要跟第三方对接数据,OK!要联系方式,联系上了,然后人家就给我一个文档,说所有东西上面都有.....,没办法只能自己慢慢琢磨了!然后发现他们是WSDL的方式调用的,百度了一下,WSDL**是基于 XML 的用于描述 Web Services 以及如何访问 Web Services 的语言,**以前只是知道有这么各东西,但是从来没用过,只能研究一下怎么搞了!以下只是我个人研究...

weixin_33997566的博客 694

webService学习1----WSDL

一. WSDL是什么?          WSDL即Web Services Description Language,是一个用来描述Web服务和说明如何与Web服务通信的XML语言。         WSDL是一个用于精确描述Web服务的文档,WSDL文档是一个遵循WSDL XML模式的XML文档。WSDL 文档将Web服务定义为服务访问点或端口的集合。在 WSDL 中,由于服务访问点和消息

alaric's blog 555
上一篇: How to create a bootable USB stick on Windows
下一篇: maven 程序包com.sun.image.codec.jpeg不存在 问题的完美解决
lcathm
博客等级 码龄18年 37粉丝 44原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值