wsdl2cpp.cpp File Reference

#include <stdio.h>
#include <Sockets/XmlDocument.h>
#include <iostream>
#include <Sockets/Exception.h>
#include "Wsdl.h"
#include "WsdlException.h"
#include "Types.h"
#include "Application.h"
#include "ComplexType.h"

Include dependency graph for wsdl2cpp.cpp:

Go to the source code of this file.

Functions

void view_wsdl (Application &appl, Wsdl &wsdl)
int main (int argc, char *argv[])


Detailed Description

Date:
2008-05-26
Author:
grymse@alhem.net

Definition in file wsdl2cpp.cpp.


Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 82 of file wsdl2cpp.cpp.

References Application::Filename(), Types::generate(), Application::Portname(), ComplexType::ShowGenerated(), and view_wsdl().

00083 {
00084         Application appl(argc, argv); // parse command line
00085 
00086         try
00087         {
00088                 Xml::XmlDocument zz(appl.Filename()); //"http://schemas.xmlsoap.org/wsdl/http/", "definitions");
00089                 Wsdl wsdl(appl, zz);
00090 
00091                 // select port
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                 // generate types
00111                 wsdl.CreateInterface();
00112                 wsdl.CreateImplementation();
00113 
00114                 {
00115                         view_wsdl(appl, wsdl);
00116                         return 0;
00117                 }
00118 
00119                 // operations...
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 }

void view_wsdl ( Application appl,
Wsdl wsdl 
)

Definition at line 33 of file wsdl2cpp.cpp.

References Wsdl::GetMessage(), Wsdl::GetOperations(), Wsdl::GetSoapAction(), Wsdl::GetTargetNamespace(), Wsdl::GetTargetNamespacePrefix(), Application::Portname(), and Wsdl::ShowMessage().

Referenced by main().

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 }


Generated on Sun Oct 11 10:57:20 2009 for Xml Schema class generator by  doxygen 1.5.5