[wsf-c-dev] svn commit r296 - wsf/php/src

svn at wso2.com svn at wso2.com
Mon Jan 1 03:11:17 PST 2007


Author: nandika
Date: Mon Jan  1 03:11:16 2007
New Revision: 296

Modified:
   wsf/php/src/util.c
   wsf/php/src/wsf.c
   wsf/php/src/wsf.h
   wsf/php/src/wsf_common.h
Log:
crash problem with mtom fixed

Modified: wsf/php/src/util.c
==============================================================================
--- wsf/php/src/util.c	(original)
+++ wsf/php/src/util.c	Mon Jan  1 03:11:16 2007
@@ -438,20 +438,22 @@
                             void *binary_data = NULL;
                             int binary_data_len = 0;
                             
-                            binary_data = Z_STRVAL_PP(tmp);
+                            /* binary_data = Z_STRVAL_PP(tmp); */
                             binary_data_len = Z_STRLEN_PP(tmp);
-                            
+							binary_data = AXIS2_MALLOC(env->allocator, sizeof(char)*binary_data_len);
+							memcpy(binary_data, Z_STRVAL_PP(tmp) , binary_data_len);
                             if(binary_data)
                             {
                                 /** detach this node */
                                 axiom_node_t *text_node = NULL;
                                 axiom_text_t *text = NULL;
                                 axiom_data_handler_t *data_handler = NULL;
-                                AXIOM_NODE_DETACH(node, env);
+								AXIOM_NODE_DETACH(node, env);
                                 data_handler = axiom_data_handler_create(env, NULL, cnt_type);
-                                AXIOM_DATA_HANDLER_SET_BINARY_DATA(data_handler, env, binary_data, binary_data_len);
-                                text = axiom_text_create_with_data_handler(env, payload_node, data_handler, &text_node);
-                                if (enable_mtom == AXIS2_FALSE){
+								AXIOM_DATA_HANDLER_SET_BINARY_DATA(data_handler, env, binary_data, binary_data_len);
+								text = axiom_text_create_with_data_handler(env, payload_node, data_handler, &text_node);
+                                
+								if (enable_mtom == AXIS2_FALSE){
 							        AXIOM_TEXT_SET_OPTIMIZE(text, env, AXIS2_FALSE);
 						        }
                                 return;
@@ -880,18 +882,7 @@
             AXIS2_PROPERTY_SET_VALUE(property, env, password_type);
             AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "passwordType" ,property);
     }
-	/*
-	if(zend_hash_find(Z_OBJPROP_P(zval_client), "Basic256Rsa15", sizeof("Basic256Rsa15"), (void **)&msg_tmp) == SUCCESS && 
-        Z_TYPE_PP(tmp) == IS_STRING){
-        char *password = NULL;
-        axis2_property_t *property = NULL;
-		property = axis2_property_create_with_args(env, AXIS2_SCOPE_REQUEST, NULL,
-        password = Z_STRVAL_PP(tmp);
-        AXIS2_PROPERTY_SET_VALUE(property,env, password);
-        AXIS2_OPTIONS_SET_PROPERTY(client_options,  env, "encryptionKeyTransportAlgorithm", property);
-        password_present = AXIS2_TRUE;
-    }
-	*/
+	
     if(zend_hash_find(Z_OBJPROP_P(zval_client), "timeToLive", sizeof("timeToLive"), 
         (void **)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
     {

Modified: wsf/php/src/wsf.c
==============================================================================
--- wsf/php/src/wsf.c	(original)
+++ wsf/php/src/wsf.c	Mon Jan  1 03:11:16 2007
@@ -119,6 +119,11 @@
 PHP_FUNCTION(ws_param_get_attribute);
 PHP_FUNCTION(ws_param_add_attribute);
 
+/** WSHeader class functions */
+PHP_METHOD(ws_header, __construct);
+PHP_METHOD(ws_header, __destruct);
+
+
 /** WSVAR class entry **/
 PHP_METHOD(ws_var, __construct);
 PHP_METHOD(ws_var, __destruct);
@@ -196,6 +201,14 @@
 	{NULL, NULL, NULL}
 };
 
+/* {{{ WSHeader class functions */
+zend_function_entry php_ws_header_class_functions[] =
+{
+	PHP_ME(ws_header, __construct, NULL, ZEND_ACC_PUBLIC)
+	PHP_ME(ws_header, __destruct, NULL, ZEND_ACC_PUBLIC)
+	{NULL, NULL, NULL}
+};
+
 /* {{{ wsf_functions[] */
 zend_function_entry wsf_functions[] = {
 	PHP_FE(is_ws_fault,	NULL)
@@ -203,9 +216,6 @@
 };
 /* }}} */
 
-
-
-
 static zend_object_handlers ws_object_handlers;
 /** object creation and destruction functions */
 static zend_object_value 
@@ -2229,12 +2239,15 @@
 	REGISTER_AXIS2_CLASS(ce, "WSService", NULL,
 	php_ws_service_class_functions, ws_service_class_entry);
 
-    	INIT_CLASS_ENTRY(ce, "WSMessage", php_ws_message_class_functions);
-	    ws_message_class_entry =  zend_register_internal_class(&ce TSRMLS_CC);
+    INIT_CLASS_ENTRY(ce, "WSMessage", php_ws_message_class_functions);
+	ws_message_class_entry =  zend_register_internal_class(&ce TSRMLS_CC);
         
 	INIT_CLASS_ENTRY(ce, "WSParam", php_ws_param_class_functions);
 	ws_param_class_entry =  zend_register_internal_class(&ce TSRMLS_CC);
 
+	INIT_CLASS_ENTRY(ce, "WSHeader", php_ws_header_class_functions);
+	ws_header_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
+
 	INIT_CLASS_ENTRY(ce, "WSFault", php_ws_fault_class_functions);
 	/*ws_fault_class_entry = zend_register_internal_class_ex(&ce, zend_exception_get_default(), NULL TSRMLS_CC);*/
 	ws_fault_class_entry = zend_register_internal_class(&ce TSRMLS_CC);
@@ -2243,6 +2256,11 @@
     le_url = register_list_destructors(delete_url, NULL);
     le_typemap = register_list_destructors(delete_hashtable, NULL);
     
+
+	REGISTER_LONG_CONSTANT("WS_SOAP_ROLE_NEXT", WS_SOAP_ROLE_NEXT, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("WS_SOAP_ROLE_NONE", WS_SOAP_ROLE_NONE, CONST_CS | CONST_PERSISTENT);
+	REGISTER_LONG_CONSTANT("WS_SOAP_ROLE_ULTIMATE_RECEIVER", WS_SOAP_ROLE_ULTIMATE_RECEIVER, CONST_CS | CONST_PERSISTENT);
+
 	
 	env = ws_env_create(WSF_GLOBAL(log_path));
 
@@ -2989,13 +3007,13 @@
         
         fault = axiom_util_get_localname(res_payload, env);
 	    
-        if( 0 == strcmp(fault, "Fault"))
+        if( fault && 0 == strcmp(fault, "Fault"))
 	    {
 	    	zval *rfault = NULL;
 		    MAKE_STD_ZVAL(rfault);
     		object_init_ex(rfault, ws_fault_class_entry);
 	    	res_text = serialize_om(env, res_payload);
-		    add_property_stringl(rfault, "Fault:", res_text, strlen(res_text), 1);
+		    add_property_stringl(rfault, "str", res_text, strlen(res_text), 1);
     		RETURN_ZVAL(rfault, NULL, NULL);
 	    }
 	    else {
@@ -3025,6 +3043,7 @@
             add_property_stringl(rmsg, AXIS2_MSG_P_STR, res_text, strlen(res_text), 1); 
   		    RETURN_ZVAL(rmsg, NULL, NULL);
 	    }
+		
 	} else {
 		zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC, 
 			"soap body is not found");
@@ -4126,3 +4145,48 @@
 zval* add_soap_fault(zval *obj, char *fault_code, char *fault_string, char *fault_actor, zval *fault_detail TSRMLS_DC){
 
 }
+
+PHP_METHOD(ws_header, __construct) 
+{
+	zval *data = NULL, *role = NULL;
+	char *name, *ns;
+	int name_len, ns_len;
+	zend_bool must_understand = 0;
+
+	if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ss|zbz", 
+			&ns, &ns_len, &name, &name_len, &data, &must_understand, &role) == FAILURE) {
+			php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
+	}
+	if (ns_len == 0) {
+		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid namespace.");
+	}
+	if (name_len == 0) {
+		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid header name.");
+	}
+
+	add_property_stringl(this_ptr, "namespace", ns, ns_len, 1);
+	add_property_stringl(this_ptr, "name", name, name_len, 1);
+	if (data) {
+#ifndef ZEND_ENGINE_2
+		zval_add_ref(&data);
+#endif
+		add_property_zval(this_ptr, "data", data);
+	}
+	add_property_bool(this_ptr, "mustUnderstand", must_understand);
+	if (role == NULL) {
+	} else if (Z_TYPE_P(role) == IS_LONG &&
+		(Z_LVAL_P(role) == WS_SOAP_ROLE_NEXT ||
+		Z_LVAL_P(role) == WS_SOAP_ROLE_NONE ||
+		Z_LVAL_P(role) == WS_SOAP_ROLE_ULTIMATE_RECEIVER)) {
+			add_property_long(this_ptr, "role", Z_LVAL_P(role));
+	} else if (Z_TYPE_P(role) == IS_STRING && Z_STRLEN_P(role) > 0) {
+		add_property_stringl(this_ptr, "role", Z_STRVAL_P(role), Z_STRLEN_P(role), 1);
+	} else {
+		php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters. Invalid role.");
+	}
+}
+
+PHP_METHOD(ws_header, __destruct) 
+{
+
+}
\ No newline at end of file

Modified: wsf/php/src/wsf.h
==============================================================================
--- wsf/php/src/wsf.h	(original)
+++ wsf/php/src/wsf.h	Mon Jan  1 03:11:16 2007
@@ -153,6 +153,7 @@
 
 zend_class_entry *ws_client_class_entry;
 zend_class_entry *ws_service_class_entry;
+zend_class_entry *ws_header_class_entry;
 zend_class_entry *ws_param_class_entry;
 zend_class_entry *ws_fault_class_entry;
 zend_class_entry *ws_message_class_entry;

Modified: wsf/php/src/wsf_common.h
==============================================================================
--- wsf/php/src/wsf_common.h	(original)
+++ wsf/php/src/wsf_common.h	Mon Jan  1 03:11:16 2007
@@ -61,10 +61,17 @@
 #define AXIS2_MSG_P_TYPE "payloadtype"
 #define AXIS2_MSG_TYPE "type"
 
+/** soap header attributes */
 
+#define WS_SOAP_ROLE_NONE			1
+#define WS_SOAP_ROLE_NEXT			2
+#define WS_SOAP_ULTIMATE_RECEIVER	3
+
+#define WS_SOAP_ROLE_NONE_URI "http://www.w3.org/2003/05/soap-envelope/role/none"
+#define WS_SOAP_ROLE_NEXT_URI "http://www.w3.org/2003/05/soap-envelope/role/next"
+#define WS_SOAP_ROLE_ULTIMATE_RECEIVER "http://www.w3.org/2003/05/soap-envelope/role/next"
 
 /** soap fault consts */
-
 #define WS_ENCODED       1
 #define WS_LITERAL       2
 #define WS_SOAP_11       3
@@ -73,10 +80,10 @@
 #define WS_DOC           6
 
 
-#define WS_LOCATION      "location"
-#define WS_USE           "use"
-#define WS_USE_SOAP_IN_OUT       "use_soap_in_out"
-#define WS_STYLE         "style"
+#define WS_LOCATION         "location"
+#define WS_USE              "use"
+#define WS_USE_SOAP_IN_OUT  "use_soap_in_out"
+#define WS_STYLE            "style"
 
 /* defaults to WS_SOAP_12 */
 #define WS_SOAP_VERSION  "soap_version" 




More information about the Wsf-c-dev mailing list