Exemplo n.º 1
0
int wsdl__import::traverse(wsdl__definitions& definitions)
{ if (vflag)
    cerr << "wsdl import" << endl;
  definitionsRef = NULL;
  if (location)
  { // parse imported definitions
    definitionsRef = new wsdl__definitions(definitions.soap, location);
    if (!definitionsRef)
      return SOAP_EOF;
    if (namespace_)
      if (strcmp(namespace_, definitionsRef->targetNamespace))
        cerr << "Import " << location << " namespace " << namespace_ << " does not match imported targetNamespace " << definitionsRef->targetNamespace << endl;
    // merge <types>
    if (definitionsRef->types)
    { if (definitions.types)
      { // import schemas
	/* Removed: now handled by xs__schema::traverse()
        for (vector<xs__schema>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
        { for (vector<xs__schema>::iterator importschema = definitionsRef->types->xs__schema_.begin(); importschema != definitionsRef->types->xs__schema_.end(); ++importschema)
	  { xs__import *import = new xs__import();
	    if (vflag)
	      cerr << "Importing schema " << (*importschema).targetNamespace << endl;
	    import->namespace_ = (*importschema).targetNamespace; // the schemaRef pointer will be set when traversing <types>
            (*schema).import.push_back(*import);
	  }
	}
	*/
        // merge <types>, check for duplicates
        for (vector<xs__schema*>::const_iterator importschema = definitionsRef->types->xs__schema_.begin(); importschema != definitionsRef->types->xs__schema_.end(); ++importschema)
	{ bool found = false;
	  for (vector<xs__schema*>::const_iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
	  { if (!strcmp((*importschema)->targetNamespace, (*schema)->targetNamespace))
	    { found = true;
	      break;
	    }
	  }
	  if (!found)
	    definitions.types->xs__schema_.push_back(*importschema);
	}
      }
      else
        definitions.types = definitionsRef->types;
    }
    // combine sets of builtin types, elements, and attributes
    definitions.builtinTypes(definitionsRef->builtinTypes());
    definitions.builtinElements(definitionsRef->builtinElements());
    definitions.builtinAttributes(definitionsRef->builtinAttributes());
  }
  return SOAP_OK;
}
Exemplo n.º 2
0
int wsoap__header::traverse(wsdl__definitions& definitions)
{   if (vflag)
        cerr << "    Analyzing soap header in wsdl namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
    elementRef = NULL;
    // WSDL 2.0
    if (element)
    {   if (definitions.types)
        {   for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
            {   const char *token = qname_token(element, (*schema)->targetNamespace);
                if (token)
                {   for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
                    {   if ((*element).name && !strcmp((*element).name, token))
                        {   elementRef = &(*element);
                            if (vflag)
                                cerr << "   Found soap header element '" << (token?token:"") << "'" << endl;
                            break;
                        }
                    }
                }
            }
        }
        if (!elementRef)
        {   if (is_builtin_qname(element))
                definitions.builtinElement(element);
            else if (!Wflag)
                cerr << "Warning: no soap header element '" << element << "' in wsdl definitions '" << (definitions.name?definitions.name:"") << "' namespace '" << (definitions.targetNamespace?definitions.targetNamespace:"") << "'" << endl;
        }
    }
    return SOAP_OK;
}
Exemplo n.º 3
0
int wsdl__types::traverse(wsdl__definitions& definitions)
{ if (vflag)
    cerr << "wsdl types" << endl;
  // import external schemas
again:
  for (vector<xs__schema*>::iterator schema1 = xs__schema_.begin(); schema1 != xs__schema_.end(); ++schema1)
  { for (vector<xs__import>::iterator import = (*schema1)->import.begin(); import != (*schema1)->import.end(); ++import)
    { if ((*import).namespace_ && (*import).schemaLocation)
      { bool found = false;
        for (vector<xs__schema*>::const_iterator schema2 = xs__schema_.begin(); schema2 != xs__schema_.end(); ++schema2)
        { if ((*schema2)->targetNamespace && !strcmp((*import).namespace_, (*schema2)->targetNamespace))
          { found = true;
	    break;
	  }
        }
	if (!found)
	{ if ((*import).schemaPtr())
	  { if (strcmp((*import).schemaPtr()->targetNamespace, (*import).namespace_))
	      cerr << "Schema import namespace " << (*import).namespace_ << " does not correspond to imported targetNamespace " << (*import).schemaPtr()->targetNamespace << endl;
	    else
	    { xs__schema_.push_back((*import).schemaPtr());
	      goto again;
	    }
	  }
	  else
          { struct Namespace *p = definitions.soap->local_namespaces;
            const char *s = (*import).schemaLocation;
            if (s && (*import).namespace_)
            { if (p)
              { for (; p->id; p++)
                { if (p->in)
                  { if (!soap_tag_cmp((*import).namespace_, p->in))
                      break;
	          }
	          if (p->ns)
                  { if (!soap_tag_cmp((*import).namespace_, p->ns))
                      break;
	          }
                }
              }
	      else
	        fprintf(stderr, "Warning: no namespace table\n");
              if (!iflag && (!p || !p->id)) // don't import any of the schemas in the .nsmap table (or when -i option is used)
	      { xs__schema *importschema = new xs__schema(definitions.soap, s);
	        (*import).schemaPtr(importschema);
	        if (!importschema->targetNamespace)
	          importschema->targetNamespace = (*import).namespace_;
	        if (strcmp(importschema->targetNamespace, (*import).namespace_))
	          cerr << "Schema import namespace " << (*import).namespace_ << " does not correspond to imported targetNamespace " << importschema->targetNamespace << endl;
	        else
                { importschema->traverse();
	          xs__schema_.push_back(importschema);
	          goto again;
	        }
              }
	    }
	    else if (vflag)
	      fprintf(stderr, "Warning: no schemaLocation for namespace '%s'\n", (*import).namespace_?(*import).namespace_:"");
	  }
        }
      }
    }
  }
  for (vector<xs__schema*>::iterator schema2 = xs__schema_.begin(); schema2 != xs__schema_.end(); ++schema2)
  { // artificially extend the <import> of each schema to include others so when we traverse schemas we can resolve references
    for (vector<xs__schema*>::iterator importschema = xs__schema_.begin(); importschema != xs__schema_.end(); ++importschema)
    { if (schema2 != importschema)
      { xs__import *import = new xs__import();
        import->namespace_ = (*importschema)->targetNamespace;
        import->schemaPtr(*importschema);
        (*schema2)->import.push_back(*import);
      }
    }
    for (vector<xs__import>::iterator import = (*schema2)->import.begin(); import != (*schema2)->import.end(); ++import)
    { if ((*import).namespace_)
      { bool found = false;
        for (vector<xs__schema*>::const_iterator importschema = xs__schema_.begin(); importschema != xs__schema_.end(); ++importschema)
	{ if ((*importschema)->targetNamespace && !strcmp((*import).namespace_, (*importschema)->targetNamespace))
          { found = true;
	    break;
	  }
        }
	if (!found)
	  cerr << "Schema import namespace " << (*import).namespace_ << " refers to a known external Schema" << endl;
      }
      else
        cerr << "<xs:import> has no namespace" << endl;
    }
  }
  for (vector<xs__schema*>::iterator schema3 = xs__schema_.begin(); schema3 != xs__schema_.end(); ++schema3)
  { (*schema3)->traverse();
    if (vflag)
      for (SetOfString::const_iterator i = (*schema3)->builtinTypes().begin(); i != (*schema3)->builtinTypes().end(); ++i)
        cerr << "Schema builtin type: " << (*i) << endl;
    definitions.builtinTypes((*schema3)->builtinTypes());
    definitions.builtinElements((*schema3)->builtinElements());
    definitions.builtinAttributes((*schema3)->builtinAttributes());
  }
  return SOAP_OK;
}
Exemplo n.º 4
0
int wsdl__part::traverse(wsdl__definitions& definitions)
{ if (vflag)
    cerr << "wsdl part" << endl;
  elementRef = NULL;
  simpleTypeRef = NULL;
  complexTypeRef = NULL;
  if (definitions.types)
  { for (vector<xs__schema*>::iterator schema = definitions.types->xs__schema_.begin(); schema != definitions.types->xs__schema_.end(); ++schema)
    { const char *token = qname_token(element, (*schema)->targetNamespace);
      if (token)
      { for (vector<xs__element>::iterator element = (*schema)->element.begin(); element != (*schema)->element.end(); ++element)
        { if ((*element).name && !strcmp((*element).name, token))
          { elementRef = &(*element);
            if (vflag)
	      cerr << "Found part " << (name?name:"") << " element " << (token?token:"") << endl;
            break;
          }
        }
      }
      token = qname_token(type, (*schema)->targetNamespace);
      if (token)
      { for (vector<xs__simpleType>::iterator simpleType = (*schema)->simpleType.begin(); simpleType != (*schema)->simpleType.end(); ++simpleType)
        { if ((*simpleType).name && !strcmp((*simpleType).name, token))
          { simpleTypeRef = &(*simpleType);
            if (vflag)
              cerr << "Found part " << (name?name:"") << " simpleType " << (token?token:"") << endl;
            break;
          }
        }
      }
      token = qname_token(type, (*schema)->targetNamespace);
      if (token)
      { for (vector<xs__complexType>::iterator complexType = (*schema)->complexType.begin(); complexType != (*schema)->complexType.end(); ++complexType)
        { if ((*complexType).name && !strcmp((*complexType).name, token))
          { complexTypeRef = &(*complexType);
            if (vflag)
	      cerr << "Found part " << (name?name:"") << " complexType " << (token?token:"") << endl;
            break;
          }
        }
      }
    }
  }
  if (!elementRef && !simpleTypeRef && !complexTypeRef)
  { if (element)
    { if (is_builtin_qname(element))
	definitions.builtinElement(element);
      else
        cerr << "Warning: could not find part " << (name?name:"") << " element " << element << " in WSDL definitions " << (definitions.name?definitions.name:"") << " namespace " << (definitions.targetNamespace?definitions.targetNamespace:"") << endl;
    }
    else if (type)
    { if (is_builtin_qname(type))
	definitions.builtinType(type);
      else
        cerr << "Warning: could not find part " << (name?name:"") << " type " << type << " in WSDL definitions " << (definitions.name?definitions.name:"") << " namespace " << (definitions.targetNamespace?definitions.targetNamespace:"") << endl;
    }
    else
      cerr << "Warning: could not find part " << (name?name:"") << " element or type" << " in WSDL definitions " << (definitions.name?definitions.name:"") << " namespace " << (definitions.targetNamespace?definitions.targetNamespace:"") << endl;
  }
  return SOAP_OK;
}