Heiko Lang - 2008-10-02

Some people have problems to use nusoap with java axis. Possible a soap request is to be sent on nusoap by java axis, but java axis do not understand the answer of nusoap. nusoap forget to map php hash variables for java axis. The following workaround for nusoap server permits a full communication with java axis and nusoap without change nusoap sources. Uses the request multiRef then send the answer with soap mapping:

class nusoap_javaaxis_server extends nusoap_server
        function serialize_val ($val, $name=false, $type=false, $name_ns=false, $type_ns=false, $attributes=false, $use='encoded', $soapval=false)
                if (($this->request) && (preg_match("/<multiRef/i", $this->request)) &&
                    (is_array($val)) && ("arrayStruct" === $this->isArraySimpleOrStruct($val))) {
                        $type = "Map";
                        $type_ns = "http://xml.apache.org/xml-soap";

                return parent::serialize_val($val, $name, $type, $name_ns, $type_ns, $attributes, $use, $soapval);

And now still another fictitious example of one soap request of one java axis client which accessed one nusoap server who answers a php hash variable (because i did not found this anywhere):

import java.util.*;
import org.apache.axis.Constants;
import org.apache.axis.client.Call;
import org.apache.axis.client.Service;
import org.apache.axis.encoding.XMLType;
import javax.xml.namespace.QName;
import javax.xml.rpc.ParameterMode;

public class record_get
        public static void main(String [] args) {
                try {
                        String soapurl = "http://my.domain.com/nusoap_server.php";

                        // instantiate new Service object
                        Service service = new Service();

                        // instantiate new Call object
                        Call call = (Call) service.createCall();

                        // set appropriate end point address
                        call.setTargetEndpointAddress(new java.net.URL(soapurl));
                        call.setOperationName(new QName("urn:data/data_get", "data_get"));

                        // set in parameter of SOAP function
                        call.addParameter("data", XMLType.SOAP_VECTOR, ParameterMode.IN);
                        call.addParameter("options", XMLType.SOAP_VECTOR, ParameterMode.IN);

                        // create SOAP call parameter
                        HashMap<String,Object> options = new HashMap<String,Object>();
                        HashMap<String,Object> subopt = new HashMap<String,Object>();
                        subopt.put("john", "doe");
                        options.put("test", subopt);

                        Hashtable<String,Object> data = new Hashtable<String,Object>();

                        Object[] params = new Object[] { data, options };

                        // set out parameter of SOAP function

                        // call SOAP function
                        HashMap ret = (HashMap) call.invoke(params);

                        // result of SOAP function
                } catch (Exception e) {