
置顶随笔
摘要: 周六闲来无事,学习了多线程BackgroundWorker,以此记录。此案例功能:实现用BackgroundWorker处理进度条,可以开始,暂停,继续,清空。BackgroundWorker说明:摘抄自---http://msdn.microsoft.comBackgroundWorker 类允许您在单独的专用线程上运行操作。耗时的操作(如下载和数据库事务)在长时间运行时可能会导致用户界面 (U...
阅读全文
posted @ 2008-11-24 13:09 yiyisawa 阅读(4171) 评论(2)
编辑

2009年1月13日
http://www.cnblogs.com/yiyisawa/archive/2008/12/16/1356191.html wcf client与webservice通信(-)只修改配置文件而改变服务端 一文中如果要将wcf service或web service host 到iis中去的话(之前没有host 到iis中去,只是临时运行service,然后取临时服务地址),有几点需要注意的地方:
一.当共用一个wcf client 调用wcf service or web service时,会在wcf client 调用web service会出现issue:
The HTTP request is unauthorized with client authentication scheme 'Anonymous'. The authentication header received from the server was 'Negotiate,Kerberos,NTLM'.
解决方案:
在wcf client的配置文件的绑定中安全设置加上以下设置,即可成功调用。详情参见:
http://www.kodyaz.com/blogs/software_development_blog/archive/2008/02/25/849.aspx

Code
<security mode="TransportCredentialOnly">
<transport clientCredentialType="Windows" proxyCredentialType="Windows" realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
二.在iis中浏览webservice时出现大红色的Service Unavailable。
解决方案:
Internet Information Services(iis) Manager--->web sites ---> 具体项目的虚拟目录-->右键属性--->permissions:
1.添加以下权限:
iis_WPG
NETWORK SERVICE
Users(Yiyisawa\Users)这个要根据域名来添加,(貌似)
Internet Information Services(iis) Manager--->web sites ---> 具体项目的虚拟目录-->右键属性--->properties-->Directory Security--->Authentication and access control-->edit--->选中Enable anonynous access 即可。
另:因为要HOST到IIS中去,期间iis出故障,重装IIS,重装过程中出现需要I386文件:
插入一张系统盘,引导到盘符下即可找到。
posted @ 2009-01-13 11:50 yiyisawa 阅读(456) 评论(0)
编辑

2008年12月26日
问题:a公司使用wcf 发布服务(.net Framework 3.0 or 3.5),b公司需要使用a公司发布的服务 ,但b公司目前阶段只使用.net Framework2.0(.net Framework 2.0不支持wcf),如果要调用a公司wcf 服务,那怎么办呢?
一、先上wcf 代码(这里懒得写了,借用microsoft公司发布的wcf samples):

Code
namespace Microsoft.ServiceModel.Samples


{
// NOTE: If you change the interface name "IService1" here, you must also update the reference to "IService1" in Web.config.
[ServiceContract, XmlSerializerFormat]
public interface ICalculator

{
[OperationContract]
double Add(double n1, double n2);
[OperationContract]
double Subtract(double n1, double n2);
[OperationContract]
double Multiply(double n1, double n2);
[OperationContract]
double Divide(double n1, double n2);
}

public class CalculatorService : ICalculator

{
public double Add(double n1, double n2)

{
return n1 + n2;
}

public double Subtract(double n1, double n2)

{
return n1 - n2;
}

public double Multiply(double n1, double n2)

{
return n1 * n2;
}

public double Divide(double n1, double n2)

{
return n1 / n2;
}
}
}
配置文件:

Code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<system.serviceModel>
<services>
<service
name="Microsoft.ServiceModel.Samples.CalculatorService"
behaviorConfiguration="CalculatorServiceBehavior">
<endpoint address=""
binding="basicHttpBinding"
contract="Microsoft.ServiceModel.Samples.ICalculator" />
</service>
</services>
<behaviors>
<serviceBehaviors>
<behavior name="CalculatorServiceBehavior">
<serviceMetadata httpGetEnabled="True"/>
<serviceDebug includeExceptionDetailInFaults="False" />
</behavior>
</serviceBehaviors>
</behaviors>
</system.serviceModel>
</configuration>
运行,记录服务地址。
二、使用wsdl工具将wcf service生成asp.net webservice方式。
start --->运行--->cmd --->cd C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin 回车。
输入wsdl 服务地址。例(wsdl http://localhost:8571/Service1.svc )便生成相应的类似asp.net webservice代理类的文件。文件地址亦在上面bin中。
新建Console application (net Framework 2.0),添加刚刚生成的代理类。调用:
调用代码:

Code
class Client

{
static void Main()

{
// Create a client to the CalculatorService
using (CalculatorService client = new CalculatorService())

{
// Call the Add service operation.
double value1 = 100.00D;
double value2 = 15.99D;
double result = client.Add(value1, value2);
Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);

// Call the Subtract service operation.
value1 = 145.00D;
value2 = 76.54D;
result = client.Subtract(value1, value2);
Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);

// Call the Multiply service operation.
value1 = 9.00D;
value2 = 81.25D;
result = client.Multiply(value1, value2);
Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);

// Call the Divide service operation.
value1 = 22.00D;
value2 = 7.00D;
result = client.Divide(value1, value2);
Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);

}

Console.WriteLine();
Console.WriteLine("Press <ENTER> to terminate client.");
Console.ReadLine();
}
}
配置文件:

Code
<?xml version="1.0" encoding="utf-8" ?>
<configuration>
<appSettings>
<add key="CalculatorServiceAddress" value="http://localhost:8571/Service1.svc"/>
</appSettings>
</configuration>
运行,即可成功调用。
项目完整代码。http://files.cnblogs.com/yiyisawa/wcfclienttowebservice.rar
(完)
posted @ 2008-12-26 16:40 yiyisawa 阅读(470) 评论(0)
编辑

2008年12月16日
问题: 假设有一个大型系统新版本使用wcf 作为服务端,生成wcf client 调用可以调用正常。 那如果当wcf 服务端出现问题或其他的原因我想再用回以前老版本的webservice或是jms server ,但客户端调用还是通过wcf client 调用。只通过更改配置来实现。
一、web service项目,添加一个普通service class .代码如下:

Code
Code
[WebService(Namespace="http://Microsoft.ServiceModel.Samples")]
public class CalculatorService : System.Web.Services.WebService
{
[WebMethod]
public double Add(double n1, double n2)
{
return n1 + n2;
}
[WebMethod]
public double Subtract(double n1, double n2)
{
return n1 - n2;
}
[WebMethod]
public double Multiply(double n1, double n2)
{
return n1 * n2;
}
[WebMethod]
public double Divide(double n1, double n2)
{
return n1 / n2;
}
}
webservice配置文件无需更改。运行。记录服务地址。
二、打开路径C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin:找到svcutil.exe文件。开始菜单-->run --> input cmd --->cd C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin -->回车;
输入svcutil http://localhost:8080/service/service.asmx,将会在C:\Program Files\Microsoft SDKs\Windows\v6.0A\bin生成一个webservice的代理类。注意:此代理类是wcf client形式的。(在后面只需将这个代理类小作改动,便可用于wcf sevice.)
生成的代理类:

Code
//------------------------------------------------------------------------------
// <auto-generated>
// This code was generated by a tool.
// Runtime Version:2.0.50727.3053
//
// Changes to this file may cause incorrect behavior and will be lost if
// the code is regenerated.
// </auto-generated>
//------------------------------------------------------------------------------
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
[System.ServiceModel.ServiceContractAttribute(Namespace = "http://Microsoft.ServiceModel.Samples", ConfigurationName = "CalculatorServiceSoap")]
public interface CalculatorServiceSoap
{
[System.ServiceModel.OperationContractAttribute(Action = "http://Microsoft.ServiceModel.Samples/Add", ReplyAction = "*")]
double Add(double n1, double n2);
[System.ServiceModel.OperationContractAttribute(Action = "http://Microsoft.ServiceModel.Samples/Subtract", ReplyAction = "*")]
double Subtract(double n1, double n2);
[System.ServiceModel.OperationContractAttribute(Action = "http://Microsoft.ServiceModel.Samples/Multiply", ReplyAction = "*")]
double Multiply(double n1, double n2);
[System.ServiceModel.OperationContractAttribute(Action = "http://Microsoft.ServiceModel.Samples/Divide", ReplyAction = "*")]
double Divide(double n1, double n2);
}
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public interface CalculatorServiceSoapChannel : CalculatorServiceSoap, System.ServiceModel.IClientChannel
{
}
[System.Diagnostics.DebuggerStepThroughAttribute()]
[System.CodeDom.Compiler.GeneratedCodeAttribute("System.ServiceModel", "3.0.0.0")]
public partial class CalculatorServiceSoapClient : System.ServiceModel.ClientBase<CalculatorServiceSoap>, CalculatorServiceSoap
{
public CalculatorServiceSoapClient()
{
}
public CalculatorServiceSoapClient(string endpointConfigurationName)
:
base(endpointConfigurationName)
{
}
public CalculatorServiceSoapClient(string endpointConfigurationName, string remoteAddress)
:
base(endpointConfigurationName, remoteAddress)
{
}
public CalculatorServiceSoapClient(string endpointConfigurationName, System.ServiceModel.EndpointAddress remoteAddress)
:
base(endpointConfigurationName, remoteAddress)
{
}
public CalculatorServiceSoapClient(System.ServiceModel.Channels.Binding binding, System.ServiceModel.EndpointAddress remoteAddress)
:
base(binding, remoteAddress)
{
}
public double Add(double n1, double n2)
{
return base.Channel.Add(n1, n2);
}
public double Subtract(double n1, double n2)
{
return base.Channel.Subtract(n1, n2);
}
public double Multiply(double n1, double n2)
{
return base.Channel.Multiply(n1, n2);
}
public double Divide(double n1, double n2)
{
return base.Channel.Divide(n1, n2);
}
}
三、添加Console Application,将上面生成的代理类加入项目中,并在Main方法中调用。

Code
Service1Clients client = new Service1Clients();
// Service1Client client = new Service1Client();
// Call the Add service operation.
double value1 = 100.00D;
double value2 = 15.99D;
double result = client.Add(value1, value2);
Console.WriteLine("Add({0},{1}) = {2}", value1, value2, result);
// Call the Subtract service operation.
value1 = 145.00D;
value2 = 76.54D;
result = client.Subtract(value1, value2);
Console.WriteLine("Subtract({0},{1}) = {2}", value1, value2, result);
// Call the Multiply service operation.
value1 = 9.00D;
value2 = 81.25D;
result = client.Multiply(value1, value2);
Console.WriteLine("Multiply({0},{1}) = {2}", value1, value2, result);
// Call the Divide service operation.
value1 = 22.00D;
value2 = 7.00D;
result = client.Divide(value1, value2);
Console.WriteLine("Divide({0},{1}) = {2}", value1, value2, result);
//Closing the client gracefully closes the connection and cleans up resources
client.Close();
Console.WriteLine();
Console.WriteLine("Press <ENTER> to terminate client.");
Console.ReadLine();
添加配置文件:App.config.此配置文件在二步生成代理类的时候会有Out.config同时产生。config里面的内容拷过来即可。

Code
<system.serviceModel>
<bindings>
<basicHttpBinding>
<binding name="CalculatorServiceSoap" closeTimeout="00:01:00"
openTimeout="00:01:00" receiveTimeout="00:10:00" sendTimeout="00:01:00"
allowCookies="false" bypassProxyOnLocal="false" hostNameComparisonMode="StrongWildcard"
maxBufferSize="65536" maxBufferPoolSize="524288" maxReceivedMessageSize="65536"
messageEncoding="Text" textEncoding="utf-8" transferMode="Buffered"
useDefaultWebProxy="true">
<readerQuotas maxDepth="32" maxStringContentLength="8192" maxArrayLength="16384"
maxBytesPerRead="4096" maxNameTableCharCount="16384" />
<security mode="None">
<transport clientCredentialType="None" proxyCredentialType="None"
realm="" />
<message clientCredentialType="UserName" algorithmSuite="Default" />
</security>
</binding>
</basicHttpBinding>
</bindings>
<client>
<endpoint address="http://localhost:8080/service/service.asmx"
binding="basicHttpBinding"
contract="IService1" name="IService1" />
</client>
</system.serviceModel>
将webservice运行起来,(也可host到iis 里去。)debug console application.即可看到结果。
回家吃饭了。
细节和要注意的地方在第二节中写出来。
项目下载地址:http://files.cnblogs.com/yiyisawa/wcfclienttowebservice.rar
posted @ 2008-12-16 19:23 yiyisawa 阅读(1034) 评论(4)
编辑

2008年11月27日
http://www.codeproject.com/KB/WPF/WPFdockinglib.aspx
posted @ 2008-11-27 12:05 yiyisawa 阅读(658) 评论(0)
编辑

2008年11月24日
摘要: 周六闲来无事,学习了多线程BackgroundWorker,以此记录。此案例功能:实现用BackgroundWorker处理进度条,可以开始,暂停,继续,清空。BackgroundWorker说明:摘抄自---http://msdn.microsoft.comBackgroundWorker 类允许您在单独的专用线程上运行操作。耗时的操作(如下载和数据库事务)在长时间运行时可能会导致用户界面 (U...
阅读全文
posted @ 2008-11-24 13:09 yiyisawa 阅读(4171) 评论(2)
编辑

2008年11月20日
摘要: 昨天在网上乱逛,误打误撞中下载到vs工具技巧手册,发现原来vs的操作有这么多快捷方式,终于发现为什么别人写code那么快,我那么慢的原因了。原来是因为这个。哈哈。Visual Studio .NET是微软推出的功能最丰富,扩展性最强的编程工具。VS.NET中的功能与快捷方式不计其数,并且在每一个版本中都会明显增加。不熟悉这些节省时间的功能的话,开发者会错过提高开发生产力和效率的大好机会。 本书主要...
阅读全文
posted @ 2008-11-20 17:55 yiyisawa 阅读(109) 评论(0)
编辑

2008年6月13日
摘要: 在完成一个项目发布到iis中的时候,大致步骤都是其他项目是相同的,只是需要多加一个步骤:在iis中点示虚拟目录,右键property,http header -->add-->MIME TYPE -->NEW ,在两个文本框中均填上.xap,-->ok。
阅读全文
posted @ 2008-06-13 18:28 yiyisawa 阅读(60) 评论(0)
编辑
摘要: Silverlight 2 Beta 2 (6/6/2008 发布的最新版本) 通过尝试性开发,主要发现以下问题:缺陷列表:1.Silverlightbeta2不能正常调用webservice和WCF(Silverlightbeta1版可以正常使用webservice和wcf),补充:后来在一个blog上看到是可以调用的,只是要稍微处理下:详情见http://www.cnblogs.com/alv...
阅读全文
posted @ 2008-06-13 18:05 yiyisawa 阅读(68) 评论(0)
编辑

2008年3月25日
posted @ 2008-03-25 17:15 yiyisawa 阅读(325) 评论(3)
编辑

2008年2月19日
摘要: 从今天起,好好学习,好好工作,天天向上从今天起,学习技术,学习英语从今天起,早起早睡,锻炼身体,精神百倍,偶尔吃吃睡睡从今天起,写工作日志,写生活日记,整理时间,整理心情从今天起,忘记过去,重新开始,每天都是新的一天
阅读全文
posted @ 2008-02-19 07:48 yiyisawa 阅读(41) 评论(0)
编辑