#include <stdio.h>
#include "atmi.h"
int main(int argc, char ?argv[])
{
char ?buf;
long len;
if(argc != 2) {
(void) fprintf(stderr, "Usage: simpcl string\n");
exit(1);
}//if argc
//初始化连接
if (tpinit((TPINIT ?) NULL) == -1) {
(void) fprintf(stderr, "Tpinit failed\n");
exit(1);
}//if tpinit
len = strlen(argv[1]);
if((buf = (char ?) tpalloc("STRING", NULL, len+1)) == NULL) {
(void) fprintf(stderr,"Error allocating send buffer\n");
tpterm();
exit(1);
}
//赋值
(void) strcpy(buf, argv[1]);
//调用服务
if(tpcall("TOUPPER", buf, 0, &&buf, &&len, 0)==-1){
(void) fprintf(stderr, "Can't send request to service TOUPPER\n");
tpfree(buf);
tpterm();
exit(3);
}
(void) fprintf(stdout, "Returned string is: %s\n", rcvbuf);
tpfree(buf);
tpterm();
return(0);
}
像这种例子都是只给TUXEDO服务传一个参数的,那如果我需要给服务传很多参数怎么办,比如,我需要给ITF_GETCSTINFO这样一个服务传客户的姓名、性别、年龄等,我该如何传呢?谢谢
这里没有专门的TUXEDO论坛,只好发到ORACLE了,时间紧急,知道的请务必讲一下,谢谢
------解决方案--------------------------------------------------------
传多个参数就用结构啊,tpalloc的时候用FML32格式,比如:
- C/C++ code
char SendBuf[1024*3]; FBFR32 *send, *rcv; long rcvLen; int ret; if (tpinit((TPINIT *) NULL) == -1) { (void) fprintf(stderr, "Tpinit failed\n"); exit(1); } if ((send=(FBFR32 *)tpalloc("FML32",NULL,1024*1024*2))==NULL) { printf("tpalloc error!\n"); return 0; } if ((rcv=(FBFR32 *)tpalloc("FML32",NULL,10000))==NULL) { printf("Error allocating receive buffer\n"); tpfree((char *)send); tpterm(); exit(1); }...... memcpy((void *)SendBuf,(void *)&a_struct_variable,sizeof(QueryReqStruc)); Fadd32(send, THE_FIELDID, (char *)&a_struct_variable, sizeof(The_struct)); ret = tpcall("servicename", (char *)send, 0, (char **)&rcv, &rcvLen, (long)0); if(ret == -1) { .......