Return-Path: Delivered-To: apmail-ws-axis-dev-archive@ws.apache.org Received: (qmail 71160 invoked by uid 500); 27 Jul 2003 10:03:36 -0000 Mailing-List: contact axis-dev-help@ws.apache.org; run by ezmlm Precedence: bulk Reply-To: axis-dev@ws.apache.org list-help: list-unsubscribe: list-post: Delivered-To: mailing list axis-dev@ws.apache.org Received: (qmail 71145 invoked by uid 500); 27 Jul 2003 10:03:35 -0000 Delivered-To: apmail-xml-axis-cvs@apache.org Date: 27 Jul 2003 10:03:34 -0000 Message-ID: <20030727100334.16946.qmail@icarus.apache.org> From: sanjaya@apache.org To: xml-axis-cvs@apache.org Subject: cvs commit: xml-axis/c/src/engine Axis.cpp X-Spam-Rating: daedalus.apache.org 1.6.2 0/1000/N sanjaya 2003/07/27 03:03:34 Modified: c/src/engine Axis.cpp Log: added routine to display list of deployed webservices as hyperlinks to their respective wsdls on a GET request Revision Changes Path 1.5 +81 -40 xml-axis/c/src/engine/Axis.cpp Index: Axis.cpp =================================================================== RCS file: /home/cvs/xml-axis/c/src/engine/Axis.cpp,v retrieving revision 1.4 retrieving revision 1.5 diff -u -r1.4 -r1.5 --- Axis.cpp 23 Jul 2003 13:52:16 -0000 1.4 +++ Axis.cpp 27 Jul 2003 10:03:33 -0000 1.5 @@ -4,87 +4,128 @@ #include #include #include "../common/Packet.h" +#include +#include + +#define res(X); send_response_bytes(X); unsigned char chEBuf[1024]; -//17.07.2003 the name process is changed to process_request(soapstream * str) extern "C" int process_request(soapstream *str) { - DEBUG1("in axis.cpp"); +DEBUG1("in axis.cpp"); AxisEngine* engine = AxisEngine::GetAxisEngine(); int ret = FAIL; - //the location of the wsdl hardcoded - char * wsdlloc = "e:\\Axis\\Calculator.wsdl"; - //char pointer to which the wsdl file will be read - char * wsdl = NULL; + char * wsdlloc = NULL; + char * uri = NULL; + int pos=0; + int slashcount=0; + int len = 0; + FILE * outfile; const int bytestoread = 6; char oneword [bytestoread]; oneword[bytestoread-1] = '\0'; + + const WSDDServiceMap * svsmap = NULL; + WSDDServiceMap::const_iterator iter; + WSDDService * svs = NULL; + //the location of the wsdl files hardcoded + string svr("./Axis/wsdl/"); + switch(str->trtype) { case APTHTTP: + //Handle the POST method if(str->so.http.ip_method==POST) { - DEBUG1("method is POST"); if (engine) { ret = engine->Process(str); - DEBUG1("ret = engine->Process(str);"); + DEBUG1("ret = engine->Process(str);"); DEBUG1("are we successful?"); ret = SUCCESS; } } + //Handler the GET method if(str->so.http.ip_method==GET) { -DEBUG1("method is GET"); - if((outfile = fopen(wsdlloc,"r"))==NULL) + //get the uri path + //i.e "/abc/xyz/" part of http://somehost/abc/xyz/ + string sUri = str->so.http.uri_path; + string sUriWOAxis = ""; + string sServiceName; + bool bNoSlash = false; + + if (sUri.find("/axis/") != string::npos) { - send_response_bytes("no wsdl to be found"); - //handle the error - //str->so.http.op_soap = "Error in reading wsdl file"; + sUriWOAxis = sUri.substr(sUri.find("/axis/") + 6); } else + { + bNoSlash = true; + } + if (sUriWOAxis.empty()) + { + svsmap = engine->getWSDDDeployment()->GetWSDDServiceMap(); + //dep = engine->getWSDDDeployment(); + //svsmap = depGetWSDDServiceMap(); + res("\ +

Welcome to Axis C++

\ +
\ +

List of Deployed Web services

\ +

click on the links to view the WSDL

\ +
\ + "); + + for (iter=svsmap->begin();iter!=svsmap->end();iter++) + { + svs = iter->second; + res(""); + res(""); + } + res("
"); + res((char *)svs->GetServiceName().c_str()); + res("GetServiceName().c_str()); + send_response_bytes("?wsdl"); + send_response_bytes("\">wsdl
"); + } + else { - int charcount = 0; - int acc = 0; + sServiceName = "./Axis/wsdl/" + sUriWOAxis + ".wsdl"; + //check whether wsdl file is available + if((outfile = fopen(sServiceName.c_str(),"r"))==NULL) + { + send_response_bytes("

Url not available

"); + //handle the error + } + else + { + int charcount = 0; + int acc = 0; while((charcount=fread(oneword,1,bytestoread-1, outfile)) != 0) { - if(wsdl==NULL) - { - acc += charcount; - wsdl = (char *)realloc(wsdl,acc); - wsdl = strcpy(wsdl,oneword); - } - else - { - wsdl = (char *)realloc(wsdl,acc+charcount); - *(wsdl+(acc))='\0'; - acc += charcount; - wsdl = strncat(wsdl, oneword,charcount); - } - } - //assign the char pointer that contains the - //wsdl file to the response - //str->so.http.op_soap = wsdl; - send_response_bytes("dummy wsdl"); - ret = SUCCESS; - fclose(outfile); - //free (wsdl); + *(oneword+charcount) = '\0'; + send_response_bytes(oneword); + } + ret = SUCCESS; + fclose(outfile); + } } } break; default: - //str->so.http.op_soap = "Unknown protocol"; + send_response_bytes("Unknown Protocol"); break; - } - - //str->op_soap = chEBuf; + svsmap = NULL; + svs =NULL; return ret; }