设当前页完整地址是:http://www.jb51.net/aaa/bbb.aspx?id=5&name=kelli "http://"是协议名 "www.jb51.net"是域名 "aaa"是站点名 "bbb.aspx"是页面名(文件名) "id=5&name=kelli"是参数 【1】获取 完整url (协议名+域名+站点名+文件名+参数) 复制代码代码如下: string url=Request.Url.ToString(); url= http://www.jb51.net/aaa/bbb.aspx?id=5&name=kelli 【2】获取 站点名+页面名+参数: 复制代码代码如下: string url=Request.RawUrl; (或 string url=Request.Url.PathAndQuery;) url= /aaa/bbb.aspx?id=5&name=kelli 【3】获取 站点名+页面名: 复制代码代码如下: string url=HttpContext.Current.Request.Url.AbsolutePath; (或 string url= HttpContext.Current.Request.Path;) url= aaa/bbb.aspx 【4】获取 域名: 复制代码代码如下: string url=HttpContext.Current.Request.Url.Host; url= www.jb51.net 【5】获取 参数: 复制代码代码如下: string url= HttpContext.Current.Request.Url.Query; url= ?id=5&name=kelli 复制代码代码如下: Request.RawUrl:获取客户端请求的URL信息(不包括主机和端口)——>/Default2.aspx Request.ApplicationPath:获取服务器上ASP.NET应用程序的虚拟路径。——>/ Request.CurrentExecutionFilePath:获取当前请求的虚拟路径。——>/Default2.aspx Request.Path:获取当前请求的虚拟路径。——>/Default2.aspx Request.PathInfo:取具有URL扩展名的资源的附加路径信息——> Request.PhysicalPath:获取与请求的URL相对应的物理文件系统路径。——>E:\temp\Default2.aspx Request.Url.LocalPath:——>/Default2.aspx Request.Url.AbsoluteUri:——>http://localhost:8080/Default2.aspx Request.Url.AbsolutePath:—————————->/Default2.aspx 转自:脚本无忧
View Details1、Byte[] ===== 1. BitConverter 将基础数据类型与字节数组相互转换。注意string不是基础类型,而且该方法在不同平台间传递可能有误。 int i = 13; byte[] bs = BitConverter.GetBytes(i); Console.WriteLine(BitConverter.ToInt32(bs, 0)); 2. Encoding 注意慎用Encoding.Default,其值取自操作系统当前的设置,因此在不同语言版本的操作系统是不相同的。建议使用UTF8或者GetEncoding(”gb2312″)。 string s = "abc"; byte[] bs = Encoding.UTF8.GetBytes(s); Console.WriteLine(Encoding.UTF8.GetString(bs)); 3. BinaryFormatter 以二进制格式将对象或整个连接对象图形序列化和反序列化。 using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; [Serializable] class Data { private int x = 13; public void Test() { Console.WriteLine(x); } } static void Main(string[] args) { Data data = new Data(); MemoryStream stream = new MemoryStream(); BinaryFormatter formatter = new BinaryFormatter(); formatter.Serialize(stream, data); byte[] bs = stream.ToArray(); MemoryStream stream2 = new MemoryStream(bs); Data data2 = (Data)formatter.Deserialize(stream2); data2.Test(); } […]
View DetailsWeb.Config
1 |
<globalization responseEncoding="gb2312"/> |
CS文件
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Net; using System.Text; using System.IO; using System.Xml; using System.Collections; using System.Diagnostics; namespace WebPortal { public partial class _Default : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { CoreProxy.Class1 c = new CoreProxy.Class1(); c.test1(); } protected void Button2_Click(object sender, EventArgs e) { webquerst1(); } public void webquers2() { string html = null; string url = "http://china.alibaba.com/keyword/promotion.htm?catId=14"; WebRequest req = WebRequest.Create(url); req.Method = "POST"; WebResponse res = req.GetResponse(); Stream receiveStream = res.GetResponseStream(); Encoding encode = Encoding.GetEncoding("gb2312"); StreamReader sr = new StreamReader(receiveStream, encode); char[] readbuffer = new char[256]; int n = sr.Read(readbuffer, 0, 256); while (n > 0) { string str = new string(readbuffer, 0, n); html += str; n = sr.Read(readbuffer, 0, 256); } System.Console.Write(html); } //成功!,利用WebRequest 一次Post提交XML内容 public void webquerst1() { WebRequest request = WebRequest.Create("http://192.168.1.244/WebPortal/PortalHandler.ashx"); // Set the Method property of the request to POST. request.Method = "POST"; // Create POST data and convert it to a byte array. System.Xml.XmlDocument xmlpostdata = new System.Xml.XmlDocument(); xmlpostdata.Load(Server.MapPath("XML/20097.xml")); string postData = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); //普通字符串内容 //string postData = "你好,1232355 abdcde"; byte[] byteArray = Encoding.UTF8.GetBytes(postData); // Set the ContentType property of the WebRequest. request.ContentType = "application/x-www-form-urlencoded"; // Set the ContentLength property of the WebRequest. request.ContentLength = byteArray.Length; // Get the request stream. Stream dataStream = request.GetRequestStream(); // Write the data to the request stream. dataStream.Write(byteArray, 0, byteArray.Length); // Close the Stream object. dataStream.Close(); // Get the response. WebResponse response = request.GetResponse(); // Display the status. //Console.WriteLine(((HttpWebResponse)response).StatusDescription); // Get the stream containing content returned by the server. dataStream = response.GetResponseStream(); // Open the stream using a StreamReader for easy access. StreamReader reader = new StreamReader(dataStream); // Read the content. string responseFromServer = reader.ReadToEnd(); // Display the content. //Console.WriteLine(responseFromServer); // Clean up the streams. reader.Close(); dataStream.Close(); response.Close(); } protected void Button3_Click(object sender, EventArgs e) { WebClientPost(); } //重点!! 成功 利用Webclient Post 按字段的方式提交每个字段的内容给服务器端 public void WebClientPost() { System.Xml.XmlDocument xmlpostdata = new System.Xml.XmlDocument(); xmlpostdata.Load(Server.MapPath("XML/OrderClient.xml")); string OrderClient = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); xmlpostdata.Load(Server.MapPath("XML/Order.xml")); string Order = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); xmlpostdata.Load(Server.MapPath("XML/TargetOut.xml")); string TargetOut = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); xmlpostdata.Load(Server.MapPath("XML/ArrayOfOrderDetail.xml")); string ArrayOfOrderDetail = HttpUtility.HtmlEncode(xmlpostdata.InnerXml); System.Net.WebClient WebClientObj = new System.Net.WebClient(); System.Collections.Specialized.NameValueCollection PostVars = new System.Collections.Specialized.NameValueCollection(); //添加值域 PostVars.Add("OrderClient", OrderClient); PostVars.Add("Order", Order); PostVars.Add("TargetOut", TargetOut); PostVars.Add("ArrayOfOrderDetail", ArrayOfOrderDetail); try { byte[] byRemoteInfo = WebClientObj.UploadValues("http://192.168.1.244/WebPortal/PlaceOrder.ashx", "POST", PostVars); //下面都没用啦,就上面一句话就可以了 string sRemoteInfo = System.Text.Encoding.Default.GetString(byRemoteInfo); //这是获取返回信息 Debug.WriteLine(sRemoteInfo); } catch { } } //未测试,使用WebClient 一次性提交POst public static string SendPostRequest(string url, string postString) { byte[] postData = Encoding.UTF8.GetBytes(postString); WebClient client = new WebClient(); client.Headers.Add("Content-Type", "application/x-www-form-urlencoded"); client.Headers.Add("ContentLength", postData.Length.ToString()); byte[] responseData = client.UploadData(url, "POST", postData); return Encoding.Default.GetString(responseData); } /// <summary> /// 这个是用WEbRequest 提交到WEbService 的例子 /// </summary> /// <param name="URL"></param> /// <param name="MethodName"></param> /// <param name="Pars"></param> /// <returns></returns> public static XmlDocument QueryPostWebService(String URL, String MethodName, Hashtable Pars) { HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(URL); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; SetWebRequest(request); byte[] data = EncodePars(Pars); WriteRequestData(request, data); return ReadXmlResponse(request.GetResponse()); } private static void SetWebRequest(HttpWebRequest request) { request.Credentials = CredentialCache.DefaultCredentials; request.Timeout = 10000; } private static void WriteRequestData(HttpWebRequest request, byte[] data) { request.ContentLength = data.Length; Stream writer = request.GetRequestStream(); writer.Write(data, 0, data.Length); writer.Close(); } private static byte[] EncodePars(Hashtable Pars) { return Encoding.UTF8.GetBytes(ParsToString(Pars)); } private static String ParsToString(Hashtable Pars) { StringBuilder sb = new StringBuilder(); foreach (string k in Pars.Keys) { if (sb.Length > 0) { sb.Append("&"); } sb.Append(HttpUtility.UrlEncode(k) + "=" + HttpUtility.UrlEncode(Pars[k].ToString())); } return sb.ToString(); } private static XmlDocument ReadXmlResponse(WebResponse response) { StreamReader sr = new StreamReader(response.GetResponseStream(), Encoding.UTF8); String retXml = sr.ReadToEnd(); sr.Close(); XmlDocument doc = new XmlDocument(); doc.LoadXml(retXml); return doc; } private static void AddDelaration(XmlDocument doc) { XmlDeclaration decl = doc.CreateXmlDeclaration("1.0", "utf-8", null); doc.InsertBefore(decl, doc.DocumentElement); } protected void Button4_Click(object sender, EventArgs e) { } } } |
ashx
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 |
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.Services; using System.Diagnostics; using System.IO; using System.Xml; namespace WebPortal { /// <summary> /// $codebehindclassname$ 的摘要说明 /// </summary> [WebService(Namespace = "http://tempuri.org/")] [WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)] public class PortalHandler : IHttpHandler { public void ProcessRequest(HttpContext context) { string testGet = context.Request["testGet"]; string testPost = context.Request["testPost"]; Debug.WriteLine(testGet); Debug.WriteLine(testPost); //一次性提交的方式 //获得内容长度 int len = context.Request.ContentLength; //获得所有内容流 StreamReader reader = new StreamReader(context.Request.InputStream); //读取内容 string responseFromServer = reader.ReadToEnd(); //字段提交Post方式 string a1 = context.Request["A1"]; string a2 = context.Request["A2"]; string a3 = context.Request["A3"]; //解析Html编码 string re = HttpUtility.HtmlDecode(a1); XmlDocument xd = new XmlDocument(); //加载XML xd.LoadXml(re); context.Response.ContentType = "text/plain"; context.Response.Write(testGet); } public bool IsReusable { get { return false; } } } } |
转自:http://www.cnblogs.com/goody9807/archive/2011/10/08/2202265.html
View Detailsusing System; using System.IO; using System.Net; using System.Text; using System.Web; namespace HP.Common { /// <summary> /// 信息 /// </summary> public class InfoCollect { /// <summary> /// 获取内网页面内容 /// </summary> /// <param name="url"></param> /// <returns></returns> public static string GetPageByInner(string url) { return GetPage("http://" + HttpContext.Current.Request.ServerVariables["SERVER_NAME"] + (HttpContext.Current.Request.ServerVariables["SERVER_PORT"] == "80" ? "" : ":" + HttpContext.Current.Request.ServerVariables["SERVER_PORT"]) + url); } /// <summary> /// 获取公网url内容(GET) /// </summary> /// <param name="url"></param> /// <returns></returns> public static string GetPage(string url) { return GetPage(url, "GET", null); } /// <summary> /// 获取公网url内容(Post方法) /// </summary> /// <param name="url"></param> […]
View Details任何程序都离不开对异常的处理,良好的异常处理方式可加快寻找出异常的根源,同时也需要避免暴露敏感信息到异常中。WCF这种典型的服务端和客户端交互的程序,服务端的异常更需要适当的处理。下面以一个简单的服务为例,说明WCF中处理异常的方式。 WCF服务定义如下,很明显方法Divide在divisor为0的时候将会抛出异常 View Code 客户端调用如下: using (var client = new CalculateServiceClient()) { try { Console.WriteLine(client.Divide(20, 0)); } catch (FaultException ex) { Console.WriteLine(ex.Reason); } } 首先需要知道的是,WCF的异常信息默认是以FaultException的形式返回到客户端,FaultException的关键属性Reason是对客户端反馈的最重要信息之一。以上客户端代码调用之后,默认的FaultException返回的Message信息如下: 由于内部错误,服务器无法处理该请求。有关该错误的详细信息,请打开服务器上的 IncludeExceptionDetailInFaults (从 ServiceBehaviorAttribute 或从 <serviceDebug> 配置行为)以便将异常信息发送回客户端,或在打开每个 Microsoft .NET Framework 3.0 SDK 文档的跟踪的同时检查服务器跟踪日志。 根据异常的提示,意思说如果要在客户端看到详细的Exception信息,那么请将ServiceBehavior对应的IncludeExceptionDetailInFaults属性设置为True,通常在配置中表现为如下设置: View Code 通过以上设置之后,客户端输出的内容为“尝试除以零”,这个提示信息跟原始的异常信息是一致,即返回的FaultException中的Reason包含原始异常的Message的值,但是这样处理之后服务端所报出的异常信息直接传到了客户端,比如一些保密信息也可能输出到了客户端,因此对于异常信息必须进行一个封装。最直接的形式莫过于在服务端就把异常给捕获了,并重新throw一个FaultException 服务端的代码改进如下,经过以下改进,那么客户端得到的信息仅仅是"操作失败",同时服务端也记录了异常信息(这时IncludeExceptionDetailInFaults是设置为False的)。 View Code 当然这是FaultException的默认用法,FaultException还支持强类型的异常错误信息,返回更加丰富和精确的错误提示。假设定义如下通用的一个FaultContract类型,将出错时的用户名和线程名字记录到异常信息中,因为异常信息也是通过SOAP格式传输的,因此跟定义其他DataContract的方式一样。 CommonFaultContract 那么服务方法的接口需要增加如下标记,如果不这样标记,那么客户端得到的异常类型依然是FaultException,而不是强类型的异常信息。 [FaultContract(typeof(CommonFaultContract))] int Divide(int dividend, int divisor) 实现方法中抛出异常的部分代码改成如下: 异常处理 这时候重新生成客户端的代理类,然后更新客户端的代码如下,红色部分即获取强类型的异常错误信息。 View Code 当然在具体应用中还需要根据需求,返回不同的信息,构建不同的FaultContract。 以上服务端捕获的异常方法,适用于方法比较少的情况,如果有十多个方法,一个个去写try catch然后做标记等,那么工作量会很大,而且代码也不利于重用。尝试寻找像MVC Controller那样的统一处理Exception的方式,将异常处理都放在基类中,那么只要继承与这个基类的方法都不需要去写try catch去捕获异常。但WCF中似乎没有这样的机制,放弃了这种做法。 最近在研究Enterprise Lib中对WCF的支持时,发现Exception Block中还特地有针对WCF程序异常处理的解决方案,而且满足以上说道的需求,即可记录异常,又可对异常信息进行封装。更重要的时,自动处理运行时的异常信息,不需要挨个方法的去写Try catch。秉承企业库的优秀传统,大部分工作还是通过配置就可以完成了,非常好的解决方案。下面介绍具体的使用步骤。 步骤一: 引用以下dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.dll Microsoft.Practices.EnterpriseLibrary.ExceptionHandling.WCF.dll Microsoft.Practices.EnterpriseLibrary.Common.dll Microsoft.Practices.ObjectBuilder2.dll 步骤2: 在具体的实现类中,增加如下属性标记,其中WcfException为企业库中Exception Block中的一个异常处理策略,具体如何配置异常处理策略,请参考企业库的帮助文档。 [ExceptionShielding("WcfException")] public class CalculateService : ICalculateService 那么只要增加了[ExceptionShielding("WcfException")]这个属性标记之后,所有运行时的异常都将交给策略名为WcfException的异常处理block来处理,在这里就可以执行一些异常记录以及异常封装的操作。 步骤3: 将异常信息封装为FaultException,这个动作也是通过配置来完成。在Exception节点中添加一个Fault Contract Exception Handler。 Fault Contract Exception Handler需要设置以下两个属性值 exceptionMessage:所有异常封装后的错误信息 faultContractType:即返回异常的faltContract类型,这个类型必须指定一个,哪怕方法中没有用到也要,如果方法中有用到,那么客户端那边就能得到强类型FaultException,否则就是普通的FaultException。这里指定为之前定义的CommonFaultContract。 对于faultContract类型的值,还可以通过PropertyMappings来自定义需要从原始异常信息中映射到faultContract的属性中,这个属性可选。 […]
View Details使用WCF传输大数据时,我们都会碰到如题中出现的错误信息,出现这个问题是因为WCF本身的安全机制导致的,限制了客户端与服务器资源传输大小,那我们如何还解决这个问题呢? 针对这个问题,我们要分发送、接受两个方面来解决。 发送大数据:在WCF服务端解决 NetTcpBinding binding = new NetTcpBinding(); binding.MaxReceivedMessageSize= 2147483647(更改这个数字) ; 接受大数据:在WCF客户端解决 NetTcpBinding binding = new NetTcpBinding(); binding.ReaderQuotas = new XmlDictionaryReaderQuotas() { MaxStringContentLength = 2147483647(更改这个数字) }; 我们即可以使用如上述通过代码配置,我们同样也可以使用配置文件进行配置(在binding节中)。
1 2 3 4 5 6 7 |
public static System.ServiceModel.BasicHttpBinding Binding() { //读取 XML 数据时,超出最大字符串内容长度配额 (8192)。 System.ServiceModel.BasicHttpBinding bing = new System.ServiceModel.BasicHttpBinding(); bing.ReaderQuotas = new System.Xml.XmlDictionaryReaderQuotas() { MaxStringContentLength = 2147483647 }; //(更改这个数字) return bing; } |
1 2 3 |
public static API.iClient api = new API.iClient(Binding(), new System.ServiceModel.EndpointAddress("http://192.168.1.11:4417/WebService.svc")); 转自:<a href="http://www.cnblogs.com/Fooo/archive/2012/12/06/2805362.html">http://www.cnblogs.com/Fooo/archive/2012/12/06/2805362.html</a> |
WEB站点在调用我们WCF服务的时候,只要传入的参数过长,就报如下错误: [csharp] view plaincopy 格式化程序尝试对消息反序列化时引发异常: 尝试对参数 http://tempuri.org/ 进行反序列化时出错: formDataXml。InnerException 消息是“反序列化对象 属于类型 System.String 时出现错误。读取 XML 数据时,超出最大字符串内容长度配额 (8192)。通过更改在创建 XML 读取器时所使用的 XmlDictionaryReaderQuotas 对象的 MaxStringContentLength 属性,可增加此配额。 第 137 行,位置为 76。”。有关详细信息,请参阅 InnerException。 网上一搜索,答案基本得到解决,可我的问题就是不能解决(主要是细节打败了我),按照网上的文章进行服务器端修改配置如下: [html] view plaincopy <binding name="HttpBinding" <span style="color:#ff0000"><strong>maxReceivedMessageSize</strong></span>="2097152"> <readerQuotas maxDepth="32" <span style="color:#ff0000"><strong>maxStringContentLength</strong></span>="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" /> <security mode="None"></security> </binding> 其实这里主要的配置是两个:maxReceivedMessageSize、maxStringContentLength; 网上提到还需要配置客户端,其实如果是报上面错误就不要管客户端了,因为如果是客户端调用WCF报错,就不是读取XML数据超时,而是明确的错误提示,如下: [csharp] view plaincopy 已超过传入消息(1024)的最大消息大小配额。若要增加配额,请使用相应绑定元素上的 MaxReceivedMessageSize 属性。 所以这篇文章提到的错误基本与客户端无关。 一般情况下,安装上面的修改就可以解决问题了,但是我的WCF还是报错,没办法,只能继续找,无意间发现服务器端WCF配置有点异常,不用登录验证的WCF接口有用到bindingConfiguration,但是需要验证的WCF接口就没有配置该属性,如下代码: [html] view plaincopy <bindings> <wsHttpBinding> <span style="color:#ff0000"><binding name="HttpBinding" maxReceivedMessageSize="2097152"> <readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" /> <security mode="None"></security> </binding></span><span style="background-color:#f0f0f0"><binding name="HttpBinding" maxReceivedMessageSize="2097152"> <readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" /> <security mode="None"></security> </binding></span> </wsHttpBinding> </bindings> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> <services> <service name="Achievo.MMIP.WMP.WebService.WMPProcService" behaviorConfiguration="wmpWcfBehavior"> <span style="color:#ff0000"><strong><endpoint address="" binding="wsHttpBinding" contract="Achievo.MMIP.WMP.WebServiceIService.WMPServiceProcIService"></strong> </span> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> <service name="Achievo.MMIP.WMP.WebService.WMPGetFormDataService" behaviorConfiguration="wmpWcfFormDataBehavior"> <span style="color:#ff0000"><strong><endpoint address="" binding="wsHttpBinding" bindingConfiguration="HttpBinding" contract="Achievo.MMIP.WMP.WebServiceIService.IWMPGetFormDataIService"></strong> </span> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> 注意红色部分的配置,大伙可以对比一下,就发现其中一个缺少bindingConfiguration配置;如果这个时候,把缺少的部分补上,和另外一个配置一样,WCF就会出错,这里我的初步判断是:name="Achievo.MMIP.WMP.WebService.WMPProcService"是必须要验证登录才能访问,所以不能绑定上面的匿名访问的配置,简单说就是规定是验证就不能在配置为匿名;所以把配置修改为如下: [html] view plaincopy <bindings> <wsHttpBinding> <span style="color:#ff0000"><strong><binding name="HttpBinding" maxReceivedMessageSize="2097152"> <readerQuotas maxDepth="32" maxStringContentLength="2097152" maxArrayLength="2097152" maxBytesPerRead="2097152" maxNameTableCharCount="2097152" /> <security mode="None"></security> </binding> <binding name="HttpBinding1" maxReceivedMessageSize="2097152"> <readerQuotas maxDepth="32" maxStringContentLength="2097152"/> </binding></strong></span> </wsHttpBinding> </bindings> <serviceHostingEnvironment aspNetCompatibilityEnabled="true" /> <services> <service name="Achievo.MMIP.WMP.WebService.WMPProcService" behaviorConfiguration="wmpWcfBehavior"> <strong><span style="color:#ff0000"><endpoint address="" binding="wsHttpBinding" <span style="font-size:18px">bindingConfiguration="HttpBinding1"</span> contract="Achievo.MMIP.WMP.WebServiceIService.WMPServiceProcIService"></span></strong> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> <service name="Achievo.MMIP.WMP.WebService.WMPGetFormDataService" behaviorConfiguration="wmpWcfFormDataBehavior"> <strong><span style="color:#ff0000"><endpoint address="" binding="wsHttpBinding" bindingConfiguration="HttpBinding" contract="Achievo.MMIP.WMP.WebServiceIService.IWMPGetFormDataIService"></span></strong> <identity> <dns value="localhost" /> </identity> </endpoint> <endpoint address="mex" binding="mexHttpBinding" contract="IMetadataExchange" /> </service> </services> 在验证,OK,通过。 转自:http://blog.csdn.net/yang_5/article/details/11775819
View Detailsusing System; using System.IO; using System.Runtime.Serialization; using System.Runtime.Serialization.Formatters.Binary; using System.Runtime.Serialization.Formatters.Soap; using System.Xml.Serialization; using HP.Common; namespace HP.UI.Web { public partial class Test : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { //原始对象 var obj = new Person { Sno = "200719", Name = "yuananyun", Sex="man", Age=22 }; Response.Write("原始信息:" + obj.DisplayInfo() + "<br /><br />"); //序列化 IFormatter formatter = new BinaryFormatter(); //二进制 //IFormatter formatter = new SoapFormatter(); //SOAP //var formatter = new XmlSerializer(typeof(Person)); //XML var stream = new MemoryStream(); formatter.Serialize(stream, obj); var bs = stream.ToArray(); var s = System.Text.Encoding.Default.GetString(bs); stream.Close(); Response.Write("序列化:" + s + "<br /><br />"); […]
View Details/** * 数字转换为中文 * @param string|integer|float $num 目标数字 * @param integer $mode 模式[true:金额(默认),false:普通数字表示] * @param boolean $sim 使用小写(默认) * @return string */ function number2chinese($num,$mode = true,$sim = true){ if(!is_numeric($num)) return '含有非数字非小数点字符!'; $char = $sim ? array('零',’一',’二',’三',’四',’五',’六',’七',’八',’九') : array('零',’壹',’贰',’叁',’肆',’伍',’陆',’柒',’捌',’玖'); $unit = $sim ? array(",’十',’百',’千',",’万',’亿',’兆') : array(",’拾',’佰',’仟',",’萬',’億',’兆'); $retval = $mode ? '元':’点'; //小数部分 if(strpos($num, '.')){ list($num,$dec) = explode('.', $num); $dec = strval(round($dec,2)); if($mode){ $retval .= "{$char[$dec['0']]}角{$char[$dec['1']]}分"; }else{ for($i = 0,$c = strlen($dec);$i < $c;$i++) { $retval .= $char[$dec[$i]]; } } } //整数部分 $str = $mode ? strrev(intval($num)) : strrev($num); for($i […]
View DetailsAndroid以其极强的开放性吸引着世界各地的开发者去开发各种各样的移动应用开发,而各种SDK更是为各个层次的开发者提供了一个可以尽情展示 他们专业技能和创造性的平台。虽然Java是各种平台最常用的编程语言,但是其它一些开发工具包只支持C、C++和Ruby。除此之外,所要开发应用的特 性在一定程度上也决定了开发环境的选择,开发工具内置的库能够降低开发强度,而特定的功能也能进行模块式独立开发,以下是Android开发者不可错过的 四款强大的Android开发工具: 1. Basic4Android Basic4Android是Android平台上一个简单而又强大的可视化快速应用开发工具,可以开发基于云计算的Android应用,同时还内 置了企业级移动应用开发所需的代码库;Basic4Android可被用来开发和测试数据库通信,甚至可以被用来开发2D的即时游戏。 Basic4Android兼容了Google的AdMob数据库,所以开发者可以在他们开发的应用中植入广告来获取收益。 主要特性: 编译为原生的bytecode,不需要运行库。生成的APK文件与Java / Eclipse生成的文件完全一样 与Java编写的应用性能相同 与Visual Basic类似的事件驱动编程语言,支持对象和代码模块 不需要写任何XML文件 可视化编辑器支持多屏幕和各种分辨率 支持Android 1.6及其以上版本的所有移动设备 支持自动完成、内置文档、内部索引和其它高级功能 强大的单步调试功能 支持所有的Android核心特性 2. Gimbal context ware Gimbal是高通旗下Qualcomm Labs推出的一款面向iOS和Android平台的SDK。Gimbal中的内置函数库能够为开发者提供特定位置或地理围栏解决方案。Gimbal环境 感知SDK帮助开发者向手机用户提供及时、个性化的相关内容,开发者可以从SDK中选择所需的软件库加入应用中。 这些SDK包括: Gimbal Geofence:旨在提供基于地理围栏的低功耗位置识别服务。这一工具将赋予应用“环境感知”功能,即能够根据用户所在的位置对用户做出有益调整。 Gimbal Interest Sensing:使应用能够根据终端用户的个人信息和兴趣做出调整,此工具可以针对特定受众提供定制应用。 Gimbal Image Recognition:使终端用户可以通过智能手机的摄像头发起互动体验。 Gimbal Manager:是一款基于Web的工具,用于管理地理围栏、个人信息规则、图像目标、内容、发布和分析。 Gimbal Privacy:供终端用户管理Gimbal及其功能,Gimbal旨在让终端用户了解和掌控他们分享环境和兴趣的内容和时间,并保护用户的个人信息。 3. Titanium SDK Titanium旨在为跨平台的原生移动开发提供一种更高级的API,所以开发者可以访问一系列从用户界面组件、插座接口到通知系统集成的原生特性 和功能。Titanium的目的是将Titanium应用程序和纯原生应用程序之间在功能方面的差异缩小到几乎为零。目前,Titanium支持iOS、 Android、BlackBerry和Windows Phone。此外,Titanium借助统一的JavaScript API,针对特定平台的功能特性以及原生性能,实现代码重用,大大地缩减了开发者的工作时间。 主要特性: 开源:Titanium采用宽松的Apache 2.0许可证 高效开发:通过代码重用,减少了开发者的工作时间,调高工作效率 廉价特性:通过使用JavaScript SDK降低了跨平台操作的成本 4. Vuforia Vuforia是一款能将现实世界物体转变为互动体验的扩增实境平台。旨在帮助开发者打造全新级别的真实世界物品与虚拟物品的互动。它使用家算计视 觉技术来实时地识别和跟踪平面图像以及简单的3D图像,使开发者能够在现实世界和数字体验之间架起桥梁。 Vuforia通过Unity游戏引擎扩展提供了C、Java、Objective-C和.Net语言的应用程序编程接口。从而Vuforia SDK能够同时支持iOS和Android的原生开发,这也使开发者在Unity引擎中开发AR应用程序时很容易将其移植到iOS和Android平台 上。 主要特性: 跨平台:同时支持iOS和Android系统 AR特性: Vuforia是移动设备最好的增强现实体验平台 最佳的性能体验:通过无与伦比的交互性实现现实与虚拟的完美互动 文字识别功能:支持借助智能手机和平板电脑摄像头实现实时文字识别 文章来源:Examiner /CSDN
View Details