示例#1
0
/*
 * Don't know why these aren't being generated, but ....
 */
struct soap_dom_element *
soap_in__bes__CreateActivityFaultMessage(struct soap *s, 
                                         const char *tag, 
                                         struct soap_dom_element *node,
                                         const char *type)
{
    return soap_in_xsd__anyType(s, tag, node, type);
}
SOAP_FMAC2
soap_in_xsd__anyType(struct soap *soap, const char *tag, struct soap_dom_element *node, const char *type)
{ register struct soap_attribute *tp;
  register struct soap_dom_attribute **att;
  if (soap_peek_element(soap))
  { if (soap->error != SOAP_NO_TAG)
      return NULL;
    if (!node)
    { if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element))))
      { soap->error = SOAP_EOM;
        return NULL;
      }
    }
    soap_default_xsd__anyType(soap, node);
    if (!(node->data = soap_string_in(soap, 1, -1, -1)) || !*node->data)
      return NULL;
    soap->error = SOAP_OK;
    return node;
  }
  if (!node)
  { if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element))))
    { soap->error = SOAP_EOM;
      return NULL;
    }
  }
  soap_default_xsd__anyType(soap, node);
  node->nstr = soap_current_namespace(soap, soap->tag);
  if ((soap->mode & SOAP_DOM_ASIS))
    node->name = soap_strdup(soap, soap->tag);
  else
  { char *s = strchr(soap->tag, ':');
    if (s)
      node->name = soap_strdup(soap, s+1);
    else
      node->name = soap_strdup(soap, soap->tag);
  }
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' parsed in namespace '%s'\n", node->name, node->nstr?node->nstr:""));
  if ((soap->mode & SOAP_DOM_NODE) || (!(soap->mode & SOAP_DOM_TREE) && *soap->id))
  { if ((node->node = soap_getelement(soap, &node->type)))
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node contains type %d from xsi:type\n", node->type));
      return node;
    }
    if (soap->error == SOAP_TAG_MISMATCH)
      soap->error = SOAP_OK;
    else
      return NULL;
  }
  att = &node->atts;
  for (tp = soap->attributes; tp; tp = tp->next)
  { if (tp->visible)
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node attribute='%s' parsed\n", tp->name));
      *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
      if (!*att)
      { soap->error = SOAP_EOM;
        return NULL;
      }
      (*att)->next = NULL;
      (*att)->nstr = soap_current_namespace(soap, tp->name);
      if ((soap->mode & SOAP_DOM_ASIS) || !strncmp(tp->name, "xml", 3))
        (*att)->name = soap_strdup(soap, tp->name);
      else
      { char *s = strchr(tp->name, ':');
        if (s)
          (*att)->name = soap_strdup(soap, s+1);
        else
          (*att)->name = soap_strdup(soap, tp->name);
      }
      if (tp->visible == 2)
        (*att)->data = soap_strdup(soap, tp->value);
      else
        (*att)->data = NULL;
      (*att)->wide = NULL;
      (*att)->soap = soap;
      att = &(*att)->next;
      tp->visible = 0;
    }
  }
  soap_element_begin_in(soap, NULL, 1, NULL);
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' pulled\n", node->name));
  if (soap->body)
  { if (!soap_peek_element(soap))
    { struct soap_dom_element **elt;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has subelements\n", node->name));
      elt = &node->elts;
      for (;;)
      { if (!(*elt = soap_in_xsd__anyType(soap, NULL, NULL, NULL)))
        { if (soap->error != SOAP_NO_TAG)
            return NULL;
          soap->error = SOAP_OK;
          break;
        }
	(*elt)->prnt = node;
        elt = &(*elt)->next;
      }
    }
    else if (soap->error == SOAP_NO_TAG)
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has cdata\n", node->name));
      if ((soap->mode & SOAP_C_UTFSTRING) || (soap->mode & SOAP_C_MBSTRING))
      { if (!(node->data = soap_string_in(soap, 1, -1, -1)))
          return NULL;
      }
      else if (!(node->wide = soap_wstring_in(soap, 1, -1, -1)))
        return NULL;
    }
    else
      return NULL;
    if (soap_element_end_in(soap, node->name))
      return NULL;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of DOM node '%s'\n", node->name));
  }
  return node;
}
示例#3
0
SOAP_FMAC2
soap_in_xsd__anyType(struct soap *soap, const char *tag, struct soap_dom_element *node, const char *type)
{ register struct soap_attribute *tp;
  register struct soap_dom_attribute **att;
  register struct soap_nlist *np;
  register char *s;
  if (soap_peek_element(soap))
    return NULL;
  if (!node)
    if (!(node = (struct soap_dom_element*)soap_malloc(soap, sizeof(struct soap_dom_element))))
    { soap->error = SOAP_EOM;
      return NULL;
    }
  node->next = NULL;
  node->prnt = NULL;
  node->elts = NULL;
  node->atts = NULL;
  node->nstr = NULL;
  node->name = NULL;
  node->data = NULL;
  node->wide = NULL;
  node->node = NULL;
  node->type = 0;
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node %s\n", soap->tag));
  np = soap->nlist;
  if (!(s = strchr(soap->tag, ':')))
  { while (np && *np->id) /* find default namespace, if present */
      np = np->next;
    s = soap->tag;
  }
  else
  { while (np && (strncmp(np->id, soap->tag, s - soap->tag) || np->id[s - soap->tag]))
      np = np->next;
    s++;
    if (!np)
    { soap->error = SOAP_NAMESPACE;
      return NULL;
    }
  }
  if (np)
  { if (np->index >= 0)
      node->nstr = soap->namespaces[np->index].ns;
    else if (np->ns)
      node->nstr = soap_strdup(soap, np->ns);
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node namespace='%s'\n", node->nstr?node->nstr:""));
  }
  node->name = soap_strdup(soap, soap->tag);
  if ((soap->mode & SOAP_DOM_NODE) || (!(soap->mode & SOAP_DOM_TREE) && *soap->id))
  { if ((node->node = soap_getelement(soap, &node->type)))
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node contains type %d from xsi:type\n", node->type));
      return node;
    }
    if (soap->error == SOAP_TAG_MISMATCH)
      soap->error = SOAP_OK;
    else
      return NULL;
  }
  att = &node->atts;
  for (tp = soap->attributes; tp; tp = tp->next)
    if (tp->visible)
    { np = soap->nlist;
      if (!(s = strchr(tp->name, ':')))
      { while (np && *np->id) /* find default namespace, if present */
          np = np->next;
        s = tp->name;
      }
      else
      { while (np && (strncmp(np->id, tp->name, s - tp->name) || np->id[s - tp->name]))
          np = np->next;
        s++;
        if (!np)
        { soap->error = SOAP_NAMESPACE;
          return NULL;
        }
      }
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node attribute='%s'\n", tp->name));
      *att = (struct soap_dom_attribute*)soap_malloc(soap, sizeof(struct soap_dom_attribute));
      if (!*att)
      { soap->error = SOAP_EOM;
        return NULL;
      }
      (*att)->next = NULL;
      (*att)->nstr = NULL;
      if (np)
      { if (np->index >= 0)
          (*att)->nstr = soap->namespaces[np->index].ns;
        else if (np->ns)
	  (*att)->nstr = soap_strdup(soap, np->ns);
        DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM attribute namespace='%s'\n", (*att)->nstr?(*att)->nstr:""));
      }
      (*att)->name = soap_strdup(soap, s);
      if (tp->visible == 2)
        (*att)->data = soap_strdup(soap, tp->value);
      else
        (*att)->data = NULL;
      (*att)->wide = NULL;
      att = &(*att)->next;
      tp->visible = 0;
    }
  soap_element_begin_in(soap, NULL, 1);
  DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' accepted\n", node->name));
  if (soap->body)
  { wchar c;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has content\n", node->name));
    do c = soap_getchar(soap);
    while (c > 0 && c <= 32);
    if (c == EOF)
    { soap->error = SOAP_EOF;
      return NULL;
    }
    soap_unget(soap, c);
    if (c == '<')
    { struct soap_dom_element **elt;
      DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has subelements\n", node->name));
      elt = &node->elts;
      for (;;)
      { if (!(*elt = soap_in_xsd__anyType(soap, NULL, NULL, NULL)))
        { if (soap->error == SOAP_NO_TAG)
            soap->error = SOAP_OK;
          else
            return NULL;
          break;
        }
	(*elt)->prnt = node;
        elt = &(*elt)->next;
      }
    }
    else
    { DBGLOG(TEST, SOAP_MESSAGE(fdebug, "DOM node '%s' has cdata\n", node->name));
      if ((soap->mode & SOAP_C_UTFSTRING) || (soap->mode & SOAP_C_MBSTRING))
      { if (!(node->data = soap_string_in(soap, 1, -1, -1)))
          return NULL;
      }
      else if (!(node->wide = soap_wstring_in(soap, 1, -1, -1)))
        return NULL;
    }
    if (soap_element_end_in(soap, node->name))
      return NULL;
    DBGLOG(TEST, SOAP_MESSAGE(fdebug, "End of DOM node '%s'\n", node->name));
  }
  return node;
}
示例#4
0
int 
bes_readEPRFromFile(struct bes_context *context, char *filename, epr_t *epr)
{
    int fd, size = 0, ret = BESE_OK;
    struct soap_dom_element *dom;
    struct bes_epr *tmpEPR;
    struct stat fileStat;
    
    if (context == NULL || epr == NULL || filename == NULL) {
        return BESE_BAD_ARG;
    }
    
    fd = open(filename, O_RDONLY, 0);
    if (fd == -1) {
        // fprintf (stderr, "err 9: %s\n", filename);
        setErrorString(context, NULL, BESE_SYS_ERR);
        return BESE_SYS_ERR;
    }
    
    dom = (struct soap_dom_element *)soap_malloc(context->soap, sizeof(struct soap_dom_element));
    if (!dom) {
        close(fd);
        setErrorString(context, NULL, BESE_MEM_ALLOC);
        return BESE_MEM_ALLOC;
    }
    
    dom->soap = soap_new1(SOAP_DOM_TREE|SOAP_C_UTFSTRING);
    dom->soap->recvfd = fd;
    if (soap_begin_recv(dom->soap)
        || soap_in_xsd__anyType(dom->soap, NULL, dom, NULL) == NULL
        || soap_end_recv(dom->soap)) {
        setErrorString(context, dom->soap, BESE_SOAP_ERR);
        ret = BESE_SOAP_ERR;
        goto error_end;
    }
    
    tmpEPR = (struct bes_epr *)malloc(sizeof(struct bes_epr));
    if (!tmpEPR) {
        setErrorString(context, NULL, BESE_MEM_ALLOC);
        ret = BESE_MEM_ALLOC;
        goto error_end;
    }
    memset(tmpEPR, 0, sizeof(struct bes_epr));
    
    if (lseek(fd, 0, SEEK_SET) == -1) {
        free(tmpEPR);
        // fprintf (stderr, "err 10\n");
        setErrorString(context, NULL, BESE_SYS_ERR);
        ret = BESE_SYS_ERR;
        goto error_end;
    }
    
    if (fstat(fd, &fileStat)) {
        free(tmpEPR);
        // fprintf (stderr, "err 11\n");
        setErrorString(context, NULL, BESE_SYS_ERR);
        ret = BESE_SYS_ERR;
        goto error_end;
    }
    
    size = fileStat.st_size;
    tmpEPR->str = (char *)malloc(size + 1);
    if (!tmpEPR->str) {
        free(tmpEPR);
        setErrorString(context, NULL, BESE_MEM_ALLOC);
        ret = BESE_MEM_ALLOC;
        goto error_end;
    }
    memset(tmpEPR->str, 0, size + 1);
    
    if (read(fd, tmpEPR->str, size) == -1) {
        free(tmpEPR);
        // fprintf (stderr, "err 12\n");
        setErrorString(context, NULL, BESE_SYS_ERR);
        ret = BESE_SYS_ERR;
        goto error_end;
    }
    
    close(fd);
    
    tmpEPR->dom = dom;
    tmpEPR->domCreateFlag = FromMalloc;
    *epr = (epr_t)tmpEPR;
    
    return BESE_OK;
    
 error_end:
    close(fd);
    soap_end(dom->soap);
    soap_done(dom->soap);
    free(dom->soap);
    
    return ret;
}
示例#5
0
int
bes_createActivityFromString(struct bes_context *context, 
                             epr_t endpointepr, 
                             char *jsdl, 
                             epr_t *activityepr) 
{
    struct soap *s;
    struct bes__CreateActivityType req;
    struct bes__CreateActivityResponseType rsp;
    struct soap_dom_element dom, *tmpdom;
    struct soap_dom_attribute *attr;
    struct bes_epr *epr;
    int jsdl_fd, size = 0, ret = BESE_OK;
    char *endpoint, filename[] = "/tmp/XXXXXX";
    
    if (context == NULL 
        || endpointepr == NULL
        || jsdl == NULL 
        || activityepr == NULL) {
        return BESE_BAD_ARG;
    }
    
    if ((jsdl_fd = mkstemp(filename)) < 0) {
        // fprintf (stderr, "err 4\n");
        setErrorString(context, NULL, BESE_SYS_ERR);
        return BESE_SYS_ERR;
    }
    unlink(filename);

    if (write(jsdl_fd, jsdl, strlen(jsdl)) < 0) {
        close(jsdl_fd);
        // fprintf (stderr, "err 5\n");
        setErrorString(context, NULL, BESE_SYS_ERR);
        return BESE_SYS_ERR;
    }

    if (lseek(jsdl_fd, 0, SEEK_SET) == -1) {
        close(jsdl_fd);
        // fprintf (stderr, "err 6\n");
        setErrorString(context, NULL, BESE_SYS_ERR);
        return BESE_SYS_ERR;
    }

    s = context->soap;
    
    if (ret = generateAddressingHeaders(context, endpointepr, CREATE_ACT, &endpoint)) {
        return ret;
    }
    
    memset(&dom, 0, sizeof(struct soap_dom_element));
    dom.soap = soap_new1(SOAP_DOM_TREE|SOAP_C_UTFSTRING);
    dom.soap->recvfd = jsdl_fd;
    if (soap_begin_recv(dom.soap)
        || soap_in_xsd__anyType(dom.soap, NULL, &dom, NULL) == NULL
        || soap_end_recv(dom.soap)) {
        setErrorString(context, dom.soap, BESE_SOAP_ERR);
        close(jsdl_fd);
        ret = BESE_SOAP_ERR;
        goto end;
    }
    close(jsdl_fd);
    
    memset(&req, 0, sizeof(struct bes__CreateActivityType));
    memset(&rsp, 0, sizeof(struct bes__CreateActivityResponseType));
    
    req.bes__ActivityDocument.__any = &dom;

    if (soap_call___bes__CreateActivity(s, endpoint, CREATE_ACT, &req, &rsp) != SOAP_OK) {
        setErrorString(context, s, BESE_SOAP_ERR);
        ret = BESE_SOAP_ERR;
        goto end;
    }
    else {
        tmpdom = rsp.__any;
        
        cleanDom(tmpdom);
        
        epr = (struct bes_epr *)malloc(sizeof(struct bes_epr));
        if (!epr) {
            setErrorString(context, NULL, BESE_MEM_ALLOC);
            ret = BESE_MEM_ALLOC;
            goto end;
        }
        memset(epr, 0, sizeof(struct bes_epr));
        
        epr->str = generateEPRString(tmpdom, NULL);
        if (!epr->str) {
            free(epr);
            setErrorString(context, NULL, BESE_MEM_ALLOC);
            ret = BESE_MEM_ALLOC;
            goto end;
        }
        epr->dom = tmpdom;
        *activityepr = (epr_t)epr;
    }
    
 end:
    soap_end(dom.soap);
    soap_done(dom.soap);
    free(dom.soap);
    
    return ret;
}