07.11.07
layman’s question: what does 64-bit mean?
To put it in a simplistic way, it just means larger address space. In the other word, more addresses become POSSIBLE to be identified with a pointer. It is like if we have 8-digit phone numbers, it becomes POSSIBLE to have more phone numbers in one area code. It gives more flexibility but does not really mean that the phone company can handle more numbers.
Here is the fun part – numbers:
2^5 = 32
2^10 = 1024. That is 1K.
2^16 = 1024*64. That is 64K.
2^32 = 64K*64K = 4* 2^10 * 2^10 * 2^10 = 4 K *K *K = 4G = 4096 M
2^64 = 4G*4G = 16 Exabyte. Are you sure that is a word? 16 EB.
1 GB is 2^30 and 1 EB is 2^60. 1 terabyte (TB) is only 2^40.
07.10.07
A “Hello World” Axis2 web service
1. “Hello World”
We only need two files:
[a] HappyPojo.java – the class/file name is arbitrary here.
public class HappyPojo {
public String helloThere() {
return “Hello, world!”;
}
}
[b] services.xml – this file name is required, I think.
<service name=”HappyPojoService”>
<messageReceivers>
<messageReceiver
mep=”http://www.w3.org/2004/08/wsdl/in-out”
class=”org.apache.axis2.rpc.receivers.RPCMessageReceiver”/>
</messageReceivers>
<parameter name=”ServiceClass”>
HappyPojo
</parameter>
</service>
2. setting up
[1] Install Axis2 – meaning axis2.war file or the class directory needs to be under the webapps directory of your servlet engine.
[2] Compile the java file to get a HappyPojo.class. Put HappyPojo.class under services directory of Axis installation described in [1].
[3] Put services.xml under META-INF under the services directory.
3. try it
Type something like “https://localhost:8443/services/HappyPojoService/helloThere” in the browser address bar. You get a XMl response as following:
- <ns:helloThereResponse xmlns:ns=”http://ws.apache.org/axis2/xsd”>
<ns:return>Hello, world!</ns:return>
</ns:helloThereResponse>
Type “https://localhost:8443/services/HappyPojoService?wsdl” in address bar, you get XML response as following:
- <wsdl:definitions xmlns:axis2=”http://ws.apache.org/axis2″ xmlns:mime=”http://schemas.xmlsoap.org/wsdl/mime/” xmlns:ns0=”http://ws.apache.org/axis2/xsd” xmlns:soap12=”http://schemas.xmlsoap.org/wsdl/soap12/” xmlns:http=”http://schemas.xmlsoap.org/wsdl/http/” xmlns:ns1=”http://org.apache.axis2/xsd” xmlns:xs=”http://www.w3.org/2001/XMLSchema” xmlns:soap=”http://schemas.xmlsoap.org/wsdl/soap/” xmlns:wsdl=”http://schemas.xmlsoap.org/wsdl/” targetNamespace=”http://ws.apache.org/axis2″>
<wsdl:documentation>HappyPojoService</wsdl:documentation>
- <wsdl:types>
- <xs:schema xmlns:ns=”http://ws.apache.org/axis2/xsd” attributeFormDefault=”qualified” elementFormDefault=”qualified” targetNamespace=”http://ws.apache.org/axis2/xsd”>
- <xs:element name=”helloThereResponse”>
- <xs:complexType>
- <xs:sequence>
<xs:element name=”return” nillable=”true” type=”xs:string” />
</xs:sequence>
</xs:complexType>
</xs:element>
</xs:schema>
</wsdl:types>
<wsdl:message name=”helloThereMessage” />
- <wsdl:message name=”helloThereResponse”>
<wsdl:part name=”part1″ element=”ns0:helloThereResponse” />
</wsdl:message>
- <wsdl:portType name=”HappyPojoServicePortType”>
- <wsdl:operation name=”helloThere”>
<wsdl:input xmlns:wsaw=”http://www.w3.org/2006/05/addressing/wsdl” message=”axis2:helloThereMessage” wsaw:Action=”urn:helloThere” />
<wsdl:output message=”axis2:helloThereResponse” />
</wsdl:operation>
</wsdl:portType>
- <wsdl:binding name=”HappyPojoServiceSOAP11Binding” type=”axis2:HappyPojoServicePortType”>
<soap:binding transport=”http://schemas.xmlsoap.org/soap/http” style=”document” />
- <wsdl:operation name=”helloThere”>
<soap:operation soapAction=”urn:helloThere” style=”document” />
- <wsdl:input>
<soap:body use=”literal” />
</wsdl:input>
- <wsdl:output>
<soap:body use=”literal” />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name=”HappyPojoServiceSOAP12Binding” type=”axis2:HappyPojoServicePortType”>
<soap12:binding transport=”http://schemas.xmlsoap.org/soap/http” style=”document” />
- <wsdl:operation name=”helloThere”>
<soap12:operation soapAction=”urn:helloThere” style=”document” />
- <wsdl:input>
<soap12:body use=”literal” />
</wsdl:input>
- <wsdl:output>
<soap12:body use=”literal” />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:binding name=”HappyPojoServiceHttpBinding” type=”axis2:HappyPojoServicePortType”>
<http:binding verb=”POST” />
- <wsdl:operation name=”helloThere”>
<http:operation location=”helloThere” />
- <wsdl:input>
<mime:content type=”text/xml” />
</wsdl:input>
- <wsdl:output>
<mime:content type=”text/xml” />
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
- <wsdl:service name=”HappyPojoService”>
- <wsdl:port name=”HappyPojoServiceSOAP11port_https” binding=”axis2:HappyPojoServiceSOAP11Binding”>
<soap:address location=”https://169.198.12.54:8443//services/HappyPojoService” />
</wsdl:port>
- <wsdl:port name=”HappyPojoServiceSOAP11port_http1″ binding=”axis2:HappyPojoServiceSOAP11Binding”>
<soap:address location=”http://169.198.12.54:8080//services/HappyPojoService” />
</wsdl:port>
- <wsdl:port name=”HappyPojoServiceSOAP12port_https” binding=”axis2:HappyPojoServiceSOAP12Binding”>
<soap12:address location=”https://169.198.12.54:8443//services/HappyPojoService” />
</wsdl:port>
- <wsdl:port name=”HappyPojoServiceSOAP12port_http1″ binding=”axis2:HappyPojoServiceSOAP12Binding”>
<soap12:address location=”http://169.198.12.54:8080//services/HappyPojoService” />
</wsdl:port>
- <wsdl:port name=”HappyPojoServiceHttpport” binding=”axis2:HappyPojoServiceHttpBinding”>
<http:address location=”https://169.198.12.54:8443//services/HappyPojoService” />
</wsdl:port>
- <wsdl:port name=”HappyPojoServiceHttpport1″ binding=”axis2:HappyPojoServiceHttpBinding”>
<http:address location=”http://169.198.12.54:8080//services/HappyPojoService” />
</wsdl:port>
</wsdl:service>
</wsdl:definitions>
4. more stories behind
A more realistic but still simple tutorial can be found at
http://ws.apache.org/axis2/1_2/quickstartguide.html
The above “Hello World” example is started from there.
I used tomcat+eclipse to test this, but I believe this will work for different settings of servlet container. In my setting, the the core of Axis installation is the jar files (many, including axis2-kernel-1.2.jar, with other necessary libraries) under {$project_directory}\WebContent\WEB-INF\lib. Other than that, Axis installation includes: directory axis2-web at the same level with WEB-INF; directories conf, services, and file web.xml under WEB-INF. conf has a file axis.xml in it; services has the implementation of our web services in it.
Under directory services, each web services is in the form of either an arr file ot a folder. Although the “quick start guide” said the folder should be of the same name as the service, my experiments showed it is not necessary – I intentionally leave it different, as “Test”, in the above “Hello World” example.
07.07.07
hello world of Windows programming
#include <windows.h>
HRESULT CALLBACK wndProc(HWND, UINT, WPARAM, LPARAM);
INT WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevious, LPTSTR cmd, int n) {
HWND hWnd;
HRESULT hRet;
MSG msg;
WNDCLASSEX wndCls;
wndCls.cbSize = sizeof(WNDCLASSEX);
wndCls.cbClsExtra = 0;
wndCls.cbWndExtra = 0;
wndCls.hInstance = hInstance;
wndCls.lpfnWndProc = wndProc;
wndCls.hIcon = LoadIcon(NULL, IDI_APPLICATION);
wndCls.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
wndCls.hCursor = LoadCursor(NULL, IDC_ARROW);
wndCls.lpszClassName = “Try Again”;
wndCls.lpszMenuName = NULL;
wndCls.hbrBackground = (HBRUSH)GetStockObject(WHITE_BRUSH);
wndCls.style = CS_VREDRAW | CS_HREDRAW;
RegisterClassEx(&wndCls);
hWnd = CreateWindow(“Try Again”,
“hello world!”,
WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL
);
if(!hWnd) {
return 1;
}
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
while( (hRet=GetMessage(&msg, NULL, 0, 0))!=0) {
if(hRet==-1) return 1;
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return 0;
}
HRESULT CALLBACK wndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
switch(msg) {
case WM_DESTROY:
PostQuitMessage(WM_QUIT);
return 0;
default:
return DefWindowProc(hWnd, msg, wParam, lParam);
}
}