[wsf-c-dev] svn commit r389 - wsf/php/src
svn at wso2.com
svn at wso2.com
Wed Jan 10 22:37:30 PST 2007
Author: nandika
Date: Wed Jan 10 22:37:17 2007
New Revision: 389
Modified:
wsf/php/src/util.c
wsf/php/src/wsf.c
wsf/php/src/wsf_util.h
wsf/php/src/xml_msg_recv.c
Log:
duplicated code removed
Modified: wsf/php/src/util.c
==============================================================================
--- wsf/php/src/util.c (original)
+++ wsf/php/src/util.c Wed Jan 10 22:37:17 2007
@@ -28,6 +28,29 @@
#include "wsf_util.h"
#include <axis2_error_default.h>
#include <axis2_log_default.h>
+#include <axiom_util.h>
+
+
+static xmlNodePtr wsf_get_xml_node(zval *node TSRMLS_DC)
+{
+ php_libxml_node_object *object;
+ xmlNodePtr nodep;
+
+ object = (php_libxml_node_object *)zend_object_store_get_object(node TSRMLS_CC);
+ nodep = php_libxml_import_node(node TSRMLS_CC);
+ if (!nodep) {
+ return NULL;
+ }
+ if (nodep->doc == NULL) {
+ php_error_docref(NULL TSRMLS_CC, E_WARNING, "Imported Node must have \
+ associated Document");
+ return NULL;
+ }
+ if (nodep->type == XML_DOCUMENT_NODE || nodep->type == XML_HTML_DOCUMENT_NODE) {
+ nodep = xmlDocGetRootElement((xmlDocPtr) nodep);
+ }
+ return nodep;
+}
/* {{{ efree wrapper */
static void WSF_CALL wsf_free_wrapper_cli(axis2_allocator_t *allocator, void *ptr)
@@ -136,10 +159,6 @@
}
-
-
-
-
ws_svc_info_t* ws_svc_info_create()
{
ws_svc_info_t *svc_info = NULL;
@@ -499,7 +518,7 @@
return;
}
-void ws_util_set_attachments_with_cids(const axis2_env_t *env,
+void wsf_util_set_attachments_with_cids(const axis2_env_t *env,
int enable_mtom , axiom_node_t *payload_node,
HashTable *attach_ht, char *default_cnt_type TSRMLS_DC)
{
@@ -581,462 +600,13 @@
tmp_node = AXIOM_NODE_GET_FIRST_CHILD(payload_node, env);
while(tmp_node)
{
- ws_util_set_attachments_with_cids(env, enable_mtom, tmp_node, attach_ht, default_cnt_type TSRMLS_CC);
+ wsf_util_set_attachments_with_cids(env, enable_mtom, tmp_node, attach_ht, default_cnt_type TSRMLS_CC);
tmp_node = AXIOM_NODE_GET_NEXT_SIBLING(tmp_node, env);
}
return;
}
-int ws_util_set_options_with_msg(zval *zval_client, zval *zval_msg, axis2_env_t *env,
- axis2_options_t *client_options, axis2_svc_client_t *svc_client,int is_send TSRMLS_DC)
-{
- zval **tmp = NULL;
- zval **msg_tmp = NULL;
- int username_present = AXIS2_FALSE;
- int password_present = AXIS2_FALSE;
- int timestamp_present = AXIS2_FALSE;
- int use_soap = 0;
- int is_addressing_engaged = AXIS2_FALSE;
- int is_rm_enabled = AXIS2_FALSE;
-
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "useSOAP", sizeof("useSOAP"),
- (void **)&tmp) == SUCCESS){
- if(Z_TYPE_PP(tmp) == IS_STRING){
- char *value = NULL;
- value = Z_STRVAL_PP(tmp);
- if(value && strcmp(value,"1.2") == 0){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP12);
- }
- else if(value && strcmp(value,"1.1") == 0){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP11);
- }
- else if(value && strcmp(value, "false") == 0) {
- use_soap = 0;
- }
- }else if(Z_TYPE_PP(tmp) == IS_DOUBLE){
- double val = Z_DVAL_PP(tmp);
- if(val == 1.2){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP12);
- }else if(val == 1.1){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP11);
- }
- }else if(Z_TYPE_PP(tmp) == IS_BOOL){
- int bval = Z_BVAL_PP(tmp);
- if(bval == 1){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP12);
- }else if(bval == 0){
- use_soap = 0;
- }
- }
- }else
- {
- use_soap = 0;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "HTTPMethod", sizeof("HTTPMethod"),
- (void **)&tmp) == SUCCESS){
- if(use_soap == 0){
- char *value = NULL;
- value = Z_STRVAL_PP(tmp);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, AXIS2_ENABLE_REST,
- AXIS2_VALUE_TRUE);
- if(value && strcmp(value, "GET") == 0){
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, AXIS2_HTTP_METHOD,
- AXIS2_HTTP_HEADER_GET);
- }
- }
- }
-
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "useMTOM", sizeof("useMTOM"),
- (void **)&tmp) == SUCCESS){
- if(Z_TYPE_PP(tmp) == IS_BOOL){
- int val = Z_BVAL_PP(tmp);
- if(val == 0){
- AXIS2_OPTIONS_SET_ENABLE_MTOM(client_options, env, AXIS2_FALSE);
- }else{
- AXIS2_OPTIONS_SET_ENABLE_MTOM(client_options, env, AXIS2_TRUE);
- }
- }
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "to", sizeof("to"),
- (void**)&msg_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *to_epr = NULL;
- char *to = Z_STRVAL_PP(msg_tmp);
- to_epr = axis2_endpoint_ref_create(env, to);
- AXIS2_OPTIONS_SET_TO(client_options, env, to_epr);
- }else if(zend_hash_find(Z_OBJPROP_P(zval_client), "to", sizeof("to"),
- (void**)&msg_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *to_epr = NULL;
- char *to = Z_STRVAL_PP(msg_tmp);
- to_epr = axis2_endpoint_ref_create(env, to);
- AXIS2_OPTIONS_SET_TO(client_options, env, to_epr);
- }
- else
- {
- return AXIS2_FAILURE;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "useWSA", sizeof("useWSA"),
- (void**)&tmp) == SUCCESS) {
- if((Z_TYPE_PP(tmp) == IS_BOOL && Z_BVAL_PP(tmp) == 1) ||
- Z_TYPE_PP(tmp) == IS_STRING){
- axis2_char_t *value = NULL;
- int addr_action_present = AXIS2_FALSE;
-
-
- if(Z_TYPE_PP(tmp) == IS_BOOL){
- value = "1.0";
- }
- else if(Z_TYPE_PP(tmp) == IS_STRING){
- value = Z_STRVAL_PP(tmp);
- }
-
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "action", sizeof("action"),
- (void**)&msg_tmp) == SUCCESS) {
- AXIS2_OPTIONS_SET_ACTION(client_options, env, Z_STRVAL_PP(msg_tmp));
- addr_action_present = AXIS2_TRUE;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "replyTo", sizeof("replyTo"),
- (void**)&msg_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *replyto_epr = NULL;
- char *replyto = Z_STRVAL_PP(msg_tmp);
- replyto_epr = axis2_endpoint_ref_create(env, replyto);
- AXIS2_OPTIONS_SET_REPLY_TO(client_options, env, replyto_epr);
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "faultTo", sizeof("faultTo"),
- (void**)&msg_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *faultto_epr = NULL;
- char *faultto = Z_STRVAL_PP(msg_tmp);
- faultto_epr = axis2_endpoint_ref_create(env, faultto);
- AXIS2_OPTIONS_SET_FAULT_TO(client_options, env, faultto_epr);
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "from", sizeof("from"),
- (void**)&msg_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *from_epr = NULL;
- char *from = Z_STRVAL_PP(msg_tmp);
- from_epr = axis2_endpoint_ref_create(env, from);
- AXIS2_OPTIONS_SET_REPLY_TO(client_options, env, from_epr);
- }
- if(addr_action_present == AXIS2_TRUE){
- is_addressing_engaged = AXIS2_TRUE;
- AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, "addressing");
- if(strcmp(value,"submission") == 0){
- axis2_property_t *property = NULL;
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
- AXIS2_PROPERTY_SET_VALUE(property, env,
- AXIS2_STRDUP(AXIS2_WSA_NAMESPACE_SUBMISSION, env));
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, AXIS2_WSA_VERSION, property);
- }
- }
- }
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "user", sizeof("user"), (void **)&msg_tmp) == SUCCESS &&
- Z_TYPE_PP(msg_tmp) == IS_STRING){
- char *username = NULL;
- axis2_property_t *property = NULL;
- username = Z_STRVAL_PP(msg_tmp);
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_VALUE(property, env, username);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "user" ,property);
- username_present = AXIS2_TRUE;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "password", sizeof("password"), (void **)&msg_tmp) == SUCCESS &&
- Z_TYPE_PP(msg_tmp) == IS_STRING){
- char *password = NULL;
- axis2_property_t *property = NULL;
- property = axis2_property_create(env);
- password = Z_STRVAL_PP(msg_tmp);
- AXIS2_PROPERTY_SET_VALUE(property,env, password);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "password", property);
- password_present = AXIS2_TRUE;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "digest", sizeof("digest"), (void **)&msg_tmp) == SUCCESS &&
- Z_TYPE_PP(msg_tmp) == IS_BOOL){
- int use_digest = 0;
- char *password_type = NULL;
- axis2_property_t *property = NULL;
- use_digest = Z_BVAL_PP(msg_tmp);
- if(use_digest){
- password_type = "passwordDigest";
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_VALUE(property, env, password_type);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "passwordType" ,property);
- }
-
- }
- else if(password_present){
- char *password_type = NULL;
- axis2_property_t *property = NULL;
- password_type = "passwordText";
- property = axis2_property_create(env);
- 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_msg), "timeToLive", sizeof("timeToLive"),
- (void **)&msg_tmp) == SUCCESS && Z_TYPE_PP(msg_tmp) == IS_STRING){
- char *timeto_live = NULL;
- axis2_property_t *property = NULL;
- timeto_live = Z_STRVAL_PP(msg_tmp);
- if(timeto_live){
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_VALUE(property, env, get_time_to_live(timeto_live, env));
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "timeToLive" ,property);
- }
- timestamp_present = AXIS2_TRUE;
- }
- if(username_present && password_present){
- axis2_property_t *sec_prop = NULL;
- sec_prop = axis2_property_create(env);
- if(timestamp_present)
- AXIS2_PROPERTY_SET_VALUE(sec_prop, env, "UsernameToken Timestamp");
- else
- AXIS2_PROPERTY_SET_VALUE(sec_prop, env, "UsernameToken");
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "items", sec_prop);
- AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client , env, "rampart");
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "reliable", sizeof("reliable"), (void**)&msg_tmp) == SUCCESS
- && Z_TYPE_PP(msg_tmp) == IS_BOOL){
- is_rm_enabled = Z_BVAL_PP(tmp);
- }
- else if(zend_hash_find(Z_OBJPROP_P(zval_client), "reliable", sizeof("reliable"),(void**)&tmp) == SUCCESS
- && Z_TYPE_PP(tmp) == IS_BOOL){
- is_rm_enabled = Z_BVAL_PP(tmp);
- }
-
- if(is_rm_enabled && is_addressing_engaged){
- axis2_property_t *rmprop = NULL;
- rmprop = axis2_property_create(env);
- AXIS2_PROPERTY_SET_SCOPE(rmprop, env, AXIS2_SCOPE_APPLICATION);
- AXIS2_PROPERTY_SET_VALUE(rmprop, env, AXIS2_VALUE_TRUE);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "Sandesha2LastMessage", rmprop);
- if(!is_send){
- AXIS2_OPTIONS_SET_USE_SEPARATE_LISTENER(client_options, env, AXIS2_TRUE);
- }
- AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, "sandesha2");
- }
- return AXIS2_SUCCESS;
-}
-
-
-int ws_util_set_options(zval *zval_client, axis2_env_t *env,
- axis2_options_t *client_options, axis2_svc_client_t *svc_client,
- int is_send TSRMLS_DC)
-{
-
- zval **tmp = NULL;
- zval **msg_tmp = NULL;
- int is_addressing_engaged = AXIS2_FALSE;
- int username_present = AXIS2_FALSE;
- int password_present = AXIS2_FALSE;
- int timestamp_present = AXIS2_FALSE;
- int encription_present = AXIS2_FALSE;
- int use_soap = 0;
- int addr_action_present = AXIS2_FALSE;
-
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "useSOAP", sizeof("useSOAP"),
- (void **)&tmp) == SUCCESS){
- if(Z_TYPE_PP(tmp) == IS_STRING){
- char *value = NULL;
- value = Z_STRVAL_PP(tmp);
- if(value && strcmp(value,"1.2") == 0){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP12);
- }
- else if(value && strcmp(value,"1.1") == 0){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP11);
- }
- else if(value && strcmp(value, "false") == 0) {
- use_soap = 0;
- }
- }else if(Z_TYPE_PP(tmp) == IS_DOUBLE){
- double val = Z_DVAL_PP(tmp);
- if(val == 1.2){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP12);
- }else if(val == 1.1){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP11);
- }
- }else if(Z_TYPE_PP(tmp) == IS_BOOL) {
- int bval = Z_BVAL_PP(tmp);
- if(bval == 1){
- AXIS2_OPTIONS_SET_SOAP_VERSION(client_options, env, AXIOM_SOAP12);
- }
- }
- }else
- {
- use_soap = 0;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "HTTPMethod", sizeof("HTTPMethod"),
- (void **)&tmp) == SUCCESS){
- if(use_soap == 0){
- char *value = NULL;
- value = Z_STRVAL_PP(tmp);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, AXIS2_ENABLE_REST,
- AXIS2_VALUE_TRUE);
- if(value && strcmp(value, "GET") == 0){
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, AXIS2_HTTP_METHOD,
- AXIS2_HTTP_HEADER_GET);
- }
- }
- }
-
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "useMTOM", sizeof("useMTOM"),
- (void **)&tmp) == SUCCESS){
- if(Z_TYPE_PP(tmp) == IS_BOOL){
- int val = Z_BVAL_PP(tmp);
- if(val == 0){
- AXIS2_OPTIONS_SET_ENABLE_MTOM(client_options, env, AXIS2_FALSE);
- }else{
- AXIS2_OPTIONS_SET_ENABLE_MTOM(client_options, env, AXIS2_TRUE);
- }
- }
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "to", sizeof("to"),
- (void**)&tmp) == SUCCESS) {
- axis2_endpoint_ref_t *to_epr = NULL;
- char *to = Z_STRVAL_PP(tmp);
- to_epr = axis2_endpoint_ref_create(env, to);
- AXIS2_OPTIONS_SET_TO(client_options, env, to_epr);
- }
- else
- {
- return AXIS2_FAILURE;
- }
-
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "useWSA", sizeof("useWSA"),
- (void**)&tmp) == SUCCESS) {
- char *value = NULL;
- if(Z_TYPE_PP(tmp) == IS_STRING){
- value = Z_STRVAL_PP(tmp);
- }
- else if(Z_TYPE_PP(tmp) == IS_BOOL && Z_BVAL_PP(tmp) == 1){
- value = "1.0";
- }
-
- if(value && strcmp(value, "false") != 0){
- zval **addr_tmp;
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "action", sizeof("action"),
- (void**)&addr_tmp) == SUCCESS) {
- AXIS2_OPTIONS_SET_ACTION(client_options, env, Z_STRVAL_PP(addr_tmp));
- addr_action_present = AXIS2_TRUE;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "replyTo", sizeof("replyTo"),
- (void**)&addr_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *replyto_epr = NULL;
- char *replyto = Z_STRVAL_PP(addr_tmp);
- replyto_epr = axis2_endpoint_ref_create(env, replyto);
- AXIS2_OPTIONS_SET_REPLY_TO(client_options, env, replyto_epr);
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "faultTo", sizeof("faultTo"),
- (void**)&addr_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *faultto_epr = NULL;
- char *faultto = Z_STRVAL_PP(addr_tmp);
- faultto_epr = axis2_endpoint_ref_create(env, faultto);
- AXIS2_OPTIONS_SET_FAULT_TO(client_options, env, faultto_epr);
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "from", sizeof("from"),
- (void**)&addr_tmp) == SUCCESS) {
- axis2_endpoint_ref_t *from_epr = NULL;
- char *from = Z_STRVAL_PP(addr_tmp);
- from_epr = axis2_endpoint_ref_create(env, from);
- AXIS2_OPTIONS_SET_REPLY_TO(client_options, env, from_epr);
- }
- if(addr_action_present == AXIS2_TRUE){
- is_addressing_engaged = AXIS2_TRUE;
- AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, "addressing");
- if(strcmp(value,"submission") == 0){
- axis2_property_t *property = NULL;
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_SCOPE(property, env, AXIS2_SCOPE_REQUEST);
- AXIS2_PROPERTY_SET_VALUE(property, env,
- AXIS2_STRDUP(AXIS2_WSA_NAMESPACE_SUBMISSION, env));
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, AXIS2_WSA_VERSION, property);
- }
- }
- }
- }
-
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "user", sizeof("user"),
- (void **)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING){
- char *username = NULL;
- axis2_property_t *property = NULL;
- username = Z_STRVAL_PP(tmp);
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_VALUE(property, env, username);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "user" ,property);
- username_present = AXIS2_TRUE;
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "password", sizeof("password"), (void **)&msg_tmp) == SUCCESS &&
- Z_TYPE_PP(tmp) == IS_STRING){
- char *password = NULL;
- axis2_property_t *property = NULL;
- property = axis2_property_create(env);
- password = Z_STRVAL_PP(tmp);
- AXIS2_PROPERTY_SET_VALUE(property,env, password);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "password", property);
- password_present = AXIS2_TRUE;
- }
-
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "digest", sizeof("digest"), (void **)&tmp) == SUCCESS &&
- Z_TYPE_PP(tmp) == IS_BOOL){
- int use_digest = 0;
- char *password_type = NULL;
- axis2_property_t *property = NULL;
- use_digest = Z_BVAL_PP(tmp);
- if(use_digest){
- password_type = "passwordDigest";
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_VALUE(property, env, password_type);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "passwordType" ,property);
- }
- }else if(password_present){
- char *password_type = NULL;
- axis2_property_t *property = NULL;
- password_type = "passwordText";
- property = axis2_property_create(env);
- 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), "timeToLive", sizeof("timeToLive"),
- (void **)&tmp) == SUCCESS && Z_TYPE_PP(tmp) == IS_STRING)
- {
- char *timeto_live = NULL;
- axis2_property_t *property = NULL;
- timeto_live = Z_STRVAL_PP(tmp);
- if(timeto_live){
- property = axis2_property_create(env);
- AXIS2_PROPERTY_SET_VALUE(property, env, get_time_to_live(timeto_live, env));
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "timeToLive" ,property);
- }
- timestamp_present = AXIS2_TRUE;
- }
- if(username_present && password_present){
- axis2_property_t *sec_prop = NULL;
- sec_prop = axis2_property_create(env);
- if(timestamp_present){
- AXIS2_PROPERTY_SET_VALUE(sec_prop, env, "UsernameToken Timestamp");
- }else{
- AXIS2_PROPERTY_SET_VALUE(sec_prop, env, "UsernameToken");
- }
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "items", sec_prop);
- AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client , env, "rampart");
- }
- if(zend_hash_find(Z_OBJPROP_P(zval_client), "reliable", sizeof("reliable"),(void**)&tmp) == SUCCESS
- && Z_TYPE_PP(tmp) == IS_BOOL){
- axis2_property_t *rmprop = NULL;
- rmprop = axis2_property_create(env);
- AXIS2_PROPERTY_SET_SCOPE(rmprop, env, AXIS2_SCOPE_APPLICATION);
- AXIS2_PROPERTY_SET_VALUE(rmprop, env, AXIS2_VALUE_TRUE);
- AXIS2_OPTIONS_SET_PROPERTY(client_options, env, "Sandesha2LastMessage", rmprop);
- if(!is_send){
- AXIS2_OPTIONS_SET_USE_SEPARATE_LISTENER(client_options, env, AXIS2_TRUE);
- }
- if(is_addressing_engaged){
- AXIS2_SVC_CLIENT_ENGAGE_MODULE(svc_client, env, "sandesha2");
- }
- }
- return AXIS2_SUCCESS;
-}
-
-void ws_util_get_attachments(const axis2_env_t *env,
+void wsf_util_get_attachments(const axis2_env_t *env,
axiom_node_t *payload_node, zval *cid2str,zval *cid2contentType TSRMLS_DC)
{
axiom_node_t *node = NULL;
@@ -1105,7 +675,7 @@
tmp_node = AXIOM_NODE_GET_FIRST_CHILD(payload_node, env);
while(tmp_node)
{
- ws_util_get_attachments(env, tmp_node, cid2str, cid2contentType TSRMLS_CC);
+ wsf_util_get_attachments(env, tmp_node, cid2str, cid2contentType TSRMLS_CC);
tmp_node = AXIOM_NODE_GET_NEXT_SIBLING(tmp_node, env);
}
return;
@@ -1346,8 +916,8 @@
faultto_epr = axis2_endpoint_ref_create(env, faultto);
AXIS2_OPTIONS_SET_FAULT_TO(client_options, env, faultto_epr);
}
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "from", sizeof("from"),
- (void**)&tmp) == SUCCESS) {
+ if(zend_hash_find(Z_OBJPROP_P(zval_msg), "from", sizeof("from"),
+ (void**)&tmp) == SUCCESS) {
axis2_endpoint_ref_t *from_epr = NULL;
char *from = Z_STRVAL_PP(tmp);
from_epr = axis2_endpoint_ref_create(env, from);
@@ -1504,7 +1074,7 @@
wsf_util_set_security_options(zval_client, zval_msg, env, client_options, svc_client TSRMLS_CC);
- if(zend_hash_find(Z_OBJPROP_P(zval_msg), "reliable", sizeof("reliable"), (void**)&msg_tmp) == SUCCESS
+ if(zval_msg && zend_hash_find(Z_OBJPROP_P(zval_msg), "reliable", sizeof("reliable"), (void**)&msg_tmp) == SUCCESS
&& Z_TYPE_PP(msg_tmp) == IS_BOOL){
is_rm_enabled = Z_BVAL_PP(tmp);
@@ -1526,3 +1096,198 @@
}
return AXIS2_SUCCESS;
}
+
+int wsf_util_handle_request(
+ zval *this_ptr,
+ zval *param,
+ zval *return_value,
+ axis2_env_t *env,
+ axis2_svc_client_t *svc_client,
+ int is_oneway TSRMLS_DC)
+{
+/** for dom */
+ xmlNodePtr nodep;
+ zval **data = NULL;
+ axiom_node_t *payload = NULL;
+ axiom_node_t *res_payload = NULL;
+ axiom_xml_reader_t *reader = NULL;
+ axis2_options_t *client_options = NULL;
+
+ /** for iterating this obj properties */
+ zval **this_tmp = NULL;
+ /** for iterating axis2_msg prop */
+ zval **msg_tmp = NULL;
+ int responseXOP = 0;
+ int status = AXIS2_SUCCESS;
+ char *str_payload = NULL;
+ int str_payload_len = 0;
+ int input_type = WS_USING_INCORRECT_INPUT;
+
+
+ if(Z_TYPE_P(param) == IS_OBJECT &&
+ instanceof_function(Z_OBJCE_P(param), ws_message_class_entry TSRMLS_CC))
+ {
+ zval **tmp_val = NULL;
+ if(zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_STR,
+ sizeof(AXIS2_MSG_P_STR), (void**)&tmp_val) == SUCCESS){
+
+ str_payload = Z_STRVAL_PP(tmp_val);
+ str_payload_len = Z_STRLEN_PP(tmp_val);
+ reader = axiom_xml_reader_create_for_memory(env,
+ str_payload, str_payload_len, "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
+ if (!reader) {
+ zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
+ "xml reader create failed");
+ }
+ }
+ else if((zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_DOM,
+ sizeof(AXIS2_MSG_P_DOM), (void**)&tmp_val) == SUCCESS) ||
+ (zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_SXML,
+ sizeof(AXIS2_MSG_P_SXML), (void**)&tmp_val) == SUCCESS)){
+ nodep = wsf_get_xml_node(*tmp_val TSRMLS_CC);
+ reader = axiom_xml_reader_create_for_memory(env,
+ (void*)nodep->doc, 0, "utf-8", AXIS2_XML_PARSER_TYPE_DOC);
+ if (!reader) {
+ zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
+ "xml reader create failed");
+ }
+ }
+
+ input_type = WS_USING_MSG;
+
+ }else if(Z_TYPE_P(param) == IS_STRING){
+ /** we have an xml string */
+ str_payload = Z_STRVAL_P(param);
+ str_payload_len = Z_STRLEN_P(param);
+ input_type = WS_USING_STRING;
+ reader = axiom_xml_reader_create_for_memory(env,
+ str_payload, str_payload_len, "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
+ if (!reader) {
+ zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
+ "xml reader create failed");
+ }
+ }else if(Z_TYPE_P(param) == IS_OBJECT && instanceof_function(Z_OBJCE_P(param), dom_node_class_entry TSRMLS_CC)) {
+ nodep = wsf_get_xml_node(param TSRMLS_CC);
+ reader = axiom_xml_reader_create_for_memory(env,
+ (void*)nodep->doc, 0, "utf-8", AXIS2_XML_PARSER_TYPE_DOC);
+ if (!reader) {
+ zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
+ "xml reader create failed");
+ }
+ input_type = WS_USING_DOM;
+
+ }
+
+ payload = ws_util_read_payload(reader, env);
+
+ if (!payload) {
+ zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
+ "payload is empty");
+ }
+
+ client_options = (axis2_options_t *)AXIS2_SVC_CLIENT_GET_OPTIONS(svc_client, env);
+
+ if(input_type == WS_USING_MSG){
+ zval **ztmp = NULL;
+ zval **ztmp_this = NULL;
+ axis2_char_t *default_cnt_type = NULL;
+
+ status = wsf_util_set_options(this_ptr, param, env,
+ client_options, svc_client, 0 TSRMLS_CC);
+ if(status == AXIS2_FAILURE){
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "service endpoint uri is needed for invocation ");
+ }
+ if(zend_hash_find(Z_OBJPROP_P(param), "defaultAttachmentContentType",
+ sizeof("defaultAttachmentContentType"),
+ (void **)&ztmp) == SUCCESS && Z_TYPE_PP(ztmp) == IS_STRING){
+ default_cnt_type = Z_STRVAL_PP(ztmp);
+ }else{
+ default_cnt_type = "application/octet-stream";
+ }
+ if(zend_hash_find(Z_OBJPROP_P(this_ptr), "responseXOP",
+ sizeof("responseXOP"),
+ (void **)&ztmp_this) == SUCCESS && Z_TYPE_PP(ztmp_this) == IS_BOOL){
+ responseXOP = Z_BVAL_PP(ztmp_this);
+ }
+
+ if(zend_hash_find(Z_OBJPROP_P(param), "attachments", sizeof("attachments"),
+ (void **)&ztmp) == SUCCESS && Z_TYPE_PP(ztmp) == IS_ARRAY){
+ HashTable *ht = NULL;
+ int enable_mtom = AXIS2_TRUE;
+ enable_mtom = AXIS2_OPTIONS_GET_ENABLE_MTOM(client_options, env);
+ ht = Z_ARRVAL_PP(ztmp);
+ if(ht){
+ wsf_util_set_attachments_with_cids(env, enable_mtom, payload,
+ ht, default_cnt_type TSRMLS_CC);
+ }
+ }
+ }else if(input_type == WS_USING_DOM || input_type == WS_USING_STRING){
+ status = wsf_util_set_options(this_ptr, NULL, env,
+ client_options, svc_client, 0 TSRMLS_CC);
+ if(status == AXIS2_FAILURE){
+ php_error_docref(NULL TSRMLS_CC, E_ERROR, "service enpoint uri is needed for service invocation");
+ }
+ }
+
+ if(is_oneway)
+ {
+ int ret_val = 0;
+ ret_val = AXIS2_SVC_CLIENT_SEND_ROBUST(svc_client, env, payload);
+ if(ret_val == 1)
+ {
+ ZVAL_TRUE(return_value);
+ }else{
+ ZVAL_FALSE(return_value);
+ }
+ }else
+ {
+ res_payload = AXIS2_SVC_CLIENT_SEND_RECEIVE(svc_client, env, payload);
+ if (res_payload) {
+ axis2_char_t *res_text = NULL;
+ axis2_char_t *fault = NULL;
+
+ fault = axiom_util_get_localname(res_payload, env);
+
+ if( fault && 0 == strcmp(fault, "Fault"))
+ {
+ zval *rfault = NULL;
+ MAKE_STD_ZVAL(rfault);
+ object_init_ex(rfault, ws_fault_class_entry);
+ res_text = wsf_util_serialize_om(env, res_payload);
+ add_property_stringl(rfault, "str", res_text, strlen(res_text), 1);
+ ZVAL_ZVAL(return_value, rfault, NULL, NULL);
+ }
+ else {
+ zval *rmsg = NULL;
+ MAKE_STD_ZVAL(rmsg);
+ object_init_ex(rmsg, ws_message_class_entry);
+ if(input_type == WS_USING_MSG){
+ if(responseXOP == 1)
+ {
+ int attachments_found = AXIS2_FALSE;
+ zval *cid2str = NULL;
+ zval *cid2contentType = NULL;
+
+ MAKE_STD_ZVAL(cid2str);
+ MAKE_STD_ZVAL(cid2contentType);
+
+ array_init(cid2str);
+ array_init(cid2contentType);
+ wsf_util_get_attachments(env, res_payload, cid2str, cid2contentType TSRMLS_CC);
+
+ add_property_zval(rmsg, "attachments", cid2str);
+ add_property_zval(rmsg, "cid2contentType", cid2contentType);
+ }
+ }
+
+ res_text = wsf_util_serialize_om(env , res_payload);
+ add_property_stringl(rmsg, AXIS2_MSG_P_STR, res_text, strlen(res_text), 1);
+ ZVAL_ZVAL(return_value, rmsg, NULL, NULL);
+ }
+
+ } else {
+ zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
+ "soap body is not found");
+ }
+ }
+}
\ No newline at end of file
Modified: wsf/php/src/wsf.c
==============================================================================
--- wsf/php/src/wsf.c (original)
+++ wsf/php/src/wsf.c Wed Jan 10 22:37:17 2007
@@ -1010,195 +1010,21 @@
*/
PHP_FUNCTION(ws_client_request)
{
- /** for dom */
- xmlNodePtr nodep;
-
zval *param = NULL;
ws_object_ptr intern = NULL;
zval *obj = NULL;
- zval **data = NULL;
- axis2_svc_client_t *client = NULL;
- axis2_options_t *client_options = NULL;
- axiom_node_t *payload = NULL;
- axiom_node_t *res_payload = NULL;
- axiom_xml_reader_t *reader = NULL;
-
- /** for iterating this obj properties */
- zval **this_tmp = NULL;
- /** for iterating axis2_msg prop */
- zval **msg_tmp = NULL;
- int responseXOP = 0;
-
- int status = AXIS2_SUCCESS;
-
- char *str_payload = NULL;
- int str_payload_len = 0;
- int input_type = WS_USING_INCORRECT_INPUT;
-
+ axis2_svc_client_t *svc_client = NULL;
if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", ¶m)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
return;
}
-
- AXIS2_OBJ_CHECK(env);
-
- if(Z_TYPE_P(param) == IS_OBJECT &&
- instanceof_function(Z_OBJCE_P(param), ws_message_class_entry TSRMLS_CC))
- {
- zval **tmp_val = NULL;
- if(zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_STR,
- sizeof(AXIS2_MSG_P_STR), (void**)&tmp_val) == SUCCESS){
-
- str_payload = Z_STRVAL_PP(tmp_val);
- str_payload_len = Z_STRLEN_PP(tmp_val);
- reader = axiom_xml_reader_create_for_memory(env,
- str_payload, str_payload_len, "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "xml reader create failed");
- }
- }
- else if((zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_DOM,
- sizeof(AXIS2_MSG_P_DOM), (void**)&tmp_val) == SUCCESS) ||
- (zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_SXML,
- sizeof(AXIS2_MSG_P_SXML), (void**)&tmp_val) == SUCCESS)){
- nodep = ws_get_xml_node(*tmp_val);
- reader = axiom_xml_reader_create_for_memory(env,
- (void*)nodep->doc, 0, "utf-8", AXIS2_XML_PARSER_TYPE_DOC);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "xml reader create failed");
- }
- }
-
- input_type = WS_USING_MSG;
-
- }else if(Z_TYPE_P(param) == IS_STRING){
- /** we have an xml string */
- str_payload = Z_STRVAL_P(param);
- str_payload_len = Z_STRLEN_P(param);
- input_type = WS_USING_STRING;
- reader = axiom_xml_reader_create_for_memory(env,
- str_payload, str_payload_len, "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "xml reader create failed");
- }
- }else if(Z_TYPE_P(param) == IS_OBJECT && instanceof_function(Z_OBJCE_P(param), dom_node_class_entry TSRMLS_CC)) {
- nodep = ws_get_xml_node(param);
- reader = axiom_xml_reader_create_for_memory(env,
- (void*)nodep->doc, 0, "utf-8", AXIS2_XML_PARSER_TYPE_DOC);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "xml reader create failed");
- }
- input_type = WS_USING_DOM;
- }
-
- payload = ws_util_read_payload(reader, env);
-
- if (!payload) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "payload is empty");
- }
+ AXIS2_OBJ_CHECK(env);
AXIS2_GET_THIS(obj);
- AXIS2_GET_OBJ(client, obj, axis2_svc_client_t, intern);
-
- client_options = (axis2_options_t *)AXIS2_SVC_CLIENT_GET_OPTIONS(client, env);
-
- if(input_type == WS_USING_MSG){
- zval **ztmp = NULL;
- zval **ztmp_this = NULL;
- axis2_char_t *default_cnt_type = NULL;
-
- status = ws_util_set_options_with_msg(obj, param, env,
- client_options, client, 0 TSRMLS_CC);
- if(status == AXIS2_FAILURE){
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "service endpoint uri is needed for invocation ");
- }
- if(zend_hash_find(Z_OBJPROP_P(param), "defaultAttachmentContentType",
- sizeof("defaultAttachmentContentType"),
- (void **)&ztmp) == SUCCESS && Z_TYPE_PP(ztmp) == IS_STRING){
- default_cnt_type = Z_STRVAL_PP(ztmp);
- }else{
- default_cnt_type = "application/octet-stream";
- }
- if(zend_hash_find(Z_OBJPROP_P(obj), "responseXOP",
- sizeof("responseXOP"),
- (void **)&ztmp_this) == SUCCESS && Z_TYPE_PP(ztmp_this) == IS_BOOL){
- responseXOP = Z_BVAL_PP(ztmp_this);
- }
-
- if(zend_hash_find(Z_OBJPROP_P(param), "attachments", sizeof("attachments"),
- (void **)&ztmp) == SUCCESS && Z_TYPE_PP(ztmp) == IS_ARRAY){
- HashTable *ht = NULL;
- int enable_mtom = AXIS2_TRUE;
- enable_mtom = AXIS2_OPTIONS_GET_ENABLE_MTOM(client_options, env);
- ht = Z_ARRVAL_PP(ztmp);
- if(ht){
- ws_util_set_attachments_with_cids(env, enable_mtom, payload,
- ht, default_cnt_type TSRMLS_CC);
- }
- }
- }else if(input_type == WS_USING_DOM || input_type == WS_USING_STRING){
- status = ws_util_set_options(obj, env,
- client_options, client, 0 TSRMLS_CC);
- if(status == AXIS2_FAILURE){
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "service enpoint uri is needed for service invocation");
- }
- }
-
- res_payload = AXIS2_SVC_CLIENT_SEND_RECEIVE(client, env, payload);
- if (res_payload) {
- axis2_char_t *res_text = NULL;
- axis2_char_t *fault = NULL;
-
- fault = axiom_util_get_localname(res_payload, env);
-
- if( fault && 0 == strcmp(fault, "Fault"))
- {
- zval *rfault = NULL;
- MAKE_STD_ZVAL(rfault);
- object_init_ex(rfault, ws_fault_class_entry);
- res_text = wsf_util_serialize_om(env, res_payload);
- add_property_stringl(rfault, "str", res_text, strlen(res_text), 1);
- RETURN_ZVAL(rfault, NULL, NULL);
- }
- else {
- zval *rmsg = NULL;
- MAKE_STD_ZVAL(rmsg);
- object_init_ex(rmsg, ws_message_class_entry);
- if(input_type == WS_USING_MSG){
- if(responseXOP == 1)
- {
- int attachments_found = AXIS2_FALSE;
- zval *cid2str = NULL;
- zval *cid2contentType = NULL;
-
- MAKE_STD_ZVAL(cid2str);
- MAKE_STD_ZVAL(cid2contentType);
-
- array_init(cid2str);
- array_init(cid2contentType);
- ws_util_get_attachments(env, res_payload, cid2str, cid2contentType TSRMLS_CC);
-
- add_property_zval(rmsg, "attachments", cid2str);
- add_property_zval(rmsg, "cid2contentType", cid2contentType);
- }
- }
-
- res_text = wsf_util_serialize_om(env , res_payload);
- 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");
- }
+ AXIS2_GET_OBJ(svc_client, obj, axis2_svc_client_t, intern);
+ wsf_util_handle_request(obj, param, return_value, env, svc_client, AXIS2_FALSE TSRMLS_CC);
}
/* }}} end request */
@@ -1208,142 +1034,19 @@
*/
PHP_FUNCTION(ws_client_send)
{
- xmlNodePtr nodep;
-
zval *param = NULL;
ws_object_ptr intern = NULL;
zval *obj = NULL;
- zval **data = NULL;
-
- axis2_svc_client_t *client = NULL;
- axis2_options_t *client_options = NULL;
- axiom_node_t *payload = NULL;
- axiom_node_t *res_payload = NULL;
- axiom_xml_reader_t *reader = NULL;
-
- /** for iterating this obj properties */
- zval **this_tmp = NULL;
- /** for iterating axis2_msg prop */
- zval **msg_tmp = NULL;
-
- int status = AXIS2_SUCCESS;
-
- char *str_payload = NULL;
- int str_payload_len = 0;
- int input_type = WS_USING_INCORRECT_INPUT;
-
- if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z|a", ¶m)) {
+ axis2_svc_client_t *svc_client = NULL;
+ if (FAILURE == zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", ¶m)) {
php_error_docref(NULL TSRMLS_CC, E_ERROR, "Invalid parameters");
return;
}
AXIS2_OBJ_CHECK(env);
-
- if(Z_TYPE_P(param) == IS_OBJECT &&
- instanceof_function(Z_OBJCE_P(param), ws_message_class_entry TSRMLS_CC)){
- zval **tmp_val = NULL;
- if(zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_STR,
- sizeof(AXIS2_MSG_P_STR), (void**)&tmp_val) == SUCCESS){
-
- str_payload = Z_STRVAL_PP(tmp_val);
- str_payload_len = Z_STRLEN_PP(tmp_val);
- reader = axiom_xml_reader_create_for_memory(env,
- str_payload, str_payload_len, "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "out of memory");
- }
- }
- else if((zend_hash_find(Z_OBJPROP_P(param), AXIS2_MSG_P_DOM,
- sizeof(AXIS2_MSG_P_DOM), (void**)&tmp_val) == SUCCESS)){
- nodep = ws_get_xml_node(*tmp_val);
- reader = axiom_xml_reader_create_for_memory(env,
- (void*)nodep->doc, 0, "utf-8", AXIS2_XML_PARSER_TYPE_DOC);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "out of memory");
- }
- }
- input_type = WS_USING_MSG;
-
- }else if(Z_TYPE_P(param) == IS_STRING){
- /** we have an xml string */
- str_payload = Z_STRVAL_P(param);
- str_payload_len = Z_STRLEN_P(param);
- input_type = WS_USING_STRING;
- reader = axiom_xml_reader_create_for_memory(env,
- str_payload, str_payload_len, "utf-8", AXIS2_XML_PARSER_TYPE_BUFFER);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "out of memory");
- }
- }
- else if(Z_TYPE_P(param) == IS_OBJECT && instanceof_function(Z_OBJCE_P(param), dom_node_class_entry TSRMLS_CC)) {
- nodep = ws_get_xml_node(param);
- reader = axiom_xml_reader_create_for_memory(env,
- (void*)nodep->doc, 0, "utf-8", AXIS2_XML_PARSER_TYPE_DOC);
- if (!reader) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "out of memory");
- }
- input_type = WS_USING_DOM;
- }
-
- payload = ws_util_read_payload(reader, env);
-
- if (!payload) {
- zend_throw_exception_ex(zend_exception_get_default(TSRMLS_C), 1 TSRMLS_CC,
- "out of memory");
- }
AXIS2_GET_THIS(obj);
- AXIS2_GET_OBJ(client, obj, axis2_svc_client_t, intern);
-
- client_options = (axis2_options_t *)AXIS2_SVC_CLIENT_GET_OPTIONS(client, env);
-
- if(input_type == WS_USING_MSG){
- zval **ztmp = NULL;
- axis2_char_t *default_cnt_type = NULL;
-
- status = ws_util_set_options_with_msg(obj, param, env,
- client_options, client, 1 TSRMLS_CC);
- if(status == AXIS2_FAILURE){
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "Needto set endpointuri ");
- }
- if(zend_hash_find(Z_OBJPROP_P(param), "defaultAttachmentContentType",
- sizeof("defaultAttachmentContentType"),
- (void **)&ztmp) == SUCCESS && Z_TYPE_PP(ztmp) == IS_STRING){
- default_cnt_type = Z_STRVAL_PP(ztmp);
- }else{
- default_cnt_type = "application/octet-stream";
- }
- if(zend_hash_find(Z_OBJPROP_P(param), "attachments", sizeof("attachments"),
- (void **)&ztmp) == SUCCESS && Z_TYPE_PP(ztmp) == IS_ARRAY){
- int enable_mtom = AXIS2_TRUE;
- HashTable *ht = NULL;
- ht = Z_ARRVAL_PP(ztmp);
-
- enable_mtom = AXIS2_OPTIONS_GET_ENABLE_MTOM(client_options, env);
- if(ht){
- ws_util_set_attachments_with_cids(env, enable_mtom, payload,
- ht, default_cnt_type TSRMLS_CC);
- }
- }
- }else if(input_type == WS_USING_DOM || input_type == WS_USING_STRING){
-
- status = ws_util_set_options(obj, env,
- client_options, client ,1 TSRMLS_CC);
- if(status == AXIS2_FAILURE){
- php_error_docref(NULL TSRMLS_CC, E_ERROR, "client require a valid endpoint uri");
- }
- }
-
- status = AXIS2_SVC_CLIENT_SEND_ROBUST(client, env, payload);
- if(status == AXIS2_SUCCESS){
- RETURN_BOOL(1)
- }
- else{
- RETURN_BOOL(0);
- }
+ AXIS2_GET_OBJ(svc_client, obj, axis2_svc_client_t, intern);
+ wsf_util_handle_request(obj, param, return_value, env, svc_client, AXIS2_TRUE TSRMLS_CC);
}
/* }}} end send*/
Modified: wsf/php/src/wsf_util.h
==============================================================================
--- wsf/php/src/wsf_util.h (original)
+++ wsf/php/src/wsf_util.h Wed Jan 10 22:37:17 2007
@@ -57,37 +57,56 @@
axis2_svc_t *svc);
ws_svc_info_t* ws_svc_info_create();
+
void ws_svc_info_free(ws_svc_info_t *svc_info);
php_req_info_t* php_req_info_create();
void php_req_info_free(php_req_info_t *req_info);
-void ws_util_set_attachments_with_cids(const axis2_env_t *env,
- int enable_mtom, axiom_node_t *payload_node,
- HashTable *attach_ht, char *default_cnt_type TSRMLS_DC);
+void wsf_util_set_attachments_with_cids(
+ const axis2_env_t *env,
+ int enable_mtom,
+ axiom_node_t *payload_node,
+ HashTable *attach_ht,
+ char *default_cnt_type TSRMLS_DC);
-int ws_util_set_options_with_msg(zval *zval_client, zval *zval_msg, axis2_env_t *env,
- axis2_options_t *options, axis2_svc_client_t *svc_client,
+int wsf_util_set_options(
+ zval *zval_client,
+ zval *zval_msg,
+ axis2_env_t *env,
+ axis2_options_t *options,
+ axis2_svc_client_t *svc_client,
int is_send TSRMLS_DC);
-int ws_util_set_options(zval *zval_client, axis2_env_t *env,
- axis2_options_t *options, axis2_svc_client_t *svc_client,
- int is_send TSRMLS_DC);
-
-void ws_util_get_attachments(const axis2_env_t *env,
- axiom_node_t *payload_node, zval *cid2str,zval *cid2contentType TSRMLS_DC);
+void wsf_util_get_attachments(
+ const axis2_env_t *env,
+ axiom_node_t *payload_node,
+ zval *cid2str,
+ zval *cid2contentType TSRMLS_DC);
-int wsf_util_set_headers(const axis2_env_t *env,
- axis2_svc_client_t *svc_client,
- zval *msg);
+int wsf_util_set_headers(
+ const axis2_env_t *env,
+ axis2_svc_client_t *svc_client,
+ zval *msg TSRMLS_DC);
char* wsf_util_serialize_om(axis2_env_t *env, axiom_node_t *ret_node);
xmlDocPtr wsf_util_serialize_om_to_doc(axis2_env_t *env, axiom_node_t *ret_node);
axis2_env_t* wsf_env_create(axis2_char_t *logpath);
+
void wsf_env_free(axis2_env_t *env);
axis2_env_t* wsf_env_create_for_client(axis2_char_t *cli_logpath);
+
+int wsf_util_handle_request(
+ zval *this_ptr,
+ zval *param,
+ zval *return_value,
+ axis2_env_t *env,
+ axis2_svc_client_t *svc_client,
+ int is_oneway TSRMLS_DC);
+
+
#endif /* WS_UTIL_H */
Modified: wsf/php/src/xml_msg_recv.c
==============================================================================
--- wsf/php/src/xml_msg_recv.c (original)
+++ wsf/php/src/xml_msg_recv.c Wed Jan 10 22:37:17 2007
@@ -540,7 +540,7 @@
array_init(cid2str);
array_init(cid2contentType);
- ws_util_get_attachments(env, om_node, cid2str, cid2contentType TSRMLS_CC);
+ wsf_util_get_attachments(env, om_node, cid2str, cid2contentType TSRMLS_CC);
add_property_zval(msg, "attachments", cid2str);
add_property_zval(msg, "cid2contentType", cid2contentType);
@@ -603,7 +603,7 @@
HashTable *ht = NULL;
ht = Z_ARRVAL_PP(msg_tmp);
if(ht && res_om_node){
- ws_util_set_attachments_with_cids(env, use_mtom, res_om_node,
+ wsf_util_set_attachments_with_cids(env, use_mtom, res_om_node,
ht, default_cnt_type TSRMLS_CC);
if(use_mtom == 1){
axis2_property_t *property = axis2_property_create(env);
More information about the Wsf-c-dev
mailing list