Blog Stats
  • Posts - 8
  • Articles - 0
  • Comments - 2
  • Trackbacks - 0

 

Sunday, May 13, 2007

Saturday, May 12, 2007

使用javascript调用cgi程序的方法

使用javascript调用cgi程序的方法

# 乌龙(sirbo)
# sirbowl@263.net
# http://sirbo.126.com
# 乌龙cgi/php天下

1.在调用页中加html代码如下:

 <script language='JavaScript' src='http://kingtown.net/cgi-bin/click/click.cgi?job=dplaytime&filename=cookie'></script>
 
2.在cgi程序里需:
 
   1.发一个html头: [不可少!]
   
     print "Content-type:text/html\n\n";
  
   2.print出javascript之document.write()动态写出你要的html代码,如下句
  
     print("document.write('<center><font color=$color size=$size1>$downtime</font></center>');\n");

Tuesday, May 08, 2007

WebService中如何使用自定义类相关问题的解决办法(下)

4.上面的例程中用到了自己编写的SerializationTool类的构造函数,还有使用到了该类下的Sedes()方法。这里便是该文档的重点内容所在。接下来就将这个类的原码在下面的例程中给出,并进行讲解。

 

        /// <summary>

        /// Author:Daniel Kwok

        /// Date:2006/12/14

        /// Description:You can use this class to serialize and deserialize some classes you want.

        /// </summary>

        public class SerializationTool{

                Object oSrc;

                Object oDes;

                public SerializationTool(){}

                /// <summary>

                /// Overload constructor

                /// </summary>

                /// <param name="srcObj">Source object</param>

                /// <param name="desObj">Destination object</param>

                public SerializationTool(Object srcObj,Object desObj){

                        this.oSrc = srcObj;

                        this.oDes = desObj;

                }

                /// <summary>

                /// The function of this method describe

                /// serialize object named oSrc into condition.xml

                /// and deserialize from condition.xml into object named oDes

                /// </summary>

                /// <returns>oDes</returns>

                public Object Sedes(){

                        IFormatter formatter = new SoapFormatter();

                        Stream stream = new FileStream("condition.xml",FileMode.Create,FileAccess.Write,FileShare.None);

                        formatter.Serialize(stream,this.oSrc);

                        stream.Close();

                        stream = new FileStream("condition.xml",FileMode.Open,FileAccess.Read,FileShare.Read);

                        formatter.Binder= new MyBinder(this.oSrc,this.oDes);

                        this.oDes = formatter.Deserialize(stream);

                        stream.Close();

                        return this.oDes;

                }

        }

        /// <summary>

        /// Author:Daniel Kwok

        /// Date:2006/12/14

        /// Description:This class is a customize binding class extends abstract class named SerializationBinder.

        /// </summary>

        public class MyBinder:SerializationBinder{

                Object oSrc;//Source object

                Object oDes;//Destination object

                public MyBinder():base(){}

                public MyBinder(Object srcClass,Object desClass){

                        this.oSrc = srcClass;

                        this.oDes = desClass;

                }

                public override Type BindToType(string assemblyName,string typeName){

                        //If it is an instance of class that oSrc belongs to,

                        //generate one instance of class that oDes belongs to

                        //by deserialization.

                        if(typeName == (oSrc.GetType()).FullName)

                                return oDes.GetType();

                        Assembly a = Assembly.Load(assemblyName);

                        return a.GetType(typeName);

                }

    }

SerializationTool类中重载的构造函数内的两个参数分别是将要进行强制转化的两种数据类型(最初定义的EstimateSearchCondition类和WebService 命名空间下的代理的EstimateSearchCondition类)的实例对象。然后,通过SerializationTool类中的Sedes()方法将两种类型进行序列化和反序列化的操作,这样便可以将两种类型进行转化。由于该方法返回的是一个Object的类型,所以在第3部分中用(HostEstimateService.EstimateSearchCondition)st.Sedes();的方式将其强制转化成了所需要的数据类型。

5.通过上面14的例程代码,就可以实现自定义类在WebService中的传输使用了。但除了上述的介绍外,在这里还有几点需要进行说明。在撰写例程4部分的代码时,需要在工程中导入System.Runtime.Serialization.Formatters.Soap组件,这样才可以使用相关的类及方法。此外,还需要提醒大家的一点就是,在客户端改变引用WebService的时候,在客户端工程文件下,会自动产生上面提到的Web References文件夹和该文件夹下面的相关文件,当然这里也就包含Reference.cs文件,那么,每当更新或重新生成对WebService引用的时候,上面提到的需要修改的Reference.cs文件下的自定义类,就会恢复到初始化时的情况,也就是该类的内容为空,这就需要你重新进行3中介绍的对该类的覆盖操作。

哎,终于都发布上来了,本来是想一整篇发布,无奈系统提示说是什么篇幅文字过长,非得让分批来发布。算了闲话不说了,讲到这里,对于自定义类作为参数或者返回值在WebService中进行操作的方法的介绍也就基本结束了。以上内容完全利用业余时间所写,由于时间仓促,如果有哪些地方,介绍的不清楚的话,请大家提出,我会尽力回复,希望大家共同进步。

WebService中如何使用自定义类相关问题的解决办法(上)

转自: http://danielkwok224.spaces.live.com/

在刚刚开始使用WebService的过程中,多数人都会遇到一个使用上让人比较难受的地方。WebService作为中间层,为其上层或下层之间传递数据,如果该传递的数据类型不是系统默认可以序列化的类型(如String,int等),即自定义的类不论是以WebService方法的参数还是返回值的形式进行传递的时候,都会失败。传输失败的原因是因为通过WebService进行方法调用的时候,使用标准化的XML消息传递机制,所以不能够像使用本地对象一样,直接传递自定义类的实例对象。

在网上看到了很多提到类似问题的帖子,但多数的回答都只是从原理上进行了阐述和说明,而没有实际的例程,对于接触该方面较少的人,虽然能够从原理上理解,但是头脑中仍然不清楚实际的解决方案,并不能够立刻地找到实际的解决方法。有鉴于此,现在将用如下的例程来说明并解决WebService中如何来使用自定义的类。

开发语言:C#

开发环境:Microsoft Visual Studio .NET 2003

1.先给出要在WebService中传递的自定义的类。如下面例程:

 

        [Serializable]

        public class EstimateSearchCondition

        {

                public EstimateSearchCondition(){

                }

                private String m_EstimateId;

                private String m_EstimateName;

                public String M_EstimateId{

                        get{return m_EstimateId;}

                        set{m_EstimateId = value;}

                }

                public String M_EstimateName{

                        get{return m_EstimateName;}

                        set{m_EstimateName = value;}

                }

    }

在这段代码中唯一需要说明的地方,就是在类的开始处用红色标记的[Serializable],这说明该类是需要进行序列化的。在这里再补充说明一点,在定义类的时候,除非确定该类不用进行序列化,可以在定义的时候不必添加该标记,除此之外,在类前添加该标记是比较好的习惯。也就是说,虽然是可选项,但是被认为是好的习惯。

2.下面将给出WebService中的方法的定义,如下面例程:

 

                [WebMethod]

                public EstimateListDataSet GetEstimateList(EstimateSearchCondition condition)

                {

                        try{

                                return new EstimateBLO().GetEstimateList(condition);

                        }

                        catch(System.Exception ex){

                                throw new Exception(ex.Message);

                        }

            }

这里的方法定义也不多说了,new EstimateBLO()是生成WebService调用的业务层的实例 

3.接下来说说如何调用WebService提供的方法,并将自定义类作为参数传入该方法。(当然,作为返回值也是同样的道理。)如下面例程:

 

                public ModelResult GetEstimateList(EstimateSearchCondition condition)

                {

                        try{

                                HostEstimateService.EstimateSearchCondition con = new HostEstimateService.EstimateSearchCondition(); 

                                SerializationTool st = new SerializationTool(condition,con);

                                con = (HostEstimateService.EstimateSearchCondition)st.Sedes();

                                this.m_EstimateService = new HostEstimateService.EstimateService();

                                SerializationTool stl = new SerializationTool(this.m_EstimateService.GetEstimateList(con),this.m_EstimateListDataSet);

                                this.m_EstimateListDataSet = (EstimateListDataSet)stl.Sedes();

                                return ModelResult.Success;

                        }

                        catch(System.Exception ex){

                                throw new Exception(ex.Message);

                        }

            }

在上面的例程中,由于WebService调用的时候,会代理生成的在WebService 命名空间下的与EstimateSearchCondition同名的类,所以在调用GetEstimateList方法时直接传入EstimateSearchCondition类的实例的时候,会提示类型不匹配,强制转换也无效。在客户端引用WebService服务的时候,在客户端程序的Web References文件夹下的Reference.cs文件内生成的代理类EstimateSearchCondition的内容是空的。这时需要打开Reference.cs文件,将原来EstimateSearchCondition类定义拷贝到该文件中,覆盖掉Reference.cs文件中的空代理类EstimateSearchCondition。并在该类的定义上面也加上[Serializable]

Monday, May 07, 2007

Dashboard项目,实现桌面的自动搜索功能

The Dashboard ,一种新出现的技术(或者应该说是新的应用想法),很值得研究,是搜索引擎更智能和便于使用的发展分支

Why can't my computer automatically show me things that will help me with what I'm doing, instead of making me search around for them?

The goal of the dashboard is to automatically show a user useful files and other objects as he goes about his day. While you read email, browse the web, write a document, or talk to your friends on IM, the dashboard does its best to proactively find objects that are relevant to your current activity, and to display them in a friendly way, saving you from digging around through your stuff like a disorganized filing clerk.

For example, if a friend IMs you and says "I can't wait for our camping trip this weekend!" the dashboard will show things like your recent emails about the camping trip, your camping bookmarks, and any files or notes you've got on your hard drive about camping.

Microsoft is biting off us and calls this concept "implicit query."

 

http://www.nat.org/dashboard/

http://www-128.ibm.com/developerworks/cn/xml/x-desktop/index.html#resources

Sunday, April 22, 2007

ASP.NET相关开发工具

极好的,能根据数据库自动生成3层架构的代码生成工具
http://www.hkvstore.com/aspnetmaker/

Thursday, April 19, 2007

Thursday, April 12, 2007

Dotnet常用工具

      ildasm:反编译.net程序;
      ilasm:编译il代码;
      Reflector:查看.net程序源码、程序集间的依赖关系;
      Xenocode Fox 2007:由.net程序生成.net工程;
      PEBrowseDbg:动态调试.net程序;
      WinDbg,OlleyDbg:调试分析程序;
      MASMPlus:查看编写编译汇编代码;
      DebugTrack:跟踪程序调试信息;
      eXeScope,PE Explorer:查看PE文件,修改程序资源;
      Code Smith:代码生成;
      Dis#:.net流程反混淆工具;
      CFF Explorer:.net PE文件查看器;
      CLRProfiler:.net分析工具;
      DNGRuard1.0:.net程序集加密工具;
      keymake:注册机,内存补丁;
      Stud_PE:查看、学习PE文件;
      IEDevToolBar:查看IE各标签属性;
      WatiN:Web项目自动化测试;
      antlr:解释器生成器;
      injectReflector:查看.net内存中IL代码;
      PEID:辨别程序开发语言;
      Log Explorer for SQL Serverv:SQL Server恢复误删数据;
      SnippetCompiler:简单代码编译;
      UltraEdit、EditPlus、NotePad:文本编辑、查看;
      RegExTool:正则表达式测试;
      Beyond Compare:文本比较。

原文 http://www.cnblogs.com/end/archive/2007/04/11/709241.html
下载工具:http://www.pediy.com/tools/dotnet.htm

最新评论

Syndication:

我参加的团队
 

 

Copyright © eddie