web service 添加服务引用和web 引用的区别
http://www.sjsjw.com/102/002329MYM001841/
在软件发布后,动态的修改引用地址的配置方法
注意这里我使用的是新版本的service 引用方式;
当你添加一个service reference后,会在对应的项目下生成一个app.config文件:(如下)
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<configSections>
</configSections>
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="PointStoreServiceSoap" />
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:25548/PointStoreService.asmx"
binding="basicHttpBinding" bindingConfiguration="PointStoreServiceSoap"
contract="PointStoreService.PointStoreServiceSoap" name="PointStoreServiceSoap" />
</client>
</system.serviceModel>
</configuration>
其中需要注意的是:
①basicHttpBinding节点下的<binding >,每天加一个service reference后,会生成一个binding节点。
②client节点下的endpoint,每添加service reference,也会增加一个endpoint节点。
如果添加webservice引用的项目是一个类库,那么就需要在网站的web.config下添加响应的模块来供类库读取。即在web.config配置文件中添加如下部分:
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="1111111111111" closeTimeout="00:01:00" openTimeout="00:01:00"
receiveTimeout="00:10:00" sendTimeout="00:01:00" allowCookies="false"
bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="6553600" maxBufferPoolSize="52428800" maxReceivedMessageSize="6553600"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="320" maxStringContentLength="8192000" maxArrayLength="163840"
maxBytesPerRead="40960" maxNameTableCharCount="163840" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://1111111111111111111111111.asmx"
binding="basicHttpBinding" bindingConfiguration="11111111111"
contract="1111111111111111" name="11111111111" />
</client>
</system.serviceModel>
以上xml节的结构就是app.config配置文件中的相同,只是添加了一些属性进行限制(对于每个属性的含义,大家有需要可以internet 查查。)显然,binding 节点的name属性和endpoint节点是可以直接从app.config copy过来的;
以上over
js多语言,定义两个js文件 如en-US.js, zh-CN.js
后端定义 public string Language
<script type="text/javascript" src="<%=Language%>.js"></script>
http://www.cnblogs.com/chenxizhang/archive/2009/11/28/1612595.html
bat文件,保存为resource.bat
rem Compile...
call "%VS100COMNTOOLS%..\..\VC\vcvarsall.bat"call resgen.exe en-US.resx
call resgen.exe zh-CN.resx
调用方法
public static string GetTransText(string key)
{
var filePath = HttpContext.Current.Server.MapPath("~/Resource");
string language = HttpContext.Current.Session["CurrentLang"] == null ? "zh-CN":
HttpContext.Current.Session["CurrentLang"].ToString();
string resxPath = string.Format(@"{0}\{1}.resources", filePath, language);
using (ResourceReader reader = new ResourceReader(resxPath))
{
var evalue = reader.Cast<DictionaryEntry>().FirstOrDefault<DictionaryEntry>(x => x.Key.ToString() == key);
return evalue.Value == null ? string.Empty : entry.Value.ToString();
}
}