posts - 17,  comments - 2,  trackbacks - 0
  2009年3月28日
October 09

gSoap: How to add info to SOAP Header using gSOAP

gSoap: How to add info to SOAP Header using gSOAP
There's some misleading info in gSOAP's official documents in SOAP Header Processing Part. 
This article leads you to the right way and can make your program work.
The use case is: 
Client needs to pass user name and password to Server Side to get authenticated.
The username and password info should be embeded in SOAP Header.
Steps:
1. Edit struct SOAP_ENV__Header in soapStub.h file which is generated by gSOAP's soapcpp2 compiler
Add the neccesary info to this struct 
For example:
The original one is:
struct SOAP_ENV__Header
{
public:
 void *dummy; /* transient */
};
This should be changed to:
struct SOAP_ENV__Header
{
public:
 void *dummy; /* transient */
 char *username;
 char *password;
};
2.  Edit function soap_out_SOAP_ENV__Header in soapC.cpp file which is also generated by gSOAP
Add statements to serialize those info into SOAP Header.
For example:
The original one is:
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
{
    soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type);
    /* transient dummy skipped */
    soap_element_end_out(soap, tag);
    return SOAP_OK;
}
This could be changed to:
SOAP_FMAC3 int SOAP_FMAC4 soap_out_SOAP_ENV__Header(struct soap *soap, const char *tag, int id, const struct SOAP_ENV__Header *a, const char *type)
{
    soap_element_begin_out(soap, tag, soap_embedded_id(soap, id, a, SOAP_TYPE_SOAP_ENV__Header), type);
    /* transient dummy skipped */
    soap_out_string(soap, "headerNS:username", 1, &(a->username), "");
    soap_out_string(soap, "headerNS:password", 2, &(a->password), "");
    soap_element_end_out(soap, tag);
    return SOAP_OK;
}
3. Add the namespace mapping to namespaces array in .nsmap file.
 {"headerNS", "http://customeheader.test.com", NULL, NULL},
 
4. Set the header before invoking Web Service Method. This part you can also refer to the gSOAP's official documenthttp://www.cs.fsu.edu/~engelen/soapdoc2.html#tth_sEc12.
   struct soap soap; 
   soap_init(&soap);  
...
    soap->header = (SOAP_ENV__Header *)soap_malloc(soap, sizeof(SOAP_ENV__Header));
    soap->header->username = (char*)malloc(MAX_NAME_SIZE * sizeof(char));
    soap->header->password = (char*)malloc(MAX_NAME_SIZE * sizeof(char));
    strcpy(soap->header->username, username);
    strcpy(soap->header->password, passwd);
    soap_call_method(&soap, ...);  //the SOAP Header will be in the request
...
5. Compile
6. Run. 
The SOAP Message could be
... 
<SOAP-ENV:Envelope xmlns:headerNS="
http://customeheader.vpamws.com">
<SOAP-ENV:Header>
<headerNS:username>admin</headerNS:username>
<headerNS:password>default</headerNS:password>
</SOAP-ENV:Header>
<SOAP-ENV:Body> 
... 
</SOAP-ENV:Body> 
</SOAP-ENV:Envelope>
 
Any Questions, Please let me know. Thanks.
 
-Debora
posted @ 2009-03-28 15:29 BeyondCN 阅读(1168) | 评论 (0)编辑 收藏
  2009年3月21日

1.subst.exe焕发青春 
subst.exe是一个不太常用的DOS命令,它的位置隐藏在\Windows\Command\下(针对Windows 9X/Me系统),如果是Windows 2000/XP,则应该隐藏在\Windows\System32\下,前者的大小为17.6KB,后者的大小更小一些,才9.0KB而已。 
subst.exe的完整名称是“给目录赋驱动器符命令”,它的功能是以磁盘驱动器号代替路径名称,以使驱动器号与指定的子目录路径关联,其命令格式很简单: 
subst.exe [Driver1: [Driver2:] Path] 
其中的“Driver1”是指定指派路径的虚拟驱动器盘符,“Driver2 Path”则是指定物理驱动器和要指派给虚拟驱动器的路径。 
2.利用subst.exe虚拟软驱 
例如,在安装瑞星杀毒软件前,你可以先通过其他方式(例如局域网、邮件、共享文件)将A盘的所有文件复制到本机的一个文件夹中,例如D:\temp下。然后在命令提示符窗口下键入如下命令“subst A: D:\temp”,如图1所示,朋友们可以看一看这里用“dir A:”命令后的文件列表,就知道一张软盘中是绝不可能放入如此之多的东东的。这样,我们就可以按照这种方法将D:\temp文件夹虚拟成A盘,瑞星杀毒软件的安装就可以顺利完成了。 
当我们虚拟软驱后,你会发觉软驱的图标已经变成了图2所示的硬盘图标,当然双击打开后就是D:\Temp文件夹中的内容。 
3.删除虚拟软驱 
如果你要删除这个虚拟出来的A盘,只要执行“subst A:/D”命令就行了,切记工作结束后一定要及时删除这个虚拟出来的A盘,否则无法正常使用原来的物理A盘哟。 
有些软件只能在软盘上运行,这是软件开发者的特别设计,主要目的是为了防止非法拷贝。不过,我们可以先通过HD-COPY工具将软盘做成一个扩展名为img的镜像文件存放在硬盘上的某个文件夹中,然后利用IMGDRIVE、UNDISK等工具软件将该镜像文件展开,这样就可以在硬盘上创建一个虚拟软盘,自然也就可以正常运行了,不过如果是加密的软件,则无法通过这种方法正常运行。

posted @ 2009-03-21 13:18 BeyondCN 阅读(568) | 评论 (0)编辑 收藏
  2009年3月19日

Sector, Boot Sector, Track, Cluster, Bad Sector, Lost Cluster

Sector, Track and Cluster

Sector, Track and Cluster

A Sector in the context of computing refers to a small area of a storage device, for example a hard disk drive. 
For more detailed information please see below.
spr
AddThisThis page is © Copyright 2001-2008 helpwithpcs.com
spr

Sector, Track and Cluster continued...

A typical hard disk drive when low-level formatted is split into tracks, sectors and clusters:
  • Tracks are concentric circles around the disk.
  • Sectors are segments of a track.
  • Clusters are a set of sectors.

Sector, track and cluster example
In the example on the left in fig 1.1 we have only illustrated one track, one sector and one cluster, but you can see where the other tracks, sectors and clusters would reside. 

A typical hard drive may have 30 or more tracks, and 10 or more sectors per track. 

The size of a cluster will vary depending on the size of the partition.

Bad Sector

A bad sector refers to a single sector that has some physical flaw. Although a disk can operate with a bad sector, any data that was stored in that sector will be lost, further, no data can be written to that sector. 

Lost Cluster

A lost cluster is a cluster that the operating system has classed as being in use, but actually contains no data. The ScanDisk utility within Windows is designed to search for lost clusters and make them available to the file system again. 

The Boot Process and the boot sector

Boot sector refers to a single sector (normally the first in the active partition) that contains the code to boot the operating system. 

Before the boot sector is read, the computer's bios will call a small program called an MBR (Master Boot Record), which normally resides in the first record of the first disk. 

The MBR will query the FAT (File Allocation Table) to establish the primary partition and then pass control over to the boot sector of that partition. 

The small program stored in the boot sector is then executed and the operating system will begin to load.
spr
posted @ 2009-03-19 10:20 BeyondCN 阅读(497) | 评论 (0)编辑 收藏
  2008年11月14日
     摘要:   阅读全文
posted @ 2008-11-14 11:40 BeyondCN 阅读(1010) | 评论 (0)编辑 收藏
  2008年11月8日
     摘要:   阅读全文
posted @ 2008-11-08 13:26 BeyondCN 阅读(859) | 评论 (0)编辑 收藏
  2008年11月7日
     摘要:   阅读全文
posted @ 2008-11-07 00:24 BeyondCN 阅读(226) | 评论 (0)编辑 收藏
  2008年11月6日
     摘要:   阅读全文
posted @ 2008-11-06 23:29 BeyondCN 阅读(524) | 评论 (0)编辑 收藏
     摘要:   阅读全文
posted @ 2008-11-06 17:31 BeyondCN 阅读(4538) | 评论 (1)编辑 收藏
  2008年11月3日
     摘要: 在 .Net 中实现自定义事件   .Net 中的自定义事件,其实是利用委托实现,大概可以分为以下几个步骤:1、定义事件传送的 EventArgs ,当然也可以直接使用系统的 EventArgs。2、定义该事件类型的委托。3、定义事件的处理方法。4、在需要的地方抛出事件,抛出的事件会在外部被捕捉到。我们以一个简单的计算程序为例讲解,该程序实现计算两个给定数字的和,当结果<=100时...  阅读全文
posted @ 2008-11-03 00:58 BeyondCN 阅读(502) | 评论 (0)编辑 收藏
     摘要:  使用Delegate类型设计自定义事件作者:罗会涛    在C#编程中,除了Method和Property,任何Class都可以有自己的事件(Event)。定义和使用自定义事件的步骤如下: (1)在Class之外定义一个delegate类型,用于确定事件程序的接口   (2)在Class内部,声明一个public e...  阅读全文
posted @ 2008-11-03 00:55 BeyondCN 阅读(589) | 评论 (0)编辑 收藏
仅列出标题  下一页