WebService的简单安全

【软件工具】VMware Workstation Pro 15.5安装 VMware Workstation Pro 15.5安装 阅读详情

1. 有关生存期的补充

正常情况下,每次调用 WebMethod,服务器都会创建一个新的 WebService 对象,即便客户端使用同一个代理对象多次调用 WebMethod。

而我们一旦调用了有缓存标记的 WebMethod,只要未超出缓存期,WebService 对象都不会被重新创建。在缓存期内调用没有缓存标记的 WebMethod,也会继续使用该 WebService 对象。有太多因素让这个缓存机制变得不那么可靠,因此我们不能奢望用缓存标记来维持特定的对象状态,况且缓存机制的设计初衷也只是为了快速输出那些比较稳定非常大的数据。

基于多用户并发调用这个环境,WebService 本身最好设计成无状态对象,我们可以使用 Session 和 Application 来保持特定的状态信息。

2. 异步调用

网上很多人在写有关 .net 2.0 的文章时,都喜欢用“优雅”这个词。的确,在 2.0 中编译器和代码生成器为我们封装了很多罗嗦的东西,诸如匿名方法、委托推断等等,当然还有这 WebService 的异步调用。我们不用再写那些个 BeginXXX、EndXXX 了,基于事件驱动的异步机制会自动为每个 WebMethod 生成一个 XXXAsync 的异步方法和 XXXCompleted 事件,我们只需调用该方法,并处理该事件即可完成异步操作,当真是优雅了不少。不要小看 2.0 的这些封装,我们编写的代码越少意味着出错的几率越小。

下面的示例中,我们使用了匿名方法来处理事件,看上去更简洁了些。

 

代码
WebServices.cs [WebService(Namespace = "http://www.rainsts.net/", Description="我的Web服务")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { [WebMethod] public string HelloWorld() { return "Hello World!"; } } Client.cs WebService ws = new WebService(); ws.HelloWorldCompleted += delegate(object sender, HelloWorldCompletedEventArgs e) { Console.WriteLine(e.Result); }; ws.HelloWorldAsync("xxx");
复制代码

 

 

3. 缓存

WebMethodAttribute.CacheDuration 为 WebService 提供了缓存申明机制。通过添加该标记,我们可以缓存输出结果。不过缓存机制会影响 WebService 的生存期(见上)。

代码
WebServices.cs [WebService(Namespace = "http://www.rainsts.net/", Description="我的Web服务")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { [WebMethod(CacheDuration=10)] public DateTime TestCache() { return DateTime.Now; } } Client.cs WebService ws = new WebService(); for (int i = 0; i < 20; i++) { Console.WriteLine("{0}:{1}", i + 1, ws.TestCache()); Thread.Sleep(1000); }
复制代码

 

 

 

 


4. 保持状态

.NET WebService 是建立在 ASP.NET 基础上,在 WebService 中我们同样可以访问 Session、User、Application 等上下文对象,不过在某些使用细节上可能有所不同。

由于 WebService 客户端代理对象可能应用于 ConsoleApplication、WinForm 或 WebForm 等环境,而 Session 又必须通过 Cookie 来保存唯一的 SessionID,因此我们必须使用 CookieContainer 创建 Cookie 容器来保存 WebService 返回的 Session 信息,否则每次调用的 SessionID 都不同,自然无法使用 Session 来保存状态了。

创建容器对象后,必须将其引用赋值给代理对象的 CookieContainer 属性。在第一次调用 SessionEnabled WebMethod 后,该容器将持有 Session Cookie 信息。如果需要在多个代理对象中调用 SessionEnabled WebMethod,那么它们必须持有同一个 Cookie 容器对象。

代码
WebServices.cs [WebService(Namespace = "http://www.rainsts.net/", Description="我的Web服务")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { [WebMethod(EnableSession = true)] public string TestSession() { string s = "TestSession"; object o = Session[s]; int i = o != null ? (int)o : 0; ++i; Session[s] = i; return Session.SessionID.ToString() + ":" + i; } } Client.cs WebService ws = new WebService(); // 创建Cookie容器,保持SessionID。否则每次调用的 SessionID 都不同。 CookieContainer cookies = new CookieContainer(); ws.CookieContainer = cookies; for (int i = 0; i < 10; i++) { Console.WriteLine("{0}:{1}", i + 1, ws.TestSession()); } //至于 Application 的使用和 WebForm 中基本没有什么区别。 WebServices.cs [WebService(Namespace = "http://www.rainsts.net/", Description="我的Web服务")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { [WebMethod] public DateTime TestApplicationState() { object o = Application["TestApplicationState"]; if (o == null) { o = DateTime.Now; Application["TestApplicationState"] = o; } return (DateTime)o; } } Client.cs for (int i = 0; i < 10; i++) { WebService ws = new WebService(); Console.WriteLine("{0}:{1}", i + 1, ws.TestApplicationState()); Thread.Sleep(1000); }
复制代码

 

 


5. SoapHeader(可作为简单的安全验证方法)

SoapHeader 多数情况下用来传递用户身份验证信息,当然它的作用远不止如此,有待于在实际应用中发掘。

SoapHeader 缺省情况下由客户端代理对象发送给 WebService,当然我们可以通过 WebMethodAttribute.Direction 来改变传送方向。

SoapHeader 使用步骤:

(1) 创建继承自 System.Web.WebServices.SoapHeader 的自定义 SoapHeader 类型。
(2) 在 WebService 中创建拥有 public 访问权限的自定义 SoapHeader 字段。
(3) 在需要使用 SoapHeader 的 WebMethod 上添加 SoapHeaderAttribute 访问特性。SoapHeaderAttribute 构造必须指定 memberName 参数,就是我们在第二步中申明的字段名称。
(4) 生成器会自动为客户端生成同名的自定义 SoapHeader 类型,只不过比起我们在 WebService 端创建的要复杂一些。同时还会为代理类型添加一个 soapheaderValue 属性。

在下面的演示代码,客户端将传递一个自定义 MyHeader 到 WebService。请注意,我们尽管在 WebService 中申明了 MyHeader 字段,但并没有创建对象实例,这是因为客户端传递过来的 XML 中包含了 SoapHeader 信息,基础结构会自动解析并创建对象实例,然后赋值给 my 字段。至于客户端,自然需要创建一个 MyHeader 对象实例,并赋值给 WebService.MyHeaderValue 属性。SoapHeaderAttribute.Direction 缺省就是 In,下面例子中的 "Direction = SoapHeaderDirection.In" 可以省略。

代码
WebServices.cs public class MyHeader : SoapHeader { public string Username; public string Password; } [WebService(Namespace = "http://www.rainsts.net/", Description="我的Web服务")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { public MyHeader my; [WebMethod] [SoapHeader("my", Direction = SoapHeaderDirection.In)] public void TestSoapHeadIn() { System.Diagnostics.Debug.Write(my.Username); System.Diagnostics.Debug.Write(my.Password); } } Client.cs WebService ws = new WebService(); MyHeader head = new MyHeader(); head.Username = "u2"; head.Password = "p2"; ws.MyHeadValue = head; ws.TestSoapHeadIn();
复制代码

 

 


我们改写一下,将传递方向改为从 WebService 到客户端。自然我们需要调整 "Direction = SoapHeaderDirection.Out",在 WebMethod 中我们还必须创建 MyHeader 实例,因为这次我们不会接受到客户端传递的 SoapHeader 了。客户端代理对象调用 WebMethod 后就可以使用 MyHeaderValue 属性访问其内容了。

代码
WebServices.cs public class MyHeader : SoapHeader { public string Username; public string Password; } [WebService(Namespace = "http://www.rainsts.net/", Description="我的Web服务")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { public MyHeader my; [WebMethod] [SoapHeader("my", Direction = SoapHeaderDirection.Out)] public void TestSoapHeadOut() { my = new MyHeader(); my.Username = "u1"; my.Password = "p1"; } } Client.cs WebService ws = new WebService(); ws.TestSoapHeadOut(); Console.WriteLine(ws.MyHeaderValue.Username); Console.WriteLine(ws.MyHeaderValue.Password); 6. 异常 ASP.NET WebService 通过 Fault XML 元素来传递异常信息,客户端代理对象会生成一个 SoapException 的异常,并使用 Fault XML 信息填充其相关属性,诸如 Message 等。另外我们可以对 WebService 进行异常包装,除了传递 Exception Message 外,还可以传递一些错误状态代码,以便客户端用户做进一步处理。 WebServices.cs [WebService(Namespace = "http://www.rainsts.net/", Description="我的Web服务")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class WebService : System.Web.Services.WebService { [WebMethod] public void TestException() { try { throw new Exception("aaa..."); } catch (Exception e) { throw new SoapException(e.Message, new System.Xml.XmlQualifiedName("ErrorCode01"), e); } } } Client.cs WebService ws = new WebService(); try { ws.TestException(); } catch (System.Web.Services.Protocols.SoapException e) { Console.WriteLine(e.Message); Console.WriteLine(e.Code.Name); }

图文并茂详细安装Vmware15.5虚拟机 今天的技术分享就到这里,感兴趣的小伙伴可以持续关注,我们下期再见!对于初次接触VMware的用户来说,安装过程可能会显得有些复杂。为了让更多的朋友能够顺利上手VMware15.5,本文将提供一个详细的图文并茂的安装教程。硬盘空间:至少需要1GB的硬盘空间用于安装程序,额外的空间用于虚拟机运行。图形处理器:支持硬件虚拟化的Intel或AMD处理器。内存:至少4GB,推荐8GB或更多。 阅读详情

相关推荐

VMwarePro 15.5安装教程

想

碎弧的星星的博客 4319

【Windows】【VMware】Win10 下安装并设置 VMware Workstation 15.5 Pro

安装并设置 VMware Workstation 15.5 Pro

RadiantJeral的博客 4704

Kimi K3大模型API实战:从调用到本地知识库问答系统构建

大语言模型(LLM)作为人工智能的核心技术,通过海量数据训练获得理解和生成自然语言的能力。其工作原理基于Transformer架构,通过自注意力机制捕捉长距离依赖关系。这项技术的核心价值在于能够将非结构化文本转化为可计算、可交互的智能体,极大地提升了信息处理和自动化任务的效率。在应用场景上,大模型广泛应用于智能对话、代码生成、文档总结与问答等领域。其中,国产大模型如月之暗面推出的Kimi K3,凭借其在**长文本处理**和**中文场景优化**方面的优势,为开发者提供了新的技术选项。本文将以Kimi K3为例

weixin_30694389的博客 299

【附安装包】VMware15.5安装教程

软件:VMware版本:15.5语言:简体中文大小:450.22M安装环境:Win11/Win10/Win8/Win7硬件要求:CPU@2.5GHz 内存@4G(或更高)下载通道①百度网盘丨下载链接:提取码:pcww。

weixin_68789096的博客 1万+

在 Kubernetes 上部署 Label Studio

Label Studio 是一款开源的数据标注工具,支持多种标注任务,如文本标注、图像标注、音频标注等。

啥都会一点 668

识别产品外观的合格软件_工业视觉工业质检视觉识别机器视觉视觉检测智能制造工业检测缺陷...

随着工业物联网技术的迅猛发展,掀起了以云计算、大数据、以及人工智能 AI 等信息技术正与传统工业深入融合,由此衍生的 “智能制造4.0” 理念,正在为全球工业带来深远变革。中国的制造业巨头也纷纷借此发力,向智能化、数字化制造演进,实施战略转型。如何高效科学的管理和分析制造业务链上的生产价值,推进制造企业生产工艺优化与产品质量提升是每一个制造企业在数字化、智能化转型过程中的必经之路。业务发展带来的挑...

weixin_42502419的博客 752

一个简单的WebService实现例子,SOAP安全验证

WebService是基于SOAP协议进行网络通讯的,但本文只介绍了一个WebService简单的使用例子,没有详细介绍关于SOAP协议的知识,有兴趣的朋友可以网站搜索下, 这方面的资料是非常多。 下面说说WebService的例子吧。 1、新建一个WebService项目,在项目下新建一个SoapHeader.cs类,这个类是用来做WebSerivce安全性验证,此类必须继承.ne

lhrhi的专栏 1万+

Python Trimesh库实战:5分钟搞定STL文件解析与3D模型可视化

本文介绍了如何使用Python的Trimesh库快速解析STL文件并进行3D模型可视化。通过简洁的代码示例,演示了从环境搭建、模型加载、几何数据提取到基础变换和批量处理的核心流程,帮助开发者和工程师在5分钟内高效完成3D数据处理与可视化任务。

weixin_32005771的博客 160

WebService 简单安全验证

WebService 简单安全验证 2011-03-04 10:34 by Vincent.Studio,8158阅读,0评论,收藏,编辑 最近新接了一个需要调用第三方WebService的项目,看到这个第三方WebService被调用的时候,需要授权用户名和密码,于是自己也想对WebService的安全授权这个方面进行了一下研究,以前调用的WebServi...

weixin_30663391的博客 118

1.2 重叠因子:双重指数移动平均(Double Exponential Moving Average, DEMA)概念与Python实战

双重指数移动平均(Double Exponential Moving Average, DEMA)是一种改进的移动平均线指标,由Patrick Mulloy在1994年开发。相比传统的指数移动平均线(EMA),DEMA通过减少滞后性来提供更快的市场反应。它通过两次计算EMA并进行特殊组合来实现这一目标,可以在保持平滑性的同时减少滞后。

Kewin的博客 2168

yolov5运行detect.py之后卡住了?没后续,没结果,没报错,怎么办?如何解决?

🏆 本文收录于《全栈Bug调优(实战版)》专栏,致力于分享我在项目实战过程中遇到的各类Bug及其原因,并提供切实有效的解决方案。无论你是初学者还是经验丰富的开发者,本文将为你指引出一条更高效的Bug修复之路,助你早日登顶,迈向财富自由的梦想🚀!同时,欢迎大家关注、收藏、订阅本专栏,更多精彩内容正在持续更新中。让我们一起进步,Up!Up!Up!    备注: 部分问题/难题源自互联网,经过精心筛选和整理,结合数位十多年大厂实战经验资深大佬经验总结所得,数条可行方案供所需之人参考。

**My Coding Family** 1105

WebService安全解决方案—简单握手协议

  WebService安全解决方案—简单握手协议1、具体方案如下图: 2、解决方案分析       A、SiteA每次向SiteB发送的请求参数都不一样,造成伪造者难以模仿和推敲里面的算法过程。B、伪造者获得了SayHelloRequest的数据,它向SiteB发送请求,但是里面加密的IP与伪造者IP不符合的情况下,系统会否定;即使伪造者伪造了IP,获得了Site

Ancky的专栏 2553

焊缝缺陷智能检测:基于 YOLO 的工业质检系统实战

从焊缝缺陷数据集的构建到模型训练,从桌面检测界面到缺陷统计输出,本文覆盖了一套工业焊缝质检系统的完整路线。这个场景的核心难点在数据层面——气孔和裂纹这类小目标的标注质量直接决定了模型的最终表现。建议先在开源数据集上跑通全链路,确认 mAP 达到可接受的水平后,再通过补充特定类型的小目标数据和提升输入分辨率来做精度优化。工业场景中,漏检一个气孔的成本和误报一个假阳性的成本不一样——根据对两类成本的承受力,调整置信度阈值来找到业务上的最佳平衡点。

m0_71589036的博客 202

【转载】WebService 简单安全验证

        最近新接了一个需要调用第三方WebService的项目,看到这个第三方WebService被调用的时候,需要授权用户名和密码,于是自己也想对WebService的安全授权这个方面进行了一下研究,以前调用的WebService大部分都是局域网内部调用,几乎没有什么权限需要增加的,今天借此机会,深入研究了一下,发现实现起来还是挺容易的。  ...

weixin_33810302的博客 107

visio安装包

Microsoft Office Visio 是一款专业的制图软件。利用经过更新的形状、协作工具和数据链接图表,创建专业级图表以简化复杂的信息。

深度学习工具包 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")

简单的WebService安全

1. 有关生存期的补充 正常情况下,每次调用 WebMethod,服务器都会创建一个新的 WebService 对象,即便客户端使用同一个代理对象多次调用 WebMethod。 而我们一旦调用了有缓存标记的 WebMethod,只要未超出缓存期,WebService 对象都不会被重新创建。在缓存期内调用没有缓存标记的 WebMethod,也会继续使用该 WebService 对象。有太多因素让...

weixin_34413065的博客 78

efm32 入门.pdf

本PDF共计22页,介绍的是操作驱动API,下载与否自己斟酌。

简单的web WebService安全

1. 有关生存期的补充正常情况下,每次调用 WebMethod,服务器都会创建一个新的 WebService 对象,即便客户端使用同一个代理对象多次调用 WebMethod。而我们一旦调用了有缓存标记的 WebMethod,只要未超出缓存期,WebService 对象都不会被重新创建。在缓存期内调用没有缓存标记的 WebMethod,也会继续使用该 WebService 对象。有太多因素让这个缓存...

weixin_33770878的博客 84
上一篇: Android的 getSystemService
下一篇: WebService系列:为WebService添加安全性
shareCode
博客等级 码龄15年 125粉丝 40原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值