axis-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Bouche Paul" <Paul.Bou...@student.hpi.uni-potsdam.de>
Subject RE: java.util.HashMap (a bit long)
Date Wed, 29 Sep 2004 10:17:58 GMT
Hello,

I am using AXIS 1.2beta 3.
I will post the server side code, the .wsdd (the wsdl is autogenerated by axis using the wsdd
parameters), and then will try to give a walkthrough what to change in the .NET generated
code (using wsdl.exe or Add WebReference) and why it had to be changed.  Forgive that I am
posting C# code on this list.

I used the wrapped (doc/literal with rpc method name wrapping convention) style.  It also
works with pure doc/lit (if you want information on that let me know) and put in my HashMap
only strings which was enough for the service I had to invoke, I also just tested it with
String[], so it should work with int[] and so on, and maybe with a JavaBean[], but I am not
sure about that.  The knwon problems sending arrays and receiving them with .net apply yet
there will be now schema definition for the type you are receiving with anytype, so you have
to use reflection to find out what the things are the XmlSerializer produced or know before
hand what you will receive.


//server side code
//----------------
package testhashmapservicealldoc;

public class TestHashMapService {
	public HashMap sayHashMap (String in)
	{
		HashMap h = new HashMap();
		
		String[] t = new String[] {"one", "one2", "one3", "one4"};
		
		h.put("key 1", t);
		h.put("key 2", "two");
		h.put("key 3", "three");
		h.put("key 4", in);
			
		return h;
	}
}


-------- the .wsdd file

<deployment name="test" xmlns="http://xml.apache.org/axis/wsdd/"
    xmlns:java="http://xml.apache.org/axis/wsdd/providers/java">
  <service name="TestHashMapServiceWrapped" style="wrapped" use="literal">
    <parameter name="className" value="testhashmapservicealldoc.TestHashMapService"/>
    <parameter name="allowedMethods" value="*"/>
  </service>
</deployment>

------- 

------- generated code of wsdl.exe with comments where to change things
// 
// This source code was auto-generated by Microsoft.VSDesigner, Version 1.1.4322.573.
// 
namespace TestHashMap.testhashmapservicewrapped {
    using System.Diagnostics;
    using System.Xml.Serialization;
    using System;
    using System.Web.Services.Protocols;
    using System.ComponentModel;
    using System.Web.Services;
    
    
    /// <remarks/>
    [System.Diagnostics.DebuggerStepThroughAttribute()]
    [System.ComponentModel.DesignerCategoryAttribute("code")]
    [System.Web.Services.WebServiceBindingAttribute(Name="TestHashMapServiceWrappedSoapBinding",

	Namespace="http://localhost:8080/axis1-2/services/TestHashMapServiceWrapped")]
    [System.Xml.Serialization.XmlIncludeAttribute(typeof(mapItem[]))]
    public class TestHashMapServiceService : System.Web.Services.Protocols.SoapHttpClientProtocol
{
        
        /// <remarks/>
        public TestHashMapServiceService() {
            this.Url = "http://localhost:8080/axis1-2/services/TestHashMapServiceWrapped";
        }
        
        /// <remarks/>
        [System.Web.Services.Protocols.SoapDocumentMethodAttribute("", RequestNamespace="http://testhashmapservicealldoc",
		ResponseNamespace="http://testhashmapservicealldoc", Use=System.Web.Services.Description.SoapBindingUse.Literal,
		ParameterStyle=System.Web.Services.Protocols.SoapParameterStyle.Wrapped)]
        
        // change the following to
        // [return: System.Xml.Serialization.XmlArrayAttribute("sayHashMapReturn", Namespace="http://testhashmapservicealldoc")]
        [return: System.Xml.Serialization.XmlArrayAttribute("sayHashMapReturn")]

        // change the following to
        // [return: System.Xml.Serialization.XmlArrayItemAttribute("item", Namespace="", IsNullable=false)]
        [return: System.Xml.Serialization.XmlArrayItemAttribute("item", Namespace="http://xml.apache.org/xml-soap",
IsNullable=false)]

        public mapItem[] sayHashMap(string @in) {
            object[] results = this.Invoke("sayHashMap", new object[] {
                        @in});
            return ((mapItem[])(results[0]));
        }
        
        /// <remarks/>
        public System.IAsyncResult BeginsayHashMap(string @in, System.AsyncCallback callback,
object asyncState) {
            return this.BeginInvoke("sayHashMap", new object[] {
                        @in}, callback, asyncState);
        }
        
        /// <remarks/>
        public mapItem[] EndsayHashMap(System.IAsyncResult asyncResult) {
            object[] results = this.EndInvoke(asyncResult);
            return ((mapItem[])(results[0]));
        }
    }
    
    /// <remarks/>
    // change the following to
    // [System.Xml.Serialization.XmlTypeAttribute(Namespace="")]
    [System.Xml.Serialization.XmlTypeAttribute(Namespace="http://xml.apache.org/xml-soap")]
    public class mapItem {
        
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public object key;
        
        /// <remarks/>
        [System.Xml.Serialization.XmlElementAttribute(IsNullable=true)]
        public object value;
    }
}
----------------------

So there had to be three changes for it to work:
 - the namespace of sayHashMapReturn element is ""; this is incorrect according to the wsdl
it should be "http://testhashmapservicealldoc"
 - the namespace of the item element in the return is "" so we need to change this (weather
this is a wrong interpretation of .NET or AXIS according to the schema, I am not sure, from
my opinion and the reading of the schema in the wsdl the namespace of item should be "" and
also the in the previous problem it should be "" since both are child elements of and they
are understood to be in the namespace "")
 - the namespace of the mapitem class also needs to be changed to "" (same discussion as above;
though the type Map is in the namespace "http://xml.apache.org/xml-soap" the elements key
and value are not in the namespace)

Can anyone comment on the namespace thing, for clarification what is the right (if you need
the wsdl which has the schema def run the compiled .java code through
java org.apache.axis.wsdl.Java2WSDL -y WRAPPED -u LITERAL testhashmapservicealldoc.TestHashMapService
-l http://foo)

Okay that it,

Paul


> -----Original Message-----
> From: Dorner, Thomas [mailto:Thomas.Dorner@t-systems.com]
> Sent: Mittwoch, 29. September 2004 08:22
> To: axis-user@ws.apache.org
> Subject: AW: java.util.HashMap
> 
> 
> Hi,
> 
> I am also using HashMaps, but only in AXIS - so I am 
> interessted in your
> solution for Interoperability reasons
> 
> Thanks Tomi
> 
> --------------------------------------------------------------
> --------------
> ---------------
> T-Systems International GmbH
> Service Line Systems Integration
> Competence Center EDM
> Department EPDM/D
> Fasanenweg 5, D 70771 Leinfelden
>  
> Tel.:        +49/711 972 - 44747
> Fax.:       +49/711 972 - 90330
>  
> mailto:Thomas.Dorner@t-systems.com
> http://www.t-systems.de
>  
> 
> 
> -----Ursprüngliche Nachricht-----
> Von: Bouche Paul [mailto:Paul.Bouche@student.hpi.uni-potsdam.de] 
> Gesendet: Dienstag, 28. September 2004 15:41
> An: axis-user@ws.apache.org
> Betreff: java.util.HashMap
> 
> If anyone is interested I have managed to receive a 
> java.lang.util.HashMap
> with .NET returned by an AXIS web service.  During the 
> process of trying to
> work that out I also found out that the root of the problem 
> was a namespace
> differrency: .NET interpreted the namespaces of the WSDL false and
> addtitionally AXIS did not itself conform to the (auto 
> generated - with
> ?wsdl) WSDL.
> 
> I intentionally did not include any more details because I 
> don't know if
> there is any interest in this.
> 
> Paul
> 
> .
> 
> .
> 

.

Mime
View raw message