注:web服务简介Webservices-1.web服务定义简介

以下均以C#语言为例

一、创建web服务(简单介绍,主要讨论客户端引用)

  打开VS创建网站项目,在网站项目中添加“WEB服务(ASMX)”,

  此时VS便已经默认建立好一个web服务。

  如需使用Session,请添加“[WebMethod(EnableSession=true)] ”,更多信息请实际编写代码时候查看智能提示,及msdn文档

  此时可以将服务部署于web服务器上,以IIS为例,部署完毕即可正确访问。有时创建IIS网站时,请注意配置使用的.net版本库。

  访问地址:http://172.168.0.40:8086/WebSer.asmx(个人PC示例,请勿随意copy)

二、服务解析概述

  在访问地址后添加?WSDL既可以查看服务说明文档http://172.168.0.40:8086/WebSer.asmx?WSDL

  

 <?xml version="1.0" encoding="utf-8"?>
<wsdl:definitions xmlns:tm="http://microsoft.com/wsdl/mime/textMatching/" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:mime="http://schemas.xmlsoap.org/wsdl/mime/" xmlns:tns="ChineShine" xmlns:soap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:s="http://www.w3.org/2001/XMLSchema" xmlns:soap12="http://schemas.xmlsoap.org/wsdl/soap12/" xmlns:http="http://schemas.xmlsoap.org/wsdl/http/" targetNamespace="ChineShine" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/">
<wsdl:types>
<s:schema elementFormDefault="qualified" targetNamespace="ChineShine">
<s:element name="HelloWorld">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ss" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="HelloWorldResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="HelloWorldResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="NoReturnValue">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="ss" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
<s:element name="NoReturnValueResponse">
<s:complexType />
</s:element>
<s:element name="NoParaValue">
<s:complexType />
</s:element>
<s:element name="NoParaValueResponse">
<s:complexType>
<s:sequence>
<s:element minOccurs="0" maxOccurs="1" name="NoParaValueResult" type="s:string" />
</s:sequence>
</s:complexType>
</s:element>
</s:schema>
</wsdl:types>
<wsdl:message name="HelloWorldSoapIn">
<wsdl:part name="parameters" element="tns:HelloWorld" />
</wsdl:message>
<wsdl:message name="HelloWorldSoapOut">
<wsdl:part name="parameters" element="tns:HelloWorldResponse" />
</wsdl:message>
<wsdl:message name="NoReturnValueSoapIn">
<wsdl:part name="parameters" element="tns:NoReturnValue" />
</wsdl:message>
<wsdl:message name="NoReturnValueSoapOut">
<wsdl:part name="parameters" element="tns:NoReturnValueResponse" />
</wsdl:message>
<wsdl:message name="NoParaValueSoapIn">
<wsdl:part name="parameters" element="tns:NoParaValue" />
</wsdl:message>
<wsdl:message name="NoParaValueSoapOut">
<wsdl:part name="parameters" element="tns:NoParaValueResponse" />
</wsdl:message>
<wsdl:portType name="WebSerSoap">
<wsdl:operation name="HelloWorld">
<wsdl:input message="tns:HelloWorldSoapIn" />
<wsdl:output message="tns:HelloWorldSoapOut" />
</wsdl:operation>
<wsdl:operation name="NoReturnValue">
<wsdl:input message="tns:NoReturnValueSoapIn" />
<wsdl:output message="tns:NoReturnValueSoapOut" />
</wsdl:operation>
<wsdl:operation name="NoParaValue">
<wsdl:input message="tns:NoParaValueSoapIn" />
<wsdl:output message="tns:NoParaValueSoapOut" />
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="WebSerSoap" type="tns:WebSerSoap">
<soap:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="HelloWorld">
<soap:operation soapAction="ChineShine/HelloWorld" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="NoReturnValue">
<soap:operation soapAction="ChineShine/NoReturnValue" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="NoParaValue">
<soap:operation soapAction="ChineShine/NoParaValue" style="document" />
<wsdl:input>
<soap:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:binding name="WebSerSoap12" type="tns:WebSerSoap">
<soap12:binding transport="http://schemas.xmlsoap.org/soap/http" />
<wsdl:operation name="HelloWorld">
<soap12:operation soapAction="ChineShine/HelloWorld" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="NoReturnValue">
<soap12:operation soapAction="ChineShine/NoReturnValue" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="NoParaValue">
<soap12:operation soapAction="ChineShine/NoParaValue" style="document" />
<wsdl:input>
<soap12:body use="literal" />
</wsdl:input>
<wsdl:output>
<soap12:body use="literal" />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="WebSer">
<wsdl:port name="WebSerSoap" binding="tns:WebSerSoap">
<soap:address location="http://172.168.0.40:8086/WebSer.asmx" />
</wsdl:port>
<wsdl:port name="WebSerSoap12" binding="tns:WebSerSoap12">
<soap12:address location="http://172.168.0.40:8086/WebSer.asmx" />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

  

折叠后查看

  

  注意:WSDL元素[1]基于XML语法描述了与服务进行交互的基本元素:

    Type(消息类型):数据类型定义的容器,它使用某种类型系统(如XSD)。
    Message(消息):通信数据的抽象类型化定义,它由一个或者多个part组成。
    Part:消息参数
    Operation(操作):对服务所支持的操作进行抽象描述,WSDL定义了四种操作: 1.单向(one-way):端点接受信息;2.请求-响应(request-response):端点接受消息,然后发送相关消息;3.要求-响应(solicit-response):端点发送消息,然后接受相关消息;4.通知(notification[2]):端点发送消息。
    Port Type (端口类型):特定端口类型的具体协议和数据格式规范。
    Binding:特定端口类型的具体协议和数据格式规范
    Port:定义为绑定和网络地址组合的单个端点。
    Service:相关端口的集合,包括其关联的接口、操作、消息等。

  2.1 targerNamespasce

    主要声明的是:本服务使用的命名空间 ,默认是:http://tempuri.org/
(打开一看,跑到bing去了,呵呵),可以自定义使用,如本文定义了:ChineShine

  2.2 wsdl:types

    主要是:服务接口里面的:方法名称,参数,返回值介绍

  2.3 wsdl:Message、wsdl:portType (参看以上注意)

  2.4 wsdl:Binding

    可以使用的协议访问,如示例中提示使用的soap(即soap1.1),soap12(即soap1.2)

  2.5 wsdl:service

    主要是:各种方式服务的接口地址

  综述:其实在调用别人web服务的时候,只要有web服务地址,即可能够使用,对方的服务,要详细正确使用还需服务开发者,提供详细调用文档。

三、客户端服务引用(这里才是重点啊)

  客户端引用主要包含:项目中引用服务地址,普通引用(主要指VS中的“添加服务引用”)

名称   使用场景 优缺点
普通引用   项目建立初期 初期建立,方便快捷,易于使用
 使用代理类    完善的项目,使用中的项目,

需求变更的项目,当然初期的也可以

 需要自己手工编写代码,

对于成熟使用的项目扩展性好

代码引用 post

完善的项目,使用中的项目,

需求变更的项目,当然初期的也可以

需要自己手工编写代码,

对于成熟使用的项目扩展性好

get
soap1.1
soap1.2

  3.1 普通引用

    在需要引用的VS项目中,引用→添加服务引用→添加服务地址“http://172.168.0.40:8086/WebSer.asmx”,

    编写基本代码即可使用

    TestServiceReference.WebSerSoapClient wc = new TestServiceReference.WebSerSoapClient();//初始化web服务客户端对象
            string ss=wc.HelloWorld("你好");//调用web服务的,接口方法  

    说明:这种方法适用于VS操作,其他语言及IDE未测试。优点方便快捷,简单易于使用。

  3.2 代码引用

    这里以soap1.1 为例,post,get比较简单,soap1.2 与soap1.1类似,讲述soap1.1后会添加全部代码

    

    打开其中一个接口,参看

  

  

  

  注:前提条件,根据接口的wsdl,以及开发商提供的文档可以查看到:接口的地址(URL)、方法名(Method)、参数列表(Paras)、命名空间等信息(tns)

  编写请求代码:

    //创建一个HttpWebRequest
    HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);
    request.Method = "POST";//请求方式
    request.ContentType = "text/xml; charset=utf-8";//网络文件的类型和网页的编码
    request.Headers.Add("SOAPAction", "\"" + XmlNs + (XmlNs.EndsWith("/") ? "" : "/") + MethodName + "\"");//构建soap1.1 请求头文件
    request.Credentials = CredentialCache.DefaultCredentials;//获取系统凭据
    request.Timeout = 10000;//请求超时时间
    byte[] data = EncodeParsToSoap(Pars, XmlNs, MethodName, soapVersion);//组织发送内容,并序列化成字节流,详细参看附注代码,
    request.ContentLength = data.Length;//请求数据长度
            using (Stream writer = request.GetRequestStream())//请求参数
            {
                writer.Write(data, 0, data.Length);
                writer.Close();
            }
    XmlDocument doc = new XmlDocument(), doc2 = new XmlDocument();
    doc = ReadXmlResponse(request.GetResponse());//接收返回消息  request.GetResponse() 附注代码已修改成使用异步编程方式
    这是一次请求,就完成了。详细处理,请参看详细代码

  附注:详细代码(复制到程序中,直接就可以使用哦!)

 using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Net;
using System.Text;
using System.Web;
using System.Xml;
using System.Xml.Serialization; namespace TestWS
{
public class WebServicesCodeTool
{
private System.Collections.Hashtable _xmlNamespaces = new System.Collections.Hashtable();//缓存xmlNamespace,避免重复调用GetNamespace /// <summary>
/// 需要WebService支持Post调用
/// </summary>
public System.Xml.XmlDocument QueryPostWebService(String URL, String MethodName, System.Collections.Hashtable Pars)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL + "/" + MethodName);
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
SetWebRequest(request);
byte[] data = EncodePars(Pars);
WriteRequestData(request, data);
return ReadXmlResponse(request.GetResponse());//这里没有修改成异步方式,建议自行修改
} /// <summary>
/// 需要WebService支持Get调用
/// </summary>
public XmlDocument QueryGetWebService(String URL, String MethodName, Hashtable Pars)
{
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL + "/" + MethodName + "?" + ParsToString(Pars));
request.Method = "GET";
request.ContentType = "application/x-www-form-urlencoded";
SetWebRequest(request);
return ReadXmlResponse(request.GetResponse());
}
/// <summary>
/// 通用WebService调用(Soap),参数Pars为String类型的参数名、参数值、soap版本(如果支持1.2,使用1.2,默认填写1.1)
/// </summary>
/// <param name="URL"></param>
/// <param name="MethodName"></param>
/// <param name="Pars"></param>
/// <param name="soapVersion"></param>
/// <returns></returns>
public XmlDocument QuerySoapWebService(String URL, String MethodName, Hashtable Pars, string soapVersion)
{
if (_xmlNamespaces.ContainsKey(URL))
{
return QuerySoapWebService(URL, MethodName, Pars, _xmlNamespaces[URL].ToString(), soapVersion);
}
else
{
return QuerySoapWebService(URL, MethodName, Pars, GetNamespace(URL), soapVersion);
}
}
XmlDocument doc = null;
private XmlDocument QuerySoapWebService(String URL, String MethodName, Hashtable Pars, string XmlNs, string soapVersion)
{
_xmlNamespaces[URL] = XmlNs;//加入缓存,提高效率
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL);
request.Method = "POST"; if (soapVersion == "1.2")
{
request.ContentType = "application/soap+xml;charset=utf-8";
}
else
{
request.ContentType = "text/xml; charset=utf-8";
request.Headers.Add("SOAPAction", "\"" + XmlNs + (XmlNs.EndsWith("/") ? "" : "/") + MethodName + "\"");
}
SetWebRequest(request);
byte[] data = EncodeParsToSoap(Pars, XmlNs, MethodName, soapVersion);
WriteRequestData(request, data); XmlDocument doc2 = new XmlDocument();
IAsyncResult ar = request.BeginGetResponse(AsyncCallbackGetResponse, request);//异步方式
//XmlDocument doc = new XmlDocument();
//doc = ReadXmlResponse(request.GetResponse());//原来同步方式
if (ar.IsCompleted && doc != null)
{
XmlNamespaceManager mgr = new XmlNamespaceManager(doc.NameTable);
String RetXml = "";
if (soapVersion == "1.2")
{
mgr.AddNamespace("soap12", "http://www.w3.org/2003/05/soap-envelope");
RetXml = doc.SelectSingleNode("//soap12:Body/*/*", mgr).InnerXml;
}
else
{
mgr.AddNamespace("soap", "http://schemas.xmlsoap.org/soap/envelope/");
RetXml = doc.SelectSingleNode("//soap:Body/*/*", mgr).InnerXml;
}
doc2.LoadXml("<root>" + RetXml + "</root>");
AddDelaration(doc2); }
return doc2;
} private void AsyncCallbackGetResponse(IAsyncResult ar)
{
WebRequest request = ar.AsyncState as WebRequest;
var response = request.EndGetResponse(ar);
Stream stream = response.GetResponseStream();
using (StreamReader reader = new StreamReader(stream))
{
string content = reader.ReadToEnd();
if (!string.IsNullOrEmpty(content))
{
doc = new XmlDocument();
doc.LoadXml(content);
}
}
} /// <summary>
/// 第一次执行获取要访问的命名空间
/// </summary>
/// <param name="URL"></param>
/// <returns></returns>
private string GetNamespace(String URL)
{
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(URL + "?WSDL");
SetWebRequest(request);
WebResponse response = request.GetResponse();
XmlDocument doc = null;
using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
doc = new XmlDocument();
doc.LoadXml(sr.ReadToEnd());
sr.Close();
}
return doc != null ? doc.SelectSingleNode("//@targetNamespace").Value : "http://tempuri.org/";
} private byte[] EncodeParsToSoap(Hashtable Pars, String XmlNs, String MethodName, string soapVersion)
{
XmlDocument doc = new XmlDocument();
XmlElement soapBody = null;
if (soapVersion == "1.2")
{
doc.LoadXml("<soap12:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap12=\"http://www.w3.org/2003/05/soap-envelope\"></soap12:Envelope>");
AddDelaration(doc);
soapBody = doc.CreateElement("soap12", "Body", "http://www.w3.org/2003/05/soap-envelope");
}
else
{
doc.LoadXml("<soap:Envelope xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xmlns:xsd=\"http://www.w3.org/2001/XMLSchema\" xmlns:soap=\"http://schemas.xmlsoap.org/soap/envelope/\"></soap:Envelope>");
AddDelaration(doc);
soapBody = doc.CreateElement("soap", "Body", "http://schemas.xmlsoap.org/soap/envelope/");
}
XmlElement soapMethod = doc.CreateElement(MethodName);
soapMethod.SetAttribute("xmlns", XmlNs);
foreach (string k in Pars.Keys)
{
XmlElement soapPar = doc.CreateElement(k);
soapPar.InnerXml = ObjectToSoapXml(Pars[k]);
soapMethod.AppendChild(soapPar);
}
soapBody.AppendChild(soapMethod);
doc.DocumentElement.AppendChild(soapBody);
return Encoding.UTF8.GetBytes(doc.OuterXml);
} private string ObjectToSoapXml(object o)
{
XmlSerializer mySerializer = new XmlSerializer(o.GetType());
MemoryStream ms = new MemoryStream();
mySerializer.Serialize(ms, o);
XmlDocument doc = new XmlDocument();
doc.LoadXml(Encoding.UTF8.GetString(ms.ToArray()));
if (doc.DocumentElement != null)
{
return doc.DocumentElement.InnerXml;
}
else
{
return o.ToString();
}
} private void SetWebRequest(HttpWebRequest request)
{
request.Credentials = CredentialCache.DefaultCredentials;
request.Timeout = ;
} private void WriteRequestData(HttpWebRequest request, byte[] data)
{
request.ContentLength = data.Length;
using (Stream writer = request.GetRequestStream())
{
writer.Write(data, , data.Length);
writer.Close();
}
} private byte[] EncodePars(Hashtable Pars)
{
return Encoding.UTF8.GetBytes(ParsToString(Pars));
} private String ParsToString(Hashtable Pars)
{
StringBuilder sb = new StringBuilder();
foreach (string k in Pars.Keys)
{
if (sb.Length > )
{
sb.Append("&");
}
sb.Append(HttpUtility.UrlEncode(k) + "=" + HttpUtility.UrlEncode(Pars[k].ToString()));
}
return sb.ToString();
} private XmlDocument ReadXmlResponse(WebResponse response)
{
String retXml = "";
using (StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8))
{
retXml = sr.ReadToEnd();
sr.Close();
}
XmlDocument doc = new XmlDocument();
if (!string.IsNullOrEmpty(retXml)) { doc.LoadXml(retXml); }
return doc;
} private void AddDelaration(XmlDocument doc)
{
XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "utf-8", null);
doc.InsertBefore(decl, doc.DocumentElement);
} }
}

  项目中的调用:

    WebServicesTool ws = new WebServicesTool();
    Hashtable paras = new Hashtable();
           paras.Add("ss", "你好");
           XmlDocument docPost = ws.QueryPostWebService("http://172.168.0.40:8086/WebSer.asmx", "HelloWorld", paras);
           XmlDocument docSoap = ws.QuerySoapWebService("http://172.168.0.40:8086/WebSer.asmx", "HelloWorld", paras, "1.2");
           context.Response.Write(docPost.OuterXml);
           context.Response.Write(docSoap.OuterXml);

  3.3 使用wsdl代理类

    ①、查看webservice服务,访问Service Document,即这里的wsdl文件,

    ②、将查看的wsdl文件保存。

    ③、本机使用VS自带的“VS2013 开发人员命令提示”。点击打开

    ④、wsdl  文件路径,即可生成代理类,调用代理类即可访问不同程序编写的webservice服务

四、心得

  4.1 使用代码方式,使得成熟稳定的项目,易于扩展。

  4.2 不论何种语言,只要读懂wsdl及接口开发商提供文档即可,调用web接口。

  4.3 一些关于soap1.2 的简介http://blog.csdn.net/xiaojianpitt/article/details/5258254

    更多的soap介绍,可以查看:http://www.ibm.com/developerworks/cn/xml/x-sisoap/
    

Webservices-2.C#创建web服务,及引用访问、代码访问的更多相关文章

  1. 手把手教你在.NET中创建Web服务

    最近发现在.NET平台下使用Web服务还是很简单的.下面举个在.NET平台下创建Web服务的简单例子.首先用Visul Studio .Net创建一个C# 项目Asp.Net Web服务程序,源代码如 ...

  2. 基于Socket创建Web服务

    基于Socket创建Web服务 为什么要使用Socket呢,我们来看下图

  3. ASP.NET---如何使用web api创建web服务

    1 首先创建asp.net web空项目,并且创建模拟数据,我在工程下面创建了一个Models文件夹,在文件夹Nodels下面创建类Product和Repository 具体如下: [Serializ ...

  4. http-server让你在任何目录下都可以创建web服务

    在做前端页面开发,或者预览时,如果借助于Apache.Tomcat.nginx等预览页面,每次需要将所需预览的页面移动到对应的文件夹下,且还需要考虑是否删除相关目录原有的文件,显然比较麻烦. 那么有没 ...

  5. Web Service 实例基于Socket创建Web服务

    ServerSocket服务器端代码如下: public static void main(String[] args) throws IOException { // 1:建立服务器端的tcp so ...

  6. 使用BPEL创建Web服务组合

    http://www.cnblogs.com/ahhuiyang/archive/2012/12/18/2824131.html 为简单起见,本例的Web服务组合只调用一个Web Service AP ...

  7. asyncio创建协程解析——分析廖雪峰的Python教程之创建WEB服务(转)

    第一步,搭建开发环境 所需第三方库: aiohttp,异步 Web 开发框架:jinja2,前端模板引擎:aiomysql,异步 mysql 数据库驱动 所需内置库: logging,系统日志:asy ...

  8. 使用记事本创建Web服务(WebService)

    学习就要从最简单最直观的地方入手. 1)打开记事本,添加如下代码: <%@ WebService Language="C#" Class="myFirstWebSe ...

  9. Golang: 创建Web服务

    使用 Go 语言,我们可以轻松创建出 Web 服务,这一点比 Node.js 还要简单,今天就来总结一下 Go 语言中 Web 服务的创建方式. 首先,我们需要引入 net/http 这个包来处理 H ...

随机推荐

  1. winform DataGridView 导出到Excel表格 分类: WinForm 2014-07-04 10:48 177人阅读 评论(0) 收藏

    public bool ExportDataGridview(DataGridView gridView)         {             if (gridView.Rows.Count ...

  2. 朴素贝叶斯(naive bayes)算法及实现

    处女文献给我最喜欢的算法了 ⊙▽⊙ ---------------------------------------------------我是机智的分割线----------------------- ...

  3. 构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(20)-权限管理系统-根据权限获取菜单

    原文:构建ASP.NET MVC4+EF5+EasyUI+Unity2.x注入的后台管理系统(20)-权限管理系统-根据权限获取菜单 不知不觉到20讲,真是漫长的日子,可惜最近工作挺忙,要不可以有更多 ...

  4. nandflash中oob、ecc分析

    1.为何需要分析? 最近一直接触这类驱动,如果对它的原理不懂的话,驱动调试会很麻烦!!!!!! 2.ecc? nand的纠错能力,目前有1位.4位和8位,也就是说在512字节中如果是4位的ecc那就可 ...

  5. LeetCode201 Bitwise AND of Numbers Range Java 题解

    题目: Given a range [m, n] where 0 <= m <= n <= 2147483647, return the bitwise AND of all num ...

  6. 开启MYSQL远程连接权限

      开启MYSQL远程连接权限   1 2 3 4 5 //建议设置固定IP mysql> GRANT ALL PRIVILEGES ON *.* TO root@"8.8.8.8&q ...

  7. QT QObject::connect函数的学习

      从Qobject(QObject.h)源码中可以看到QObject::connect的定义是这样的: static bool connect(const QObject *sender, cons ...

  8. curl post参数,接口接收不到数据问题

    今天遇到一个问题,注册下发短信失败,总提示无法发送注册短信,请从新发送. 经检查,curl里面将post数据以json_encode的方法转码之后传递,而且各选项设置感觉没有问题,怎么接口就接收不到p ...

  9. 观察者模式在ng(Angular)中的应用

    在这个前端框架满天飞的天下,angular MVVM 的模式确实火了一把,所以最近一直在学习ng,感悟颇多,填坑无数,今天终静下心来打算更新自己久未变动的博客,做一做总结. 1.在ng中的观察者模式: ...

  10. Java设计模式01:设计模式的 分类 和 设计原则

    一.总体来说设计模式分为三大类: 创建型模式:对象的创建. 创建对象本身是比较耗时的操作,所以我们这里专门找人来帮我们创建对象,我们根据经验总结出来的设计成熟的思路模式. 结构型模式:对象的组成(结构 ...