You are viewing a plain text version of this content. The canonical link for it is here.
Posted to axis-cvs@ws.apache.org by da...@apache.org on 2006/01/25 11:16:59 UTC
svn commit: r372183 -
/webservices/axis2/trunk/c/test/core/clientapi/test_client.c
Author: damitha
Date: Wed Jan 25 02:16:52 2006
New Revision: 372183
URL: http://svn.apache.org/viewcvs?rev=372183&view=rev
Log:
added options
Modified:
webservices/axis2/trunk/c/test/core/clientapi/test_client.c
Modified: webservices/axis2/trunk/c/test/core/clientapi/test_client.c
URL: http://svn.apache.org/viewcvs/webservices/axis2/trunk/c/test/core/clientapi/test_client.c?rev=372183&r1=372182&r2=372183&view=diff
==============================================================================
--- webservices/axis2/trunk/c/test/core/clientapi/test_client.c (original)
+++ webservices/axis2/trunk/c/test/core/clientapi/test_client.c Wed Jan 25 02:16:52 2006
@@ -7,6 +7,8 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
+#include <unistd.h>
+#include <axis2.h>
void error(char *msg)
{
@@ -16,13 +18,13 @@
int main(int argc, char *argv[])
{
- char *hostname = "localhost";
- char *port = "9090";
- char *filename = "soap_req";
- char* endpoint = "/axis2/services/echo/echo";
- char c;
+ axis2_char_t *hostname = "localhost";
+ axis2_char_t *port = "9090";
+ axis2_char_t *filename = "soap_req";
+ axis2_char_t *endpoint = "/axis2/services/echo/echo";
+ int c;
extern char *optarg;
-
+
while ((c = getopt(argc, argv, ":h:p:f:e:")) != -1)
{
switch(c)
@@ -41,20 +43,22 @@
break;
}
}
-
+
write_to_socket(hostname, port, filename);
return 0;
}
int write_to_socket(char *address, char* port, char* filename)
{
+ axis2_char_t buffer_l[4999];
int sockfd, portno, n, i;
struct sockaddr_in serv_addr;
struct hostent *server;
struct stat buf;
- char *buffer;
+ axis2_char_t *buffer;
+ axis2_char_t tmpstr[10];
int bufsize = 0;
-
+
portno = atoi(port);
sockfd = socket(AF_INET, SOCK_STREAM, 0);
if (sockfd < 0)
@@ -76,27 +80,39 @@
stat(filename, &buf);
bufsize = buf.st_size* sizeof(char);
buffer = (char *) malloc(bufsize);
+ strcpy(buffer_l, "POST /axis2/services/RMInteropService\r\nUser-Agent: Axis/2.0\r\nConnection: Keep-Alive\r\nHost: ");
+ strcat(buffer_l, address);
+ strcat(buffer_l, ":");
+ strcat(buffer_l, port);
+ strcat(buffer_l, "\r\n");
+ strcat(buffer_l, "Content-Length: ");
+ sprintf(tmpstr, "%d", buf.st_size);
+ strcat(buffer_l, tmpstr);
+ strcat(buffer_l, "\r\n");
+ strcat(buffer_l, "application/soap+xml; charset=UTF-8;action=\"http://127.0.0.1:8070/axis2/services/RMInteropService/__OPERATION_OUT_IN__\"");
+ strcat(buffer_l, "\r\n\r\n");
+
int fd = open(filename, O_RDONLY, 0);
if (fd == -1)
{
- printf("can't open file soap_req\n");
+ printf("can't open file %s\n", filename);
return;
}
else
- printf("opened file soap_req\n");
+ printf("opened file %s\n", filename);
+ n = write(sockfd, buffer_l, strlen(buffer_l));
+
while((i = read(fd, buffer, bufsize - 1)) > 0)
{
buffer[i] = '\0';
n = write(sockfd,buffer,strlen(buffer));
- printf("buffer = %s %d...", buffer, i);
if (n < 0)
error("ERROR writing to socket");
}
printf("Done writing to server\n");
-/* bzero(buffer,2000);*/
buffer[0] = '\0';
while((n = read(sockfd, buffer, bufsize -1)) > 0)
@@ -108,5 +124,6 @@
if (n < 0)
error("ERROR reading from socket");
printf("%s\n",buffer);
+ free(buffer);
}