Friday, June 27, 2014

【職場管理】避免說的11句話

圖片來源: Getty Images圖片來源: Getty Images
職場中掙扎求存,空靠一雙手並不夠,還需要一張嘴。口才了得的人,有誰不喜歡?即使不能雄辯滔滔,只要說話時,懂得選擇適當的詞匯,便能提升你的權威性和專業性。美國《Inc.》雜誌一文中,提及11句應避免在職場說的話,若當中有你的「口頭襌」,就要快快戒掉了。


1. 「我這樣說合理嗎?
原本用來確認對方是否理解你的意思,可是實際上,可能讓對方誤會你在質疑自己,並不完全清楚自己的想法似的。專家建議,改說「你有甚麼看法?」比較好。

2. 「這樣不公平!」
雖然美國最新研究顯示,甚麼都要抱怨的人,比個性樂觀的人工作效率更高。抱怨有助抒發情緒,但最好不要在職場說出來。只懂抱怨並不能改變狀況,比起發牢騷,在麻煩的事發生之前,預先想好對策阻止其發生更實際吧。

3. 「我沒有時間」
只要待在職場一段時間,總會試過接到上司派予的「不可能任務」。沒能完成的工作,與其花時間想藉口解釋為甚麼要遲,倒不如為工作設下死線,快手快腳做完更好,反正你總得完成它。

4. 「只是……
很多人喜歡說「只是」,一句「我只是覺得」、「我只是想」,會使人感到你帶著戒心和一絲抱怨、緊張。把這兩個字從你的說話中「刪除」,能讓你的話顯得更具說服力。

5. 「我一周前已發了電郵」
發了電郵不代表任務完成,別人沒回覆,你得主動跟進。溝通需要主動,別因這些問題,令同事受到責罵,破壞彼此關係。

6. 「我討厭……
職場中,和同事聊聊八卦,的確可增進彼此感情。惟羞辱別人或公司業務,只會顯得你很幼稚,禍從口出,更隨時惹來被解僱的危機。

7. 「這不是我的責任」
即使不是你的職責,假如可抽出時間,不妨幫同事一把,突顯你擁有團隊精神。反正事情到最後,若出了壞結果,這個責任大家都要一同承擔。

8.「你應該……
在予以建議時,很多人不奇然地說出「你應該」三個字。不過,這句話或多或少令聽者感到責備的感覺,想表達相同意思,只要稍作修飾,改為說「在未來,我建議你......,聽起來有尊重的感覺,舒服很多。

9. 「我可能是錯的,但是……
第一句就貶低自己,之後接著說的話,說服力也會大打折扣了。人需要謙虛,但過於謙虛的開場白,還是不要說比較好。

10. 「對不起,但是……
有些人習慣以「對不起」作為開場白,但沒頭沒腦的道歉,只會讓人感到煩懨,亦顯得懦弱,必須戒掉

11. 「其實……

有些人喜歡以「其實」作為開場白,就如「其實,你要找的東西就在那裏」、「其實,你可以用這個方法」。講者可能是習慣使然,但聽者卻有種自己做錯事的感覺,「其實」二字把彼此的距離拉遠,最好戒掉它吧


Source: https://hk.finance.yahoo.com/news/%E3%80%90%E8%81%B7%E5%A0%B4%E7%AE%A1%E7%90%86%E3%80%91%E9%81%BF%E5%85%8D%E8%AA%AA%E7%9A%8411%E5%8F%A5%E8%A9%B1-052627525.html

Saturday, May 10, 2014

An Overview of Mobile Debugging Techniques – Part One

An Overview of Mobile Debugging Techniques – Part One

12.10.2013
| 9372 views |
The Mobile Zone is presented by New Relic and Verivo. New Relic is a performance monitoring tool and has a Data Nerd T-Shirt with your name on it if you sign up. Verivo is an enterprise mobile app platform designed to radically simplify the complexities of building, securing and controlling custom enterprise apps.
Working with mobile sites (or hybrid applications via PhoneGap) can be painful at times when you need to debug. Unless you're perfect (and therefore, do not exist, so how are you reading this?), you're going to need to iterate through numerous different builds of your application before you get it just right. In this article, I'm going to look at a few of the options available to developers to help debug their mobile web applications.

An Overview of Mobile Debugging Techniques – PartTwo

Safari Remote Debugging

The first option we'll look at is specific to iOS devices, but can still be useful for debugging in general. In iOS6, Apple introduced a new feature called Safari Remote Debugging. This allows you to use the Safari web browser to debug web applications being run on iOS devices (both iPhones and iPads). This also includes PhoneGap applications. Unfortunately, this option is only available to folks running Mac OS X.
To use this feature, your iOS device must be physically connected to your laptop. Next, you need to enable it (one time) on the device itself. Open the Settings app, go to Safari, and then click the Advanced Menu. Here is a screenshot from an iOS7 device:

Simply enable Web Inspector and this device will be ready for remote debugging. Before continuing on, open up Safari on your device and visit any web page.
Next, open up Safari. If you don't see the Develop menu, go into your Safari preferences, select the Advanced tab, and turn it on there.

In the Develop menu you will see a new menu option that matches the name of your iOS device. (Note that if you have multiple devices connected you will see all of them, including the iOS Simulator if you have that running.)

If you mouse over the device name, you'll see the name of the web page visible in Safari, or a list of URLs if you have multiple tabs opened.

Select the URL and Safari will open up a set of dev tools:
You now have the ability to interact with your mobile Safari directly from the desktop. If you're primarily a Chrome user, the menu options here may not be terribly obvious. (The next version of Safari will be updating the developer tools UI so what you have now may be a bit different.)
Going from left to right, the menu icons are:
  • Resources: This provides roughly the same view as the Elements panel in Chrome's Dev Tools.
  • Storage: This is similar to the Resources panel in Chrome's Dev Tools. Note that unlike Chrome's Dev Tools, the Web Inspector only seems to support cookies and Web SQL databases. Local Storage is missing from the UI. (Although you could use the console to inspect these values.)
  • Instrument: This includes network requests as well as timing data for layout and JavaScript events. This corresponds roughly to the Network, Timeline, and Profiles panel in Chrome.
  • Search: Allows you to search across all the data in the current request - this includes HTML, JavaScript, and CSS source.
  • Issue: Reports on issues found in the current request. You can find similar information in Chrome's Console, but this focused view is pretty handy.
  • Debug: Safari's JavaScript debugger.
  • Breakpoint: Where you set and view breakpoints.
  • Finally, the Console.

Let's take a closer look at the tabs that I think are going to be the most valuable to you in terms of debugging. To be clear, you should be aware of the capabilities in all the different tabs, but for this article we will focus on some of the more important ones.

The Console

The Console tab is hopefully familiar to you already. On the desktop this is where you can find errors and run arbitrary code. This is even more useful for mobile websites. In the screenshot below you can see the console reporting a simple JavaScript error.
As I mentioned above, you can also run code from here as well. This could be useful for manually firing functions or even just checking variables.
Here's a simple example. I've used the console to check the value of navigator.userAgent and run an alert. Notice that it fires on the device (the simulator in this case) itself.


Resources

The Resources tab gives you access to the DOM. As you select code in the panel, you will see it highlighted in real time on the device.

Even more interesting is that you can edit the HTML live on the device. Double clicking on the text of the h1 tag lets us edit and modify it.


Selecting the icons on the upper right hand side give you access to the tag node and style properties. Under the style property menu you can actually modify the design. This is especially helpful on mobile devices. In the example below I've just added a color, but you could play with margins, padding, and size values to try to improve the design of your web site.


Instrument

In the Instrument panel, the network requests are probably the first useful tool you will need. In complex Ajax-based applications, being able to trace and monitor network requests is incredibly helpful.
The first thing you should be aware of though is that network requests that fail.  404s for example, will not show up here. Instead they will show up in the console only. Chrome on the Desktop will show the failed network requests in both the Networks tab and the console.
Let's look at a simple example. I've run a simple Ajax request. Notice how it shows up in the Network panel along with other requests (CSS, JavaScript, etc).


Notice the arrow on the selected row? Clicking it will load the raw result of the request:


Be sure to check the rest of the Instrument panel as the rendering section and JavaScript events could also be incredibly helpful.

The Debugger

The final feature we'll look at is the debugger. This involves a few different aspects of the web inspector. First, in the Resource panel I can select a JavaScript file from my application:
I can then simply click a line to add a breakpoint. I've done so on line 7 below:
Now when I execute this on the device, it will actually pause execution and let you step through the function one step at a time.

Chrome Remote Debugging

For the next portion of this article, we'll focus on Chrome Remote Debugging. As you can probably guess, this is focused on Android devices and the Chrome browser. It is important that you remember that there is a difference between the stock Android browser and Chrome for Android. The debugging supported by Chrome on the desktop is for Chrome on the device. That's probably obvious but don't forget. As of a report from approximately 6 months ago, the stock Android browser was in use around 10 times more than Chrome for Android! Despite that, you can still make use of Chrome Remote debugging.

To begin, you install the ADB extension for Chrome (https://chrome.google.com/webstore/detail/dpngiggdglpdnjdoaefidgiigpemgage). This extension adds a new icon to the upper right hand corner of your Chrome browser:

In this case, I've got an Android device connected already. (Note - unlike the iOS remote debugger, you can't use this feature with the Android emulator.) Clicking on it exposes these options:

Startand Stop ADB refer to the debugging service and as long as it is already started you can just leave it be. View Inspection Targets gives you a list of all connected devices.

Next, on your Android device, open up Chrome, go to Settings, then Advanced, Developer tools, and enable USB Web debugging.

Once you've done that, return to your desktop, select View Inspection Targets, and note how the Desktop Chrome can tell what site you have open on the device. In fact, if you have multiple sites open in different tabs, you can see a list of them on your desktop:
You can see a few options for each tab. Reload and Close do exactly what you would imagine. The interesting option here is Inspect. Clicking Inspect opens a new window with the familiar Chrome Dev Tools UI:
(Blockquote - What is the SchemaDump tab you ask? That's actually an extension I wrote myself. Chrome lets you write extensions that do many things, including extend the built in developer tools. The same extensions that work for my desktop will work for Android as well!)

We won't go over the tabs as the assumption is that most folks are pretty familiar with Chrome already. If not, you can check out this freeDevTools course on CodeSchool.  As you can imagine, the console is connected to the device. Running a command on the desktop will execute on the mobile device.

Also, much like the Safari debugger, you can select DOM items in the Elements panel and see them update live on the device. You can also modify these elements to test out CSS modifications and other changes. (Pardon the lame camera picture but there was no way to select both the device DOM being highlighted and the desktop!)

As you can imagine, Chrome's developer tools are very powerful and familiar to most developers. Having these available to you for testing mobile devices will be incredibly useful!

What's Next?

In this article we focused on the "big boys", iOS and Chrome remote debugging. Certainly there are other mobile platforms out there and other tools available to you. In the next article, we'll discuss two more tools, Adobe's Edge Inspect and Weinre.

An Overview of Mobile Debugging Techniques – PartTwo

This article was commissioned by Intel and the Tizen Mobile Web Development team.

Source: 
http://css.dzone.com/articles/overview-mobile-debugging 

Tuesday, May 6, 2014

手機應用程式開發

圖片來源:Getty Images
今時今日,手機不離身,是現代人的寫照。看影片新聞、聽音樂、玩遊戲、修圖、和朋友聊天,甚至找路看地圖、查字典、買戲票等等,只要一部智能手機,下載一堆應用程式(Apps),全部就能做到。不能否認,我們的生活與Apps已密不可分。若你遇到難題時,腦海經常閃過用Apps能夠解決就好的念頭,你已經具備成為手機程式開發員(Apps Developers)的基本條件了。
手機應用程式開發公司Mtel行政總裁黃明威(Willy),曾為機管局、機鐵、電影院線等製作Apps。他認為,手機程式開發員需要具備基本電腦製作程式的智識外,更重要是要有對Apps的熱愛:「要常常從生活出發,了解自己所需之餘,同時了解世界需要甚麼,將這些想法透過Apps,在生活中實踐出來。要做到這一點,需要熱愛Apps,首先你自己要想用,然後更想推薦予身邊的朋友,以至客戶,才有機會成為一個成功的手機程式開發員。」


 







與潮流鬥快 

Willy笑言,要隨著時代走,更要比時代走得更快、更前,才能夠成功。
開發員除了接受客戶要求,亦要不時向公司作出建議,製作新的手機應用程式。所以,開發員一定要對生活有敏銳觸覺,以及天馬行空的想法。「舉個例說,有同事看到通訊軟件以及網上交友平台,興起用電影、電視截圖代替文字作回覆,引發我們開發一個App,用戶可以將截圖上載及下載轉發,成為截圖圖庫。關鍵在於你要夠快、夠獨特,就有製作一個出色App的條件。」 
Apps下載的市場是全球性的,所以製作Apps的要求及客戶亦來自全球,發展潛力可想而知。在港澳台均設有辦公室的Willy強調,手機應用程式只是其中一個電子訊息傳播的渠道,隨時會改變。手機應用程式大約2008年才出現,之前其公司的程式設計員經歷過Java GamesWallpaper Download,甚至手機鈴聲Download的年代。「要隨著時代走,更要比時代走得更快、更前,才能夠成功。」
要追上社會脈搏,更加要追上手機的變化速度,所製作的Apps要跟得上步伐,手機軟件便要不停更新,令其可以運用到最新的科技,所以手機程式開發員在產品完成前後,亦要日以繼夜不停地作出修改,工時無可避免較一般辦公室工作長,要有心理準備加班是家常便飯。打算入這行,一般而言,由初級手機程式開發員做起,起薪點大約為$13,000。經過23年時間累積經驗,便可晉升為高級手機程式開發員,月薪普遍由$20,000起跳。

進修課程豐儉由人

若然有志投身這一行,卻對電腦程式編寫不太熟識,坊間有不少機構提供進修機會,並以短期課程為主,內容包括相關程式編寫以至介面設計等;學費亦豐儉由人,由一千多元至一萬多元不等,視乎課程內容及教學時數而定。 其實,現時有不少自製Apps的網頁,只需按步驟輸入資料,就能製造出一個App,而且大部分是免費的。想知道自己對這方面是否有天分和興趣,不妨瀏覽一下這類網頁,動腦動手做做看,也是不錯的測試方法。

手機程式開發員的晉升階梯
職位
月薪()
初級手機程式開發員 (0-3年經驗)
$13,000-$15,000
高級手機程式開發員 (4-8經驗)
$20,000-$30,000
手機程式開發組長  (9-10經驗或以上

Monday, April 21, 2014

[Java] JSF - Java Server Faces

TOPIC 
  • JSF concept
  • MVC architecture
  • Navigation Rules
  • XML configuration file 
  • What is backing bean?
  • Life cycle
  • How to do rendering?


What is JSF?

  • JSF stands for Java Server Faces
  • JSF is user interface (UI) framework for Java web applications. By this it means complex components are pre-coded and can be used with ease. 
  • It is event-driven programming model. By that it means that JSF has all necessary code for event handling and component organization. 
  • Application programmers can concentrate on application logic rather sending effort on these issues. 
  • It has component model that enables third-party components to be added like AJAX.



What is required for JSF to get started?


Following things required for JSF:
  • JDK (Java SE Development Kit)
  • JSF 1.2
  • Application Server (Tomcat or any standard application server)
  • Integrated Development Environment (IDE) Ex. Netbeans 5.5, Eclipse 3.2.x, etc.
Once JDK and Application Server is downloaded and configured, one can copy the JSF jar files to JSF project and could just start coding. :-)
If IDE is used, it will make things very smooth and will save your time.




JSF Architecture

JSF was developed using MVC (a.k.a Model View Controller) design pattern so that applications can be scaled better with greater maintainability.
It is driven by Java Community Process (JCP) and has become a standard.

The advantage of JSF is that it has both a Java Web user and interface and a framework that fits well with the MVC.
It provides clean separation between presentation and behavior.
UI (a.k.a User Interface) can be created by page author using reusable UI components and business logic part can be implemented using managed beans.


How the components of JSF are rendered? An Example

In an application add the JSF libraries. Further in the .jsp page one has to add the tag library like:

<%@ taglib uri="http://java.sun.com/jsf/core" prefix="f"%> 

<%@ taglib uri="http://java.sun.com/jsf/html" prefix="h"%>

Or one can try XML style as well:

<?xml version="1.0"?> 
<jsp:root version="2.0" 
xmlns:jsp="http://java.sun.com/JSP/Page" xmlns:f="http://java.sun.com/jsf/core" 
xmlns:h="http://java.sun.com/jsf/html">

Once this is done, one can access the JSF components using the prefix attached. If working with an IDE (a.k.a Integrated Development Environment) one can easily add JSF but when working without them one also has to update/make the faces-config.xml and have to populate the file with classes i.e. Managed Beans between

<faces-config> </faces-config> tags




How to declare the Navigation Rules for JSF?

Navigation rules tells JSF implementation which page to send back to the browser after a form has been submitted. For ex. for a login page, after the login gets successful, it should go to Main page, else to return on the same login page, for that we have to code as:

<navigation-rule>
     <from-view-id>/login.jsp</from-view-id>
     <navigation-case>
          <from-outcome>login</from-outcome>
          <to-view-id>/main.jsp<to-view-id>
     </navigation-case>
 

      <navigation-case>
          <from-outcome>fail</from-outcome>
          <to-view-id>/login.jsp<to-view-id>
     </navigation-case>
</navigation-rule>


from-outcome to be match with action attribute of the command button of the login.jsp as:

<h:commandbutton value="Login" action="login"/>
Secondly, it should also match with the navigation rule in face-config.xml as

face-config.xml
 <managed-bean>
    <managed-bean-name>user</managed-bean-name>
    <managed-bean-class>core.jsf.LoginBean</managed-bean-class>
    <managed-bean-scope>session</managed-bean-scope>
</managed-bean> 

In the UI component, to be declared / used as:


<h:inputText value="#{user.name}"/>
value attribute refers to name property of the user bean.



How do I configure the configuration file?

The configuration file used is our old web.xml, if we use some IDE it will be pretty simple to generate but the contents will be something like below:


<?xml version="e;1.0"e; encoding="e;UTF-8"e;?>
<web-app version="e;2.4"e; xmlns="e;http://java.sun.com/xml/ns/j2ee"e;
xmlns:xsi="e;http://www.w3.org/2001/XMLSchema-instance"e;
xsi:schemaLocation="e;http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"e;>
 

 <context-param> 
    <param-name>com.sun.faces.verifyObjects</param-name>
    <param-value>false</param-value>
</context-param>

<context-param>
     
    <param-name>com.sun.faces.validateXml</param-name>      
    <param-value>true</param-value>
</context-param>

<context-param>
    
    <param-name>javax.faces.STATE_SAVING_METHOD</param-name>      
    <param-value>client</param-value>
</context-param>


<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>     <load-on-startup>1</load-on-startup>
</servlet>


<servlet-mapping>
    
    <servlet-name>Faces Servlet</servlet-name>      
    <url-pattern>/faces/*</url-pattern>
</servlet-mapping>


<session-config>
     
    <session-timeout> 30 </session-timeout>
</session-config>


<welcome-file-list>
     
    <welcome-file> index.jsp </welcome-file>
</welcome-file-list>
</web-app>


The unique thing about this file is ?servlet mapping?. JSF pages are processed by a servlet known to be part of JSF implementation code. In the example above, it has extension of .faces. It would be wrong to point your browser to http://localhost:8080/MyJSF/login.jsp, but it has to be http://localhost:8080/MyJSF/login.faces. If you want that your pages to be with .jsf, it can be done with small modification :-),

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>     <url-pattern>*.jsf</url-pattern>
<servlet-mapping>



How does JSF depict the MVC (Model View Controller) model? 

The data that is manipulated in form or the other is done by model. The data presented to user in one form or the other is done by view. JSF is connects the view and the model. View can be depicted as shown by:


<h:inputText value="#{user.name}"/>
JSF acts as controller by way of action processing done by the user or triggering of an event. For ex.

<h:commandbutton value="Login" action="login"/>
this button event will triggered by the user on Button press, which will invoke the login Bean as stated in the faces-config.xml file.

Hence, it could be summarized as below: User Button Click -> form submission to server ->; invocation (救助) of Bean class ->; result thrown by Bean class caught be navigation rule ->; navigation rule based on action directs to specific page.



How to get current page URL from backing bean?

You can get a reference to the HTTP request object via FacesContext like this:

FacesContext fc = FacesContext.getCurrentInstance();
HttpServletRequest request = (HttpServletRequest) fc.getExternalContext().getRequest();


and then use the normal request methods to obtain path information. Alternatively,

context.getViewRoot().getViewId();
will return you the name of the current JSP (JSF view IDs are basically just JSP path names).



Discuss life cycle in JSF.

The life cycle of a JavaServer Faces page is similar to that of a JSP page: The client makes an HTTP request for the page, and the server responds with the page translated to HTML. However, because of the extra features that JavaServer Faces technology offers, the life cycle provides some additional services to process a page.

JSF application lifecycle consists of six phases which are as follows
  • Restore view phase 
  • Apply request values phase; process events 
  • Process validations phase; process events 
  • Update model values phase; process events 
  • Invoke application phase; process events 
  • Render response phase 

Restore View Phase: 
When a request for a JavaServer Faces page is made, such as when a link or a button is clicked, the JavaServer Faces implementation begins the restore view phase.

Apply Request Values Phase: 
After the component tree is restored, each component in the tree extracts its new value from the request parameters by using its decode method. The value is then stored locally on the component. If the conversion of the value fails, an error message associated with the component is generated and queued on FacesContext. This message will be displayed during the render response phase, along with any validation errors resulting from the process validations phase. '

Process Validations Phase: 
During this phase, the JavaServer Faces implementation processes all validators registered on the components in the tree. It examines the component attributes that specify the rules for the validation and compares these rules to the local value stored for the component.

Update Model Values Phase: 
After the JavaServer Faces implementation determines that the data is valid, it can walk the component tree and set the corresponding server-side object properties to the components' local values. The JavaServer Faces implementation will update only the bean properties pointed at by an input component's value attribute. If the local data cannot be converted to the types specified by the bean properties, the life cycle advances directly to the render response phase so that the page is rerendered with errors displayed. This is similar to what happens with validation errors.

Invoke Application Phase: 
During this phase, the JavaServer Faces implementation handles any application-level events, such as submitting a form or linking to another page.

Render Response Phase: 
During this phase, the JavaServer Faces implementation delegates authority for rendering the page to the JSP container if the application is using JSP pages. If this is an initial request, the components represented on the page will be added to the component tree as the JSP container executes the page. If this is not an initial request, the components are already added to the tree so they needn't be added again. In either case, the components will render themselves as the JSP container traverses the tags in the page.

JSF與Struts雖然都是Web MVC架構的實現,但兩者所偏重的並不相同,Struts著重的是控制物件的設計;JSF則著重於頁面流程的設計,也就是定義在何種條件成立下,上一個頁 面與下一個頁面之間是如何連結,您可以在faces-config.xml中定義頁面流程



Source:
http://www.withoutbook.com/Technology.php?tech=37&page=5&subject=JSF%20Interview%20Questions%20and%20Answers

http://openhome.cc/Gossip/SpringGossip/FirstJSF.html

[Web Technology] Web Service

"网络服务"(Web Service)的本质,就是通过网络调用其他网站的资源
举例来说,去年我写过一个"四川大地震图片墙",它能动态显示关于四川地震的最新图片。但是,所有的图片都不是储存在我的服务器上,而是来自flickr.com。我只是发出一个动态请求,要求flickr.com向我提供图片。这种情况下,flickr.com提供的就是一种Web service。如果我把图片都存放在本地服务器,不调用flickr.com,那么我就是在使用"本地服务"。

所以,Web service让你的网站可以使用其他网站的资源,比如在网页上显示天气、地图、twitter上的最新动态等等。

Web Service架构的基本思想,就是尽量把非核心功能交给其他人去做,自己全力开发核心功能。比如,如果你要开发一个相册软件,完全可以使用Flickr的网络服务,把相片都储存到它上面,你只要全力做好相册本身就可以了。
 

最近很红的"云计算"(cloud computing)或者"云服务"(cloud services),实际上就是Web Service的同义词。

四、Web Service的优势
除了本地服务的缺点以外,Web Service还有以下的优越性:
* 平台无关。不管你使用什么平台,都可以使用Web service。

* 编程语言无关。只要遵守相关协议,就可以使用任意编程语言,向其他网站要求Web service。这大大增加了web service的适用性,降低了对程序员的要求。

* 对于Web service提供者来说,部署、升级和维护Web service都非常单纯,不需要考虑客户端兼容问题,而且一次性就能完成。

* 对于Web service使用者来说,可以轻易实现多种数据、多种服务的聚合(mashup),因此能够做出一些以前根本无法想像的事情。

五、Web service的发展趋势
根据我的观察,目前Web service有这样几种发展趋势。
*在使用方式上,RPC和soap的使用在减少,Restful架构占到了主导地位。
*在数据格式上,XML格式的使用在减少,json等轻量级格式的使用在增多。
*在设计架构上,越来越多的第三方软件让用户在客户端(即浏览器),直接与云端对话,不再使用第三方的服务器进行中转或处理数据。
sdfaf

[Web Services] Web Services XML

Web Services

  • Web services are application components
  • Web services communicate using open protocols
  • Web services are self-contained and self-describing
  • Web services can be used by other applications
  • HTTP and XML is the basis for Web services
  • Web Services can be created regardless of programming language
This tutorial introduces WSDL, SOAP, UDDI, and RDF.

Background of Web Services

WSDL

  • WSDL stands for Web Services Description Language
  • WSDL is an XML-based language for describing Web services.
  • WSDL is a W3C recommendation

SOAP

  • SOAP stands for Simple Object Access Protocol
  • SOAP is an XML based protocol for accessing Web Services.
  • SOAP is based on XML
  • SOAP is a W3C recommendation

UDDI

  • UDDI stands for Universal Description, Discovery and Integration
  • UDDI is a directory service where companies can search for Web services.
  • UDDI is described in WSDL
  • UDDI communicates via SOAP

RDF

  • RDF stands for Resource Description Framework
  • RDF is a framework for describing resources on the web
  • RDF is written in XML
  • RDF is a W3C Recommendation

[Web Service] SOAP & SOAP Connection

<SOAP>

Two vendor-neutral standards for accessing web services are REST and SOAP.
REST - Representational State Transfer.
SOAP - Simple Object Access Protocol.



Introduction
  • Simple Object Access Protocol
  • is a protocol specification for exchanging structured information in the implementation of Web Services in computer networks
  • relies on XML Information Set for its message format, and usually relies on other Application Layer protocols, most notably Hypertext Transfer Protocol (HTTP) or Simple Mail Transfer Protocol (SMTP), for message negotiation and transmission. 
  • is platform independent.
  • is language independent.
  • is simple and extensible.
  • Unlike REST, it's a W3C-recommended protocol for web services.
  • SOAP is most often used with HTTP to take advantage of the existing HTTP framework. This also enables calls to bypass firewalls because they pass on the HTTP port - port 80. However, SOAP can also use TCP.

SOAP Syntax

A SOAP message is an ordinary XML document containing the following elements:
  • An Envelope element that identifies the XML document as a SOAP message
    • is the root element of a SOAP message.
    • This element defines the XML document as a SOAP message.
  • [empty] A Header element that contains header information
    • contains application-specific information (like authentication, payment, etc) about the SOAP message.
    • All immediate child elements of the Header element must be namespace-qualified.
  • A Body element that contains call and response information
    • actual SOAP message
  • [optional] A Fault element containing errors and status information for a SOAP message.
Here are some important syntax rules:
  • A SOAP message MUST be encoded using XML
  • A SOAP message MUST use the SOAP Envelope namespace
  • A SOAP message MUST use the SOAP Encoding namespace
  • A SOAP message must NOT contain a DTD reference
  • A SOAP message must NOT contain XML Processing Instructions
For example,
A SOAP  request
<soap-env:Envelope xmlns:soap-env="http://schemas.xmlsoap.org/soap/envelope/"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">
 <soap-env:Header/>
    <soap-env:Body>
        <cal:schedule xmlns:cal="http://www.example.com/calendar">
            <cal:newitem>
                <cal:eventDate>4/10/2002</cal:eventDate>
                <cal:title>Fun With Frogs</cal:title>
            </cal:newitem>
        </cal:schedule>
    </soap-env:Body>
</soap-env:Envelope>
 

*Notes:
Header element
soap:encodingStyle attribute is optional for SOAP.

Fault element
If a Fault element is present, it must appear as a child element of the Body element. A Fault element can only appear once in a SOAP message.
The SOAP Fault element has the following sub elements:
Sub Element Description
<faultcode> A code for identifying the fault
<faultstring> A human readable explanation of the fault
<faultactor> Information about who caused the fault to happen
<detail>
Holds application specific error information related to the Body element
SOAP Fault Codes The faultcode values defined below must be used in the faultcode element when describing faults:
Error Description
VersionMismatch Found an invalid namespace for the SOAP Envelope element
MustUnderstand An immediate child element of the Header element, with the mustUnderstand attribute set to "1", was not understood
Client The message was incorrectly formed or contained incorrect information
Server There was a problem with the server so the message could not proceed


The HTTP Binding /Protocol 


SOAP Example

A SOAP Request
POST /InStock HTTP/1.1
Host: www.example.org
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPrice>
    <m:StockName>IBM</m:StockName>
  </m:GetStockPrice>
</soap:Body>


</soap:Envelope>


A SOAP Response
HTTP/1.1 200 OK
Content-Type: application/soap+xml; charset=utf-8
Content-Length: nnn

<?xml version="1.0"?>
<soap:Envelope
xmlns:soap="http://www.w3.org/2001/12/soap-envelope"
soap:encodingStyle="http://www.w3.org/2001/12/soap-encoding">

<soap:Body xmlns:m="http://www.example.org/stock">
  <m:GetStockPriceResponse>
    <m:Price>34.5</m:Price>
  </m:GetStockPriceResponse>
</soap:Body>


</soap:Envelope>


<SOAP Connection>

A connection is required to send and receive all SOAP messages. The connection can go to a messaging provider or a particular destination.


The JAXM API provides the class and interface to represent two kinds of connections:

A SOAPConnection is a point-to-point connection for sending messages directly to a remote party.
A SOAPConnection object, which represents a point-to-point connection, is simple to create and use. You do not have to do any configuration to use a SOAPConnection object because it does not need to run in a servlet container (like Tomcat) or in a J2EE server. It is the only way for a client to have a connection without a service provider.

A ProviderConnection object represents a connection to a messaging provider. (The next section explains more about messaging providers.) When you send a message via a ProviderConnection object, the message goes to the messaging provider. The messaging provider forwards the message, following the message's routing instructions, until the message gets to the ultimate recipient's messaging provider, which in turn forwards the message to the ultimate recipient.

A messaging provider keeps track of messages and routes them to the correct destination or destinations. It is a service that handles the transmission and routing of messages.


Reference 
http://www.cnblogs.com/chenying99/archive/2013/05/23/3094128.html

http://www.w3schools.com/Webservices/ws_soap_httpbinding.asp

[Web Technology] jQuery

<jQuery>

Introduction of jQuery

jQuery is a light weight JavaScript library which provides fast and easy way of HTML DOM traversing (穿過) and manipulation (操作,運用), its event handling,its client side animations, etc.
One of the greatest features of jQuery is that jQuery supports an efficient way to implement AJAX applications because of its light weight nature and make normalize and efficient web programs.


Explain the features of jQuery?

Features of jQuery are :

  • Effects and animations
  • Ajax
  • Extensibility
  • DOM element selections functions
  • Events
  • CSS manipulation
  • Utilities - such as browser version and the each function.
  • JavaScript Plugins
  • DOM traversal and modification


Why is jQuery better than JavaScript?

  • jQuery is great library for developing ajax based application
  • It helps the programmers to keep code simple and concise and reusable. 
  • jQuery library simplifies the process of traversal of HTML DOM tree
  • jQuery can also handle events, perform animation, and add the Ajax support in web applications.


How to use jQuery?

jQuery can be easily used with other libraries so it should work out of the box with simple and complex JavaScript and Ajax.



What is jQuery connect?




jQuery Mobile

Basic Page Template 
This framework provides a set of touch-friendly UI widgets and an AJAX-powered navigation system to support animated page 


<!doctype html>
<html>
    <head>     
          <title>My Page</title>         
         <meta name="viewport" content="width=device-width, initial-scale=1">     
         <link rel="stylesheet" href="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.css">         
         <script src="http://code.jquery.com/jquery-1.8.2.min.js"></script>         
         <script src="http://code.jquery.com/mobile/1.2.0/jquery.mobile-1.2.0.min.js"></script>     
    </head>
    <body>     
        <div data-role="page">     
            <div data-role="header">         
            <h1>My Title</h1>     
            </div><!-- /header --> 
 
            <div data-role="content">     
            <p>Hello world</p>     
            </div><!-- /content --> 
     
            <div data-role="footer">         
            <h4>My Footer</h4>         
            </div><!-- /footer --> 
        </div><!-- /page --> 
    </body>
</html>
In the <body>,
a div with a data-role of page is the wrapper used to delineate a page. A header bar (data-role="header"), a content region (data-role="content") and a footer bar (data-role="footer") are added inside to create a basic page (all three are optional). These data- attributes are HTML5 attributes used throughout jQuery Mobile to transform basic markup into an enhanced and styled widget.





Make a ListView
<ul data-role="listview" data-inset="true" data-filter="true">
<li><a href="#">Acura</a></li> 
    <li><a href="#">Audi</a></li>
<li><a href="#">BMW</a></li>
<li><a href="#">Cadillac</a></li>
<li><a href="#">Ferrari</a></li>
</ul>



Add a Slider

<form>
<label for="slider-0">Input slider:</label>
<input type="range" name="slider" id="slider-0" value="25" min="0" max="100" />
</form>
* Notes:
  • Here's a slider made with the new HTML5 input type of range
  • no data-role needed.

Make a Button



Choose a Theme Swatch 



Reference
http://learn.jquery.com

http://www.roseindia.net/ajax/jquery/index.shtml

http://www.w3schools.com/Jquery/default.asp