2007年3月15日星期四

CIM、WBEM要Web Service化么?

CIM、WBEM要Web Service化么?

    其实我的需求很简单,就是要让PHP能够和C/C++通讯。

    RPC?是的,当然要有。但是我们也期望有一个好的设计,就比如Java RMI那样的,可以将我们的开发成本降到最低。

    跨语言嘛,很容易就想到了XML。XMLRPC试过了,简单轻便,但是设计上的能力稍微差点。SOAP好些,WSDL正好加强了设计,可以完全实现类似RMI的模式。模式的名字叫什么?Proxy?

    可是我也知道WBEM能够完成同样的功能,但是去不了解他是具体实现的。想要通过Web访问,肯定要有一个协议吧?于是幻想WBEM的解决办法,也许一切都已经实现了,也许和SOAP差不多。

    花了三天看CIM、WBEM和SMI,终于搞清楚了,大失所望。。。。。。

    CIM定义了一个对象的角色和模样,你将你自己的设备包装成这个模样,你就是符合标准的了,可以被管理。

    WBEM使CIM可以应用起来。通过Service Location Protocol (SLP),WBEM工具可以发现CIM服务端。通过CIM-XML,WBEM工具可以向CIM服务端发送标准的请求,并且按照CIM的标准操作服务端对象,从而执行某项管理职能。

    看到了吧,就是这个CIM-XML,它替代了XMLRPC和SOAP的位置,负责将客户端的动作转换为具体的向服务器端的请求。简单的说呢,就是一系列的Web Service接口。只不过不同的地方是,CIM又定义了这些接口的使用方式,使得即使你对这些接口完全一无所知,也没有WSDL,就可以使用这些接口,因为他们都是符合CIM标准的。

    问题是CIM-XML既不是XMLRPC,也不是SOAP,很难知道DMTF当初为何要重新发明轮子,也不知道究竟是CIM-XML早还是SOAP或者XMLRPC早。在我看来,如果他们能够统一,该多好。。。。。。

    现在就面临一个选择,究竟是SOAP呢?还是CIM-XML?CIM-XML到底有多少前途呢?

    现在怀疑WBEM有废弃CIM-XML,向Web Service转移的可能,因为我发现了这么两个事实:

    其一,WBEM最新产生了一个名为WS-Management的标准。WS即为Web Service的简称。我没有仔细看这么一个标准,因为其中满是技术细节,我现在还不需要了解。但是这两份于06年8月刚刚产生的,还未正式发布的标准定义了如何将CIM绑定到WS上,并且如何通过WSDL解释。这是否预示着CIM开始发现重复发明轮子的坏处,开始向主流的WS靠拢?

    其二,我在网络上搜索到了一封邮件,是2000年某人发给xml-dist-app@w3.org的信。我不知道这位作者Frederick B. Kintanar(fred@ntsp.nec.co.jp)的来历,但是他写给标准化组织W3C的这封信恰恰表明了,早在2000年,这位日本人(猜测)就已经发现了我现在担忧的问题。他提出将xmlCIM(可以认为和CIM-XML同等)列入W3C的一个XML相关技术的表格,并且在信中提到完全可以将SOAP中的信体替换为CIM的标准,从而用SOAP替代xmlCIM。下面是原信:

xmlCIM over HTTP

From: Frederick B. Kintanar <fred@ntsp.nec.co.jp>

Date: Tue, 8 Aug 2000 15:42:32 +0800

Message-ID: <000501c0010c$36ab3880$5c3b1cac@ntsp.nec.co.jp>

To: <xml-dist-app@w3.org>

I was looking at the survey of XML protocol techniques at

http://www.w3.org/2000/03/29-XML-protocol-matrix
.

I think it would be relevant to include the HTTP Messaging

incorporated into xmlCIM, the XML encoding of 

the Common Information Model (CIM), being developed

by Distributed Management Task Force (DMTF) as part

of the Web Based Enterprise Management (WBEM)

initiative.

http://www.dmtf.org/spec/wbem.html


 

Microsoft has incorporated CIM into its implementation 

of Windows Management Instrumentation, and I'm sure 

it would be easy to use SOAP instead of the xmlCIM 

<message> elements to carry CIM declarations.  I don't 

 know  whether a standard way to do this will emerge, and

how CIM and WBEM might eventually support a standard 

XML protocol.


 

CIM is also related to Directory Enabled Networking and 

LDAP, so their experiences interacting with directory services 

may also be of interest to W3C.


 

Cheers,

Fred Kintanar

NEC Telecom Software Philippines

Cebu City

Received on Wednesday, 9 August 2000 03:42:53 GMT

    如上两个因素能否看出WBEM有WS的趋势还不能下定论,但我总是希望朝前看些。结合SOA目前在MS和IBM的推动下已经蓬勃发展如此,很难相信CIM-XML可以取代之。现在有WMI和sblim分别在WIN和Linux平台下实现了CIM,WBEM端的很多工具也已经成型。事态还是需要发展的,需要慢慢来才能逐渐明朗。但我希望冒冒险,在现在这个阶段就预言CIM和WBEM向WS的转移,你赞同吗?

2007年3月12日星期一

CIM、WBEM、SMI-S。。。。。。

头痛,面对一堆的概念还有E文Spec,看的脑袋发胀。之前的两个星期一直是在做Development,感觉状态还好,所以非常相信自己的实力。这个星期开始搞一些conceptual的,读了一上午便有些体力不支了。

看来现在写Code倒变成了习惯,几乎不动脑子,哪怕是刚接触的新领域,玩着闹着就搞定了。看来还有一些比Coding更加logistic的东东,脑力消耗太大,受不了了~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

不理解DMTF的家伙们到底在做什么,眼看着SOAP大行其道,满城尽是SOAer,偏偏搞出一个CMI-XML来,原理相同,效果一直,但就是不是一回事。逼得我又得作选择,向左还是向右,天煞的知道。也许DMTF早一些,传说1997就有。但不管怎么说,将来肯定不会是Both,肯定是The Only One。所以你就不得不赌一把。

我倾向于SOAP,理由是我只看未来。

不过CIM也好,最起码有一个标准和规范,底下的小子们还算是听话。JS到没有这么幸运了。想起之前同事在跟我讨论OOJS的情况,想起了两个广泛应用的脚本JS和PHP的面向对象都是那么的差强人意,不由得感叹那帮人都在干什么呢,真是有心替他们干干,进度太慢了,等到黄花菜都凉了。

唠叨着休息一下,继续研究CIM、WBEM、SMI-S。。。。。。

2007年3月8日星期四

什么是PHP中的stdclass()

什么是PHP中的stdclass()

看到有人用这个,不知道为何,找到如下文章解释:

中文的,应用自http://www.stud.uni-karlsruhe.de/~uu5i/blog/index.php?aid=261


 

php的stdClass是什么

简述

这两天看drupal的代码,发现他常用这个类

可是查了整个文件也没找到stdClass的定义。估计是内置对象,查手册。手册上查到了,stdClass是zent保留的一个类。仅此而已?



google中文一查,多是php手册上的统一句话。后来看到maboo中国上有人提这个问题,哪个lang3竟然回答让别人善用资源管理器??太不厚道了。



google查全部语言。总算查到一点信息。

http://forum.mamboserver.com/showthread.php?t=936

原来就是基类。很多php程序员用它来传递一系列变量的值,而同时又懒得去创建一个自己的类。

这个基类只能传递属性,而不能定义方法。因为,一旦类被实列化以后,就不能在添加方法了。

再说的明白一点,这个stdClass就类似于C++里面的structur。你可以用它来存储很多变量属性,但是没有方法。就是这样。

stdClass is a default PHP object.


 

这篇文章还引用到另一篇英文的文章,对stdclass做了详细解释:


 

This might shed some light on the subject: From PHP CookBook



Classes also live in a defined hierarchy. At the top of the chain, there is a generic class. In

PHP, this class is named stdClass, for "standard class." Each class down the line is more

specialized than its parent.



Recipe 7.12 Adding Properties to a Base Object

7.12.1 Problem

You want to create an object and add properties to it, but you don't want to formally define it

as a specific class. This is useful when you have a function that requires an object with certain

properties, such as what's returned from mysql_fetch_object( ) or imap_header( ).

7.12.2 Solution

Use the built-in base class, stdClass:

$pickle = new stdClass;

$pickle->type = 'fullsour';



7.12.3 Discussion

Just as array( ) returns an empty array, creating an object of the type stdClass provides

you with an object without properties or methods.

Like objects belonging to other classes, you can create new object properties, assign them

values, and check those properties:

$guss = new stdClass;

$guss->location = 'Essex';

print "$guss->location\n";

$guss->location = 'Orchard';

print "$guss->location\n";

Essex

Orchard



Methods, however, can't be defined after an object is instantiated.

It is useful to create objects of stdClass when you have a function that takes a generic object, such as one returned from a database fetching function, but you don't want to actually make a database request. For example:



function pc_format_address($obj) {

return "$obj->name <$obj->email>";

}

$sql = "SELECT name, email FROM users WHERE id=$id";

$dbh = mysql_query($sql);

$obj = mysql_fetch_object($dbh);

print pc_format_address($obj);

David Sklar <david@example.com>



The pc_print_address( ) function takes a name and email address and converts it to a format as you might see in the To and From fields in an email program. Here's how to call this function without calling mysql_fetch_object( ):



$obj = new stdClass;

$obj->name = 'Adam Trachtenberg';

$obj->email = 'adam@example.com';

print pc_format_address($obj);

Adam Trachtenberg adam@example.com


 

In case anybody didn't catch it, stdClass is the base php class, form which all other classes are actually extended. This gives the basics of default methods and properties, and is an inherint concept in class type data structures.



The reason you see it so much in mambo is becuase mambo developers have decided to use stdClass type objects as configuration/information repositories instead or parrallel variables or arrays. These objects are used exclusively for run time storage of variables (just for their set and get abilities.)



They actually get quite ugly if you turn your php alerts on (as most of us do when we develop,) as you can see an alert for each call to a variable that has yet to be set.



This is actually a beef of mine here. The use of these empty objects, with attributes set at runtime (as opposed to being declared as a part of the class) generate a few problems:



1) the only bug I've ever found in PHP4 was with respect to refering undeclared object properties which used to trip out php4, and give you an error relating to a completely different bit of code - although that might have required the properties to be returned by reference, I can't rememeber.



2) you can never really see what the object is like/supposed to be like if it isn't set up properly. Similarily the object can never be tested for vailidty before being passed on.



3) all occurences of such objects are completely non-differentiable (sp?) You can't tell if two are meant for the same purpose or if they are for different purposes.



I'm not much of a programmer but I think it would be much better to use a base class defined for this use, which has some understanding of what it stores and can perhaps self-validate and self manage (and print itself out.)



I wrote a php4 object of such a nature which I called a struct. It is an abstracted class, which when extended is told what kind of information it holds. It then spend it's existence setting and retrieving the values it is meant to hold, in essence serving it's purpose an a configuration information repository. In addition it can self-validate ( $obj->isValid(); ), return meta inforamtion on itself and it's variables and .... that's it actually.

Of course my code is made irrelevant by php5 which actually handles the sets and gets much better (but still would require a base abstract class.)



ok - enough of my blab.

2007年3月7日星期三

Zf Controller层的问题解决

Zf Controller层的问题解决

看了近两天的zf的手册,尝试做点东西,没想到卡到了Controller层上,郁闷无助。

    问题现象:

按照zf的要求写好代码,却发现无法用默认的route机制访问。明明写了localhost/index/index,却显示找不到页面。但是如果直接写localhost却一切正常。

解决问题吧?zf的手册再也找不到啥东西了,索性看源代码。源代码都理解了,还是找不到问题,我靠!

没办法,求助Google吧,找到一片tutorail,of zf的,一看才知道,原来是apache的原因。

由于zf的Controller要用到apache的rewrite模块,目的是把所有的对网站的访问都重定向到index.php页面中,也就是所谓的bootStraper。这个功能要通过放置.htaccess文件。我一直以为仅仅需要在httpd.conf中将相关的module前的注释去掉就可以了,所以才郁闷了半天。原来还需要将AllowOverride字段的None(默认值)改成All。仔细看看对该字段的解释吧:

#

# AllowOverride controls what directives may be placed in .htaccess files.

# It can be "All", "None", or any combination of the keywords:

# Options FileInfo AuthConfig Limit

#

真想骂街啊,怎么早没仔细看看呢。。。。。。。

赶紧写下来吧,以便那位兄弟碰到类似的问题搜索Google。

顺便推荐一个有用的tutorail,里面就有这些信息:

http://akrabat.com/2007/03/05/zend-framework-tutorial-for-zf-v08/

2007年3月5日星期一

失败,coofucoo.blogspot.com被人家占用了

失败,coofucoo.blogspot.com被人家占用了

没办法,请大家记住这个coofucoosblog.blogspot.com的地址吧,虽然有些长了点,但还是多少有些意义的。

有机会也可以访问coofucoo.blogspot.com,我竟然被翻译成卡夫卡。我喜欢酷夫酷。: (