00001
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #include <stdio.h>
00023 #include <Sockets/XmlDocument.h>
00024 #include <iostream>
00025 #include <Sockets/Exception.h>
00026 #include "Wsdl.h"
00027 #include "WsdlException.h"
00028 #include "Types.h"
00029 #include "Application.h"
00030 #include "ComplexType.h"
00031
00032
00033 void view_wsdl(Application& appl, Wsdl& wsdl)
00034 {
00035 std::string target_ns = wsdl.GetTargetNamespace();
00036 std::string prefix_ns = wsdl.GetTargetNamespacePrefix();
00037 printf("Target Namespace: %s\n", target_ns.c_str());
00038 printf("Target Ns Prefix: %s\n", prefix_ns.c_str());
00039
00040 std::list<std::string> ops = wsdl.GetOperations( appl.Portname() );
00041 printf("Number of operations: %d\n", ops.size());
00042
00043 for (std::list<std::string>::iterator it = ops.begin(); it != ops.end(); it++)
00044 {
00045 std::string op = *it;
00046 printf("%s\n----------------------------------------\n", op.c_str());
00047 printf("SOAPaction: %s\n", wsdl.GetSoapAction(appl.Portname(), op).c_str());
00048 std::string in;
00049 std::string out;
00050 std::string fault;
00051 std::string path;
00052 try {
00053 in = wsdl.GetMessage(appl.Portname(), op, "input");
00054 } catch (const WsdlException&) {}
00055 try {
00056 out = wsdl.GetMessage(appl.Portname(), op, "output");
00057 } catch (const WsdlException&) {}
00058 try {
00059 fault = wsdl.GetMessage(appl.Portname(), op, "fault");
00060 } catch (const WsdlException&) {}
00061 if (!in.empty())
00062 {
00063 printf("Input: %s\n", in.c_str());
00064 wsdl.ShowMessage(in);
00065 }
00066 if (!out.empty())
00067 {
00068 printf("Output: %s\n", out.c_str());
00069 wsdl.ShowMessage(out);
00070 }
00071 if (!fault.empty())
00072 {
00073 printf("Fault: %s\n", fault.c_str());
00074 wsdl.ShowMessage(fault);
00075 }
00076
00077 printf("\n");
00078 }
00079 }
00080
00081
00082 int main(int argc, char *argv[])
00083 {
00084 Application appl(argc, argv);
00085
00086 try
00087 {
00088 Xml::XmlDocument zz(appl.Filename());
00089 Wsdl wsdl(appl, zz);
00090
00091
00092 std::list<std::string> ports = wsdl.GetPorts();
00093 if (ports.size() > 1)
00094 {
00095 bool ok = false;
00096 for (std::list<std::string>::iterator it = ports.begin(); it != ports.end(); it++)
00097 if (appl.Portname() == *it)
00098 ok = true;
00099 if (!ok)
00100 {
00101 if (!appl.Portname().empty())
00102 printf("Port name not found: \"%s\"\n", appl.Portname().c_str());
00103 printf("Select one of these ports:\n");
00104 for (std::list<std::string>::iterator it = ports.begin(); it != ports.end(); it++)
00105 printf(" %s\n", it -> c_str());
00106 return -1;
00107 }
00108 }
00109
00110
00111 wsdl.CreateInterface();
00112 wsdl.CreateImplementation();
00113
00114 {
00115 view_wsdl(appl, wsdl);
00116 return 0;
00117 }
00118
00119
00120 Types t(appl, wsdl);
00121 t.generate();
00122
00123 }
00124 catch (const Exception& e)
00125 {
00126 std::cout << "---------------------------------------------" << std::endl;
00127 std::cout << e.ToString() << std::endl;
00128 std::cout << "---------------------------------------------" << std::endl;
00129 std::cout << e.Stack() << std::endl;
00130 }
00131
00132 ComplexType::ShowGenerated();
00133 return 0;
00134 }
00135
00136