Ejemplo n.º 1
0
xmlNodePtr
soap_env_get_header(SoapEnv *env)
{
  xmlNodePtr node;

  if (!env)
  {
    log_error1("SoapEnv is NULL");
    return NULL;
  }

  if (!env->root)
  {
    log_error1("SoapEnv contains no document");
    return NULL;
  }

  for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next(node))
  {
    if (!xmlStrcmp(node->name, BAD_CAST "Header")
     && !xmlStrcmp(node->ns->href, BAD_CAST soap_env_ns))
      return node;
  }

  return NULL;
}
Ejemplo n.º 2
0
xmlNodePtr
soap_env_get_body(SoapEnv * env)
{
  xmlNodePtr node;

  if (env == NULL)
  {
    log_error1("env object is NULL");
    return NULL;
  }

  if (env->root == NULL)
  {
    log_error1("env has no xml");
    return NULL;
  }

  for (node = soap_xml_get_children(env->root); node; node = soap_xml_get_next(node))
  {
    if (!xmlStrcmp(node->name, BAD_CAST "Body")
     && !xmlStrcmp(node->ns->href, BAD_CAST soap_env_ns))
      return node;
  }

  log_error1("Body tag not found!");
  return NULL;
}
Ejemplo n.º 3
0
int interpretResponse( SoapCtx* response, xmlChar** buildID ) {
	xmlNodePtr method;
	xmlNodePtr node;
	xmlChar* value;
                                                                                                                                    
	method = soap_env_get_method( response->env );

	if ( method ) {
		if ( strcmp( (char*)method->name, "Fault" ) == 0 ) {
			printf( "Regresstor: A SOAP error has occured:\n" );
			node = soap_xml_get_children( method );
			while ( node ) {
				value = xmlNodeListGetString( node->doc, node->xmlChildrenNode, 1 );
				printf( "Regresstor: %s=%s\n", node->name, value );
				node = soap_xml_get_next(node);
			}
			return 0;
		}
		
		node = soap_xml_get_children( method );		/* The s-gensym3 struct */

		if ( node->children ) {
			/* This is where the response values are */
			node = node->children;
			while ( node ) {
				value = xmlNodeListGetString( node->doc, node->xmlChildrenNode, 1 );

				if ( strcmp( (char*)node->name, "errorMsg" ) == 0 ) {
					printf( "Regresstor: Error - %s\n", value );
					return 0;
				}
				
				node = soap_xml_get_next(node);
			}
		}
	}
	else {
		printf( "Regresstor: Non-SOAP response.\n" );
	}
	printf( "Regresstor: Successfully submited check.\n" );
	return 1;
}
Ejemplo n.º 4
0
static s32 umc_get_res(WS_ENV* ws_env, WS_REQ_RES* ws_req_res, xmlNodePtr parent)
{
    xmlNodePtr node;
    s32 ret = 0;

    /* 遍历res的子节点 */
    for (node = soap_xml_get_children(parent);
            node;
            node = soap_xml_get_next(node))
    {
        ret = ws_add_res_string(ws_env, ws_req_res, (s8 *)(node->name), soap_xml_get_text(node));
        if(ret)
        {
            break;
        }
        
    }
     return ret;
}
Ejemplo n.º 5
0
xmlNodePtr
soap_env_get_fault(SoapEnv * env)
{
  xmlNodePtr node;

  node = soap_env_get_body(env);

  if (!node)
    return NULL;

  while (node != NULL)
  {
    if (!xmlStrcmp(node->name, BAD_CAST "Fault"))
      return node;
    node = soap_xml_get_next(node);
  }

/*  log_warn1 ("Node Fault tag found!");*/
  return NULL;
}
Ejemplo n.º 6
0
u_int32_t ws_umc_call(WS_ENV* ws_env, WS_REQ_RES* ws_req_res, char* method, char* end_point, char** reason)
{
    SoapCtx *ctx = NULL, *ctx2 = NULL;
    herror_t err = NULL;
    xmlNodePtr node;
    s8 url[SOAP_UMC_URL_LEN];
    s32 ret = 0;
    s8* fault_string;
    s8 umc_addr[24] = {0};
    s32 umc_port;
    s8 umc_url[30] = {0};

    /*soap client*/
    err = soap_client_init_args(0, NULL);
    if (err != H_OK)
    {
        ret = ERROR_FAIL;
        goto ret_label;
    }

    /*为soap client添加方法*/
    err = soap_ctx_new_with_method(SOAP_UMC_URN, method, &ctx);
    if (err != H_OK)
    {
        ret = ERROR_FAIL;
        goto ret_label;
    }

    /*为soap client添加请求参数*/
    ret = ws_iterate_req(ws_env, ws_req_res, ws_add_para_tosoap, (void *)ctx);
    if(ret)
    {
       goto ret_label;
    }


    ret = umc_getip(umc_addr, sizeof(umc_addr), &umc_port);
    if(ret)
    {
       goto ret_label;
    }
    if(umc_port == 0)
    {
        umc_port = 80;
    }
    snprintf(umc_url, sizeof(umc_url), "%s:%d", umc_addr, umc_port);
    
    snprintf(url, SOAP_UMC_URL_LEN, "http://%s/%s", umc_url, end_point+strlen("::/"));

    /*建立客户端, 发送请求*/
    err = soap_client_invoke_auth(ctx, &ctx2, url, "", "admin", "admin", 0);
    if (err != H_OK)
    {
         ret = ERROR_FAIL;
         goto ret_label;
    }   
    
    /*解析收到的soap应答,知道找到ret退出*/
    for (node = ctx2->env->root; node; )
    {
        if (!xmlStrcmp(node->name, BAD_CAST "Header"))
        {
            node = soap_xml_get_next(node);
        }
        else if (!xmlStrcmp(node->name, BAD_CAST "ret")
            /*|| !xmlStrstr(node->name, BAD_CAST ":ret")*/)
        {
            (void)ws_set_res_type(ws_env, ws_req_res, WS_RESULT_STRUCT);
            node = soap_xml_get_children(node);
            break;
        }
        else
        {
            node = soap_xml_get_children(node);
        }
    }

    /*此时节点指向 ret的children节点,*/
    while (node)
    {
        if (!xmlStrcmp(node->name, BAD_CAST "res_count"))
        {
            /*将总数添加res结构中*/
            ret = ws_add_res_int(ws_env, ws_req_res, (s8 *)(node->name), 
                    atoi(soap_xml_get_text(node)));
            if(ret)
            {
                break;
            }
            /*设置类型*/
            ws_set_res_type_struct_list(ws_env, 
                    ws_req_res,
                    atoi(soap_xml_get_text(node)));
                        
        }
        else if (!xmlStrcmp(node->name, BAD_CAST "umc_res"))
        {
            node = soap_xml_get_children(node);
            continue;
        }
        else if (!xmlStrcmp(node->name, BAD_CAST "res"))
        {   
            /*添加一行,每个res占用一行, 实际
                      为指针后移一行最大数*/
            ws_res_new_struct_list(ws_env, ws_req_res);
            /*添加一个res内的数据*/
            ret = umc_get_res(ws_env, ws_req_res, node);
            if(ret)
            {
                break;
            }
        }
        else
        {
            /*结构类型res的添加*/
            ret = ws_add_res_string(ws_env, ws_req_res, (s8 *)(node->name), soap_xml_get_text(node));
            if(ret)
            {
                break;
            }
        }
        node = soap_xml_get_next(node);
    }    
ret_label:
    if(ret != 0)
    {
        if(err != H_OK)
        {
            fault_string = herror_message(err);
        }
        else
        {
            fault_string = "umc get system error";
        }
        *reason = (char*)ws_strdup(ws_env, fault_string);
    }
    
    herror_release(err);
    soap_ctx_free(ctx2);
    soap_ctx_free(ctx);
    soap_client_destroy();
    
    return ret;

}