Title: RE: Interoperability Axis with .NET (C#)
Using the Axis1.0 samples for encoding using custom serralizer/deserializer, I wish to pass an array of complex data types to .Net(C# Web Reference).  In addition, I am using Java2Wsdl. 
The C# .Net side Web Refernce auto-generated code catches System.InvalidOperationException: There is an error in XML document (5, 5). ---> System.InvalidOperationException: Namespace prefix 'null' is not defined.
 
Below is the relevant Java code:
 
<!--server-config.wsdd data service entry -->
<service name="ElementService" provider="java:RPC">
        <parameter name="className" value="com.bah.tia.portal.service.elementService.ElementService"/>
        <parameter name="allowedMethods" value="*" />
  <typeMapping qname="multiRef" xmlns:ns="
http://schemas.xmlsoap.org/wsdl/"
      languageSpecificType="java:com.bah.tia.portal.domain.Data"
                     serializer="com.bah.tia.portal.util.customSerialization.DataSerFactory"
                     deserializer="com.bah.tia.portal.util.customSerialization.DataDeserFactory"
                     encodingStyle="
http://schemas.xmlsoap.org/soap/encoding/"/>
</service>
 
public class ElementService
{
    public Data[] getDataObjects()
    {
        Data[] dataObjects = new Data[3];
        dataObjects[0]= new Data();
        dataObjects[1]= new Data();
        dataObjects[2]= new Data();
        return(dataObjects);
    }
    public String helloWorld()
    {
        System.out.println("testing...");
        return("Hello World!!");
    }
}
 
public class Data
{
    public String stringMember;
    public Float floatMember;
    public Data() {
        stringMember = "default string";
        floatMember  = new Float(0.00);
    }
 
    public Data(String stringMember, Float floatMember) {
        this();
        this.stringMember = stringMember;
        this.floatMember  = floatMember;
    }
}
 
public class DataSer implements Serializer
{
    public static final String STRINGMEMBER = "stringMember";
    public static final String FLOATMEMBER = "floatMember";

    public void serialize(QName name, Attributes attributes,
                          Object value, SerializationContext context)
        throws IOException
    {

       if (value instanceof Data) {
           Data data = "">
           context.startElement(name, attributes);
           context.serialize(new QName("", STRINGMEMBER), null, data.stringMember);
           context.serialize(new QName("", FLOATMEMBER), null, data.floatMember);
           context.endElement();
       }
       else
           throw new IOException("Can't serialize a " + value.getClass().getName() + " with a DataSerializer.");
       }
      
    public String getMechanismType() { return Constants.AXIS_SAX; }

    public boolean writeSchema(Types types) throws Exception {
        return false;
    }
}
 
 
public class DataDeser extends DeserializerImpl
{
    public static final String STRINGMEMBER = "stringMember";
    public static final String FLOATMEMBER  = "floatMember";
    private Hashtable typesByMemberName = new Hashtable();
 
    public DataDeser()
    {
        typesByMemberName.put(STRINGMEMBER, Constants.XSD_STRING);
        typesByMemberName.put(FLOATMEMBER, Constants.XSD_FLOAT);
        value = new Data();
    }
 
     public SOAPHandler onStartChild(String namespace,
                                    String localName,
                                    String prefix,
                                    Attributes attributes,
                                    DeserializationContext context)
        throws SAXException
    {
        QName typeQName = (QName)typesByMemberName.get(localName);
 
        if (typeQName == null)
            throw new SAXException("Invalid element in Data struct - " + localName);
 
        // These can come in either order.
        Deserializer dSer = context.getDeserializerForType(typeQName);
 
        try {
            dSer.registerValueTarget(new FieldTarget(value, localName));
        } catch (NoSuchFieldException e) {
            e.printStackTrace();
            throw new SAXException(e);
        }
 
        if (dSer == null)
            throw new SAXException("No deserializer for a " + typeQName + "???");
 
        return (SOAPHandler)dSer;
    }
}
JAVA2WSDL:
java -cp ./deploy/development/tia.jar:./lib/axis/axis.jar:./lib/axis/commons-logging.jar:./lib/axis/commons-discovery.jar:./lib/axis/wsdl4j.jar:./lib/axis/jaxrpc.jar:./lib/axis/saaj.jar:./lib/common/deploy/xalan.jar org.apache.axis.wsdl.Java2WSDL -o ElementService-dev.wsdl -l"http://honda:6001/tia/services/ElementService" com.bah.tia.portal.service.elementService.ElementService
 
WSDL
<?xml version="1.0" encoding="UTF-8"?>
<wsdl:definitions targetNamespace="http://elementService.service.portal.tia.bah.com" xmlns="http://schemas.xmlsoap.org/wsdl/" xmlns:apachesoap="http://xml.apache.org/xml-soap" xmlns:impl="http://elementService.service.portal.tia.bah.com" xmlns:intf="http://elementService.service.portal.tia.bah.com" xmlns:soapenc="http://schemas.xmlsoap.org/soap/encoding/" xmlns:tns2="http://domain.portal.tia.bah.com" xmlns:wsdl="http://schemas.xmlsoap.org/wsdl/" xmlns:wsdlsoap="http://schemas.xmlsoap.org/wsdl/soap/" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wsdl:types>
<schema targetNamespace="http://domain.portal.tia.bah.com" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="Data">
<sequence>
<element name="stringMember" nillable="true" type="xsd:string"/>
<element name="floatMember" nillable="true" type="xsd:float"/>
</sequence>
</complexType>
</schema>
<schema targetNamespace="http://elementService.service.portal.tia.bah.com" xmlns="http://www.w3.org/2001/XMLSchema">
<import namespace="http://schemas.xmlsoap.org/soap/encoding/"/>
<complexType name="ArrayOf_tns2_Data">
<complexContent>
<restriction base="soapenc:Array">
<attribute ref="soapenc:arrayType" wsdl:arrayType="tns2:Data[]"/>
</restriction>
</complexContent>
</complexType>
<element name="ArrayOf_tns2_Data" nillable="true" type="impl:ArrayOf_tns2_Data"/>
</schema>
</wsdl:types>
<wsdl:message name="getDataObjectsRequest">
</wsdl:message>
<wsdl:message name="helloWorldRequest">
</wsdl:message>
<wsdl:message name="helloWorldResponse">
<wsdl:part name="helloWorldReturn" type="xsd:string"/>
</wsdl:message>
<wsdl:message name="getDataObjectsResponse">
<wsdl:part name="getDataObjectsReturn" type="impl:ArrayOf_tns2_Data"/>
</wsdl:message>
<wsdl:portType name="ElementService">
<wsdl:operation name="getDataObjects">
<wsdl:input message="impl:getDataObjectsRequest" name="getDataObjectsRequest"/>
<wsdl:output message="impl:getDataObjectsResponse" name="getDataObjectsResponse"/>
</wsdl:operation>
<wsdl:operation name="helloWorld">
<wsdl:input message="impl:helloWorldRequest" name="helloWorldRequest"/>
<wsdl:output message="impl:helloWorldResponse" name="helloWorldResponse"/>
</wsdl:operation>
</wsdl:portType>
<wsdl:binding name="ElementServiceSoapBinding" type="impl:ElementService">
<wsdlsoap:binding style="rpc" transport="http://schemas.xmlsoap.org/soap/http"/>
<wsdl:operation name="getDataObjects">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="getDataObjectsRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://elementService.service.portal.tia.bah.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="getDataObjectsResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://elementService.service.portal.tia.bah.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
<wsdl:operation name="helloWorld">
<wsdlsoap:operation soapAction=""/>
<wsdl:input name="helloWorldRequest">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://elementService.service.portal.tia.bah.com" use="encoded"/>
</wsdl:input>
<wsdl:output name="helloWorldResponse">
<wsdlsoap:body encodingStyle="http://schemas.xmlsoap.org/soap/encoding/" namespace="http://elementService.service.portal.tia.bah.com" use="encoded"/>
</wsdl:output>
</wsdl:operation>
</wsdl:binding>
<wsdl:service name="ElementServiceService">
<wsdl:port binding="impl:ElementServiceSoapBinding" name="ElementService">
<wsdlsoap:address location="http://honda:6001/tia/services/ElementService"/>
</wsdl:port>
</wsdl:service>
</wsdl:definitions>

Reply via email to